VMware Cloud Director API
The VMware Cloud Director API allows you to interact with VMware Cloud Director through a REST client.
For a description of all VMware Cloud Director API methods, see the VMware documentation.
Authorization
To log in and start using the API:
1. Request API version
-
Print the list of API versions:
curl 'https://<url>/api/versions'Specify
<url>- address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru.
For current versions of the API, the
deprecatedparameter will befalse, for non-updated versions it will betrue. - Moscow:
-
Select any current version of the API. The example requests use version 36.3.
2. Get a token
-
Use any string translation tool to translate a string from text format to MIME Base64 format:
<username>@<tenant>:<password>Specify:
<username>- username of the virtual data center. See the instructions for details Manage users of the virtual data center;<tenant>- tenant, you can look in the URL to log in to Cloud Director of the formhttps://<url>/tenant/<tenant>;<password>- password of the virtual data center user.
-
Request a token:
curl -i -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Basic <encoded_string>' \
'https://<url>/cloudapi/1.0.0/sessions/'Specify:
-
<version>- API version; -
<encoded_string>- string obtained in step 1; -
<url>- address depending on region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru.
- Moscow:
-
-
Save it:
- token from the
X-VMWARE-VCLOUD-ACCESS-TOKENfield. When the key session expires, the token must be retrieved again; - organization identifier from the
org:idfield. The field contains data in urn:vcloud:orgformat:<org_id>, where<org_id>is the organization identifier.
- token from the
Examples of requests
For a full description of the VMware Cloud Director API, see the VMware documentation.
Request organization objects
Outputs all available organization objects (virtual data centers, directories, directories, tasks, quotas, groups, metadata, and organization networks), as well as a link to administer the organization.
Example of a request:
curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/org/<org_id>'
Specify:
-
<version>- API version; -
<token>- token; -
<url>- address depending on region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<org_id>- the organization identifier that you saved when when you received the token.
Request virtual data center objects
Returns a list of virtual data center objects.
Example of a request:
curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/query?type=orgVdc'
Specify:
-
<version>- API version; -
<token>- token; -
<url>- address depending on region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru.
- Moscow:
Request a list of virtual machines
Returns a list of virtual machines.
Example of a request:
curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/query?type=vm&fields=name,containerName&filter=isVAppTemplate==false'
Specify <url> - address depending on the region:
- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru.
Request Parameters:
type=vm- Requests objects of type virtualmachine;fields=name,containerName- for each virtual machine shows only the attributesnameandcontainerName(and by default the attributeshref);filter=isVAppTemplate==false- outputs only deployed virtual machines without vApp templates.
Turn on the virtual machine
Enables the specified virtual machine.
Example of a request:
curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/vApp/vm-<vm_id>/power/action/powerOn'
Specify:
-
<version>- API version; -
<token>- token; -
<url>- address depending on region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>- virtual machine identifier, can be viewed when querying the list of virtual machines in thehref.
Shut down the virtual machine
Shuts down the specified virtual machine.
Example of a request:
curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/vApp/vm-<vm_id>/power/action/powerOff'
Specify:
-
<version>- API version; -
<token>- token; -
<url>- address depending on region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>- virtual machine identifier, can be viewed when querying the list of virtual machines in thehref.
Quit the session
Deletes the current session.
Example of a request:
curl -i -XDELETE \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/cloudapi/1.0.0/sessions/'
Specify: