Skip to content
writeameer edited this page Sep 14, 2010 · 12 revisions

(Github Link )

Instantiate the NRightApi object and call the Login method using your RightScale username, password and account number:

    using RightClient;

    class Program
    {
        static void Main(string[] args)
        {
            // Instantiate NRightAPI using RS account number
            var api = new NRightApi(account);

            // Log in to RightScale 
            api.Login(username, password);

Once logged in, you are issued a session cookie by RightScale. This session cookie is automatically added to all subsequent HTTP requests to RightScale. The following is an example of retrieving all the RightScripts in your RightScale account:

       
// Example: Get All Right Scipts
var restResponse = api.Send(NRightApi.Get, “right_scripts.xml”);
NRightApi.DisplayRestResponse(restResponse);

The following is an example of creating a server template using NRightAPI

           
            // Example: Create a server template
             restResponse = api.Send(
                NRightApi.Post,"server_templates",
                "server_template[nickname]=template nickname",
                "server_template[description]=template description",
                "server_template[multi_cloud_image_href]=http://<multicloudhref>",
                "server_template[instance_type]=m1.small"
                );

            NRightApi.DisplayRestResponse(restResponse);

The following is an example of creating a server using NRightAPI

            // Example: Create Server
            restResponse = api.Send(
                NRightApi.Post, "servers",
                "server[cloud_id]=1",
                "server[nickname]=Server nickname",
                "server[server_template_href]=http://<server template href>",
                "server[ec2_ssh_key_href]=https://<ssh key href>",
                "server[ec2_security_groups_href]=https://<security gorup href>",
                "server[deployment_href]=<https://deployment href>",
                "server[instance_type]=m1.small"
                );

            NRightApi.DisplayRestResponse(restResponse);   
        }
    }

Clone this wiki locally