Overview
To perform some tasks in a CLOUD4Y environment, you may need to access VMware Cloud Director through the vCloud API. This guide demonstrates how to access the vCloud API.
Before you begin
Before using the vCloud API, we recommend that you install a REST client that allows you to access your VDC API. The steps described in this article use POSTMAN. You can also install the RESTClient plugin for Firefox or Chrome browser, the interface in this plugin is the same as Postman.
vCloud API credentials
Before using the vCloud API you need to have login credentials to your VDC in the CLOUD4Y portal. Usually you receive these credentials to the e-mail indicated at registration. These credentials are of the following form:
Username - the username for logging to your CLOUD4Y portal is backwards compatible with the API connectivity.
Organization ID - use this to uniquely identify vOrg when using the vCloud API.
Password - for authentication using the vCloud API. This password is the same as the one you use to log in to the CLOUD4Y portal.
Receiving the current version of the API
To start interacting with the vCloud API you need to configure and receive the current supported version of the server API.
- Run the API client
- Make a GET request to https://vcd.cloud4y.ru/api/versions
- In the Authorization panel select BasicAuth authentication type
- In the Username panel, enter your username and vORG name with @.
- In the Password panel, specify your vORG password in the cloud
If the request is successful you should receive a "Status: 200 OK" response from the server and the Body response panel will list all the API versions that are not supported (depricated <true>) and supported (depricated <false>) by the server.
In the next request sessions only those versions of the API that are in active status should be used.
Obtaining an authorization token
Now you need to get the x-vmware-vcloud-access-token; to do this follow these steps:
- Make a POST request to https://vcd.cloud4y.ru/api/sessions you received in the previous request
- In the Authorization panel, select BasicAuth authentication type
- In the Username panel enter your username and vORG's name with @.
- In the Password panel, specify your vORG password in the cloud
- In the HEADERS panel add Accept in the Key field and in the Value dialogue box enter application/*+xml;version=34.0
- After receiving a response from the server go to the Headers panel
- Here you can see several headers and authorization keys, the one we are interested in is the x-vcloud-authorization key. This is a momentary key that is only issued for a limited time. If a session with this key expires, the steps to get an authorization token must be performed again.
It is also possible to use the Authorization key for authorization, where you can specify the authorization method (Bearer in our example) and its key.
If you switch to the Body answer panel you can find the API URLs for accessing the various VDC components. We recommend saving this data in a separate file to simplify further interaction with the API
Authorization and retrieval vApp data within the VDC
After receiving the authorization token, the following steps are required:
- Specify GET request method
- Enter the address https://vcd.cloud4y.ru/api/query/?type=vApp
- In the HEADERS panel add the value x-vcloud-authorization in the "Key" field and in the "Value" dialog enter the key from the previous request
- In the Authorisation, panel disable authorization
- Send API request and receive all requested information.
Thus you know how to retrieve data from VDC via API request. In the same way you can manage this data, delete and create entities, configure EDGE Gateway, change vApp parameters. To fully master the Vcloud API we recommend you to refer to the official documentation.