Accessing the API with .NET

Requirements

To begin to use Cube Panel's access library with .NET, follow these steps:

WSUser class

This class provides access to the other classes of Cube Panelīs WebServices. Its constructor has the following definitions:

WSUser user = new WSUser(user_name, password, server, port, id_language)

Getting access to WebServices

Once a WSUser class request is obtained, the WebServices can be directly used with the following:

     

                // We create an WSUser instance with admin as invoking user                

                WSUser admin = WSUser("admin","admin_passw","server",25112,1);            

                // And call ADMINCLIENTS_getClients method. It returns a list of clients

                ClientInfo []clients = admin.ADMINCLIENTS_getClients("",null,"");

            

Obtaining credentials for another users

Other users can be added after the first request with the getUser method. You only have to use the username as a parameter; see the following example:

 

                    WSUser client = admin->getUser("testclient");	// Get a client user

                    WSUser domain = client->getUser("testdomain1.com");	// Get a domain user

                    WSUser domain = admin->getUser("testdomain2.com");	// Get another domain user

            

Using Webservices

Once a WSUser class request is obtained with the necessary credentials, there are two ways to access the WebServices: using the methods provided by the class, or with the execute method.

It is recommended that you access through the methods provided by your own class. A method is provided for each of Cube Panel's APIīs WebServices. However, if you prefer to access through the execute method, use these definitions:

public object []execute(string method, object []params)

The following example demonstrates the recommended method of accessing WebServices:

     

            using CubeWS;

            class Prueba

            {

                [STAThread]

                static void Main(string[] args)

                {

                

                    // Init access objects

                    WSUser admin = WSUser("admin","123456","hostinglinux.com",25112,0);

                    WSUser client = admin->getUser("client");	// Server administrator

                    WSUser domain = client->getUser("testdomain1.com");	// testdomain1.com must belong to client

                    WSUser domain = admin->getUser("testdomain2.com");	// it also allowed

                    

                    // Get client list (must be called by admin)

                    ClientInfo []cinfo = admin.ADMINCLIENTS_getClients("",null,"");

                    

                    // Get client domains (must be called by a client)

                    DomainInfo []dinfo = client.DOMAINS_getDomains(0,"",null,"");

                    

                    // Get domain FTP accounts (must be called by a domain)

                    FTPUserInfo []ftuser = user.FTP_listUsers("",null,"");

                }

            }