VMware Cloud Director API
VMware Cloud Director API allows you to interact with VMware Cloud Director via a REST client.
You can view a description of all VMware Cloud Director API methods 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; - St. Petersburg:
vcd.selectel.ru.
For current API versions, the
deprecatedparameter value will befalse, and for outdated 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 details, see the guide Managing virtual data center users;<tenant>— the tenant; you can find it in the Cloud Director login URL, for example:https://<url>/tenant/<tenant>;<password>— the virtual data center user password.
-
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>— the API version; -
<encoded_string>— the string obtained in step 1; -
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru.
- Moscow:
-
-
Save:
- the token from the
X-VMWARE-VCLOUD-ACCESS-TOKENfield. When the session with the key expires, you will need to get a new token; - the organization ID from the
org:idfield. This field contains data in theurn:vcloud:org:<org_id>format, where<org_id>is the organization identifier.
- the token from the
Request examples
Full description of the VMware Cloud Director API can be found 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>— the API version; -
<token>— the token; -
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<org_id>— the organization identifier you saved when getting the 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>— the API version; -
<token>— the token; -
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. 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> — the address depending on the region:
- Moscow:
vcd-msk.selectel.ru; - St. 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 the defaulthrefattributes);filter=isVAppTemplate==false— returns 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>— the API version; -
<token>— the token; -
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>— the virtual machine identifier; you can find it 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>— the API version; -
<token>— the token; -
<url>— the address depending on the region:- Moscow:
vcd-msk.selectel.ru; - St. Petersburg:
vcd.selectel.ru;
- Moscow:
-
<vm_id>— the virtual machine identifier; you can find it 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: