VMware Cloud Director API
VMware Cloud Director API allows you to interact with VMware Cloud Director via a REST client.
A description of all VMware Cloud Director API methods can be found in the VMware documentation.
Authorization
To authorize and start using the API:
1. Request the API version
-
Get a list of API versions:
curl 'https://<url>/api/versions'Specify
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru.
For current API versions, the
deprecatedparameter value will befalse, and for obsolete ones —true. - Moscow:
-
Select any current API version. The request examples use version 36.3.
2. Get a token
-
Using any tool to convert strings from text format to MIME Base64, convert the following string to MIME Base64 format:
<username>@<tenant>:<password>Specify:
<username>— the virtual data center username. For more information, see the Manage virtual data center users instruction;<tenant>— tenant, can be found in the Cloud Director login URL formatted ashttps://<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>— the string obtained in step 1; -
<url>— address depending on the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru.
- Moscow:
-
-
Save:
- token from the
X-VMWARE-VCLOUD-ACCESS-TOKENfield. When the key session expires, you will need to get the token again; - organization ID from the
org:idfield. The field contains data in the formaturn:vcloud:org:<org_id>, where<org_id>is the organization ID.
- token from the
Request examples
Full description of the VMware Cloud Director API in the VMware documentation.
Request organization objects
Returns all available organization objects (virtual data centers, catalogs, tasks, quotas, groups, metadata, and organization networks), as well as a link for organization administration.
Request example:
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 the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru;
- Moscow:
-
<org_id>— organization ID that you saved when getting a token.
Request virtual data center objects
Returns a list of virtual data center objects.
Request example:
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 the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru.
- Moscow:
Request a list of virtual machines
Returns a list of virtual machines.
Request example:
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; - Saint Petersburg:
vcd.selectel.ru.
Request parameters:
type=vm— requests objects of the virtual machine type;fields=name,containerName— for each virtual machine shows only thenameandcontainerNameattributes (and by default thehrefattributes);filter=isVAppTemplate==false— displays only deployed virtual machines without vApp templates.
Turn on a virtual machine
Turns on the specified virtual machine.
Request example:
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 the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>— virtual machine ID, can be found when requesting a list of virtual machines in thehreffield.
Turn off a virtual machine
Turns off the specified virtual machine.
Request example:
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 the region:- Moscow:
vcd-msk.selectel.ru; - Saint Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>— virtual machine ID, can be found when requesting a list of virtual machines in thehreffield.
Sign out of the session
Deletes the current session.
Request example:
curl -i -XDELETE \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/cloudapi/1.0.0/sessions/'
Specify: