To programmatically access the vCloud Compute Service, you must discover the plans and instances available in Virtual Private Cloud OnDemand.

Log in and List Available Plans and Instance Sequence Diagram
Log in and List Available Plans and Instance Sequence Diagram

You have signed up and registered for Virtual Private Cloud OnDemand and received an email with a user name and password for an Account Administrator.

Using the URL in the confirmation email, you have logged in to Virtual Private Cloud OnDemand using the Web UI, set your password, and accepted the Terms of Service.

1

POST a request that includes your user name and password in a MIME Base64 encoding:

POST https://vca.vmware.com/api/iam/login

The initial POST requires that you enter the Authorization header with an encoded Base64 username:password value as shown:

Authorization: Basic [email protected]:password

Wherein [email protected]:password is encoded.

If the request is successful, the server returns HTTP response code 201 Created and a response that contains the vchs-authorization.

2

Issue a request to get the list of service plans for your account:

GET https://vca.vmware.com/api/sc/plans

In the request, include the OAuth token:

Authorization: Bearer OAuth_token

Include the OAuth token in all subsequent API requests as a request header.

The returned response includes the list of plans for your account. Each plan consists of the following elements:

Element

Description

id

The ID of the plan

name

The name of the plan

region

The geographical location where the plan is offered

description

Description about the plan

planVersion

The version of the plan

serviceUri

The API endpoint of the service offering for the plan

instanceSpec

Custom values to create an instance

When instanceSpec is specified, default values are not used when the instance is created.

planAttributes

The attributes associated with a given plan

planPolicy

Policy information for the plan

The planPolicy element enables functionality for future releases.

3

Issue a request to get a list of all the instances:

GET https://vca.vmware.com/api/sc/instances

The response includes your list of all instances. Each instance has the following elements:

Element

Description

description

Description of the instance

region

The geographical location where the instance was created

instanceVersion

The version of the instance

planId

The plan associated with the creation of the instance

serviceGroupId

The service group ID associated with the creation of the instance

apiUrl

The API endpoint to access the instance

You use the value in the apiUrl to log in to the Compute Service for Virtual Private Cloud OnDemand.

dashboardUrl

The URL to access the Compute Service by using the Web UI

instanceAttributes

The attributes associated with a given instance

id

The ID of the instance

name

The name of the instance

Request Header – Log in

POST https://vca.vmware.com/api/iam/login 
Accept: application/json;version=5.7 
Authorization: Basic cHhzdXNlcjFAdm13YXJlLmNvbTpQYXNzQDEyMw==… 

Request body not required.

Response – Log in

HTTP/1.1 201 Created 
Header: 
  vchs-authorization: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmOTF…
Body:
  {"serviceGroupIds":["37"]}

Request Header – Get plans

GET https://vca.vmware.com/api/sc/plans
Accept: application/json;version=5.7
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmOTF…

Response body not required.

Response Body – Get plans

{
  {
  "plans": [{
    "link": [],
    "region": "LVG",
    "serviceName": "com.vmware.vchs.compute",
    "description": "Create virtual machines, and scale as your needs change.",
    "planVersion": "1.0",
    "instanceSpec": "",
    "planAttributes": "attributes",
    "planPolicy": {
       "canCreateInstance": true,
       "canCreateBinding": true,
       "maxInstanceCount": 1
    },
    "id": "6",
    "name": "Virtual Private Cloud OnDemand"
   }]
}

Request Header – Get instances

GET https://vca.vmware.com/api/sc/instances
Accept: application/json;version=5.7
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmOTF…

Response Body – Get instances

{
  "instances": [{
    "link": [],
    "description": "Create virtual machines, and scale as your needs change.",
    "region": "LVG",
    "instanceVersion": "1.0",
    "planId": "24",
    "serviceGroupId": "37",
    "apiUrl": "https://example_host.vmware.com/api/compute/api/org/17",
    "dashboardUrl": "https://example_host.vmware.com/api/compute/compute/ui?orgName=42&serviceInstanceId=17",
    "instanceAttributes": "{\"orgName\":\"42\",\"sessionUri\":\"https://example_host.vmware.com/api/compute/api/sessions\"}",
    "id": "71",
    "name": "Virtual Private Cloud OnDemand"
  }]
}