vCloud Air requires login requests to be authenticated. Begin the workflow with a login request that supplies user credentials in the MIME Base64 encoding format as specified in RFC 1421.
As a vCloud Air client, you present your credentials one time to log in and view the list of your subscribed compute services in vCloud Air.
The Session element, which the API returns from a successful login, contains a link to the services for that vCloud Air account. The client invokes the service link and receives a list of services. Each service contains a serviceType, serviceId, and an href to the content for that service. The compute serviceType has the following values:
■
| |
■
|
The vCloud Air automated subscription system assigns the value of the serviceId attribute.
1 | POST a request to this URL that includes your user name and password in a MIME Base64 encoding: POST https://vchs.vmware.com/api/vchs/sessions 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 the following items in the response: Response Header: x-vchs-authorization:vchs-auth-token <Session ...> <Link rel="down" type="application/xml;class=vnd.vmware.vchs.servicelist" href="https://vchs.vmware.com/api/vchs/services" /> </Session>
| ||||||
2 | From the Session response, use the value from the servicelist link and issue a GET request to retrieve the list of services: GET href="https://vchs.vmware.com/api/vchs/services" | ||||||
3 | In the request, include the vCloud Air authorization token: x-vchs-authorization:vchs-auth-token Include the x-vchs-authorization token in all subsequent API requests as a request header. The returned response includes the list of services subscribed for your vCloud Air account. Each Service element in the list has the following format: <Services ...> <Service region="xs:string" serviceId="xs:string" serviceType="compute:type" type="application/xml;class=vnd.vmware.vchs.compute" href="https://vchs.vmware.com/api/vchs/compute/compute-uuid" /> </Services> |
This example shows the two parts that are required for logging in to the Compute Service that you have subscribed to with vCloud Air. The first part of the example shows the request and response for HelloUser to log in to vCloud Air at the URL https://vchs.vmware.com/api/vchs/sessions In Request 1, the initial POST requires you enter the Authorization header with an encoded Base64 username:password value.
The second part shows the request and response for HelloUser to pass the authorization token to obtain the compute service list purchased for the user's company account. The service list contains one service for a Dedicated Cloud subscription.
POST https://vchs.vmware.com/api/vchs/sessions Authorization: Basic Vk13YXJlMTIzIQ== Accept: application/xml;version=5.6
201 Created Response Header: x-vchs-authorization:f1c687e31731cc9a5820d233e46ef1dfa131cb45 ... <Session type="application/xml;class=vnd.vmware.vchs.session" href="https://vchs.vmware.com/api/vchs/session" xmlns="http://www.vmware.com/vchs/v5.6" xmlns:tns=http://www.vmware.com/vchs/v5.6 xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance> <Link rel="down" type="application/xml;class=vnd.vmware.vchs.servicelist" href="https://vchs.vmware.com/api/vchs/services" /> <Link rel="remove" href="https://vchs.vmware.com/api/vchs/session" /> </Session>
GET https://vchs.vmware.com/api/vchs/services Authorization: x-vchs-authorization:f1c687e31731cc9a5820d233e46ef1dfa131cb45 Accept: application/xml;version=5.6
200 OK <Services type="application/xml;class=vnd.vmware.vchs.servicelist" href="https://vchs.vmware.com/api/vchs/services" ...> <Service region="US - Las Vegas" serviceId="example-1101-130711-1" serviceType="compute:dedicatedcloud" type="application/xml;class=vnd.vmware.vchs.compute" href="https://vchs.vmware.com/api/vchs/compute/vchs-2" /> </Services>