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 the VMware Cloud Director API methods, see the VMware documentation.
Authorization
To authorize and start using the API, find out the API version and get a token.
Request API version
- Execute the request:
curl 'https://vcd.selectel.ru/api/versions'
The deprecated
attribute is false
for current versions of the API, and true for
deprecated
versions.
- Select any current API version from the list. The example requests use version 36.3.
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 to access Cloud Director;<tenant>
— tenant, you can look in the URL to log in to Cloud Director:https://vcd.selectel.ru/tenant/<tenant>
<password>
— password for the user to access Cloud Director.
- Request a token:
curl -i -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Basic <encoded_string>' \
'https://vcd.selectel.ru/cloudapi/1.0.0/sessions/'
Specify:
<version>
— API version;<encoded_string>
— string obtained in step 1.
- Check it out:
- token in the
X-VMWARE-VCLOUD-ACCESS-TOKEN
field. When the key session expires, the token must be retrieved again; - organization identifier in the
org:id
field in the format urn:vcloud:org:<org_id>
, where<org_id>
is the organization identifier.
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://vcd.selectel.ru/api/org/<org_id>'
Specify:
<version>
— API version;<token>
— token;<org_id>
— organization identifier received when receiving 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://vcd.selectel.ru/api/query?type=orgVdc'
Specify:
<version>
— API version;<token>
— token.
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://vcd.selectel.ru/api/query?type=vm&fields=name,containerName&filter=isVAppTemplate==false'
Request Parameters:
type=vm
— Requests objects of type virtualmachine;fields=name,containerName
— for each virtual machine shows only the attributesname
иcontainerName
(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://vcd.selectel.ru/api/vApp/vm-<vm_id>/power/action/powerOn'
Specify:
<vm_id>
— virtual machine identifier, can be viewed when querying the list of virtual machines in the fieldhref
;<version>
— API version;<token>
— token.
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://vcd.selectel.ru/api/vApp/vm-<vm_id>/power/action/powerOff'
Specify:
<vm_id>
— virtual machine identifier, can view when querying the list of virtual machines in the fieldhref
;<version>
— API version;<token>
— token.
Quit the session
Will delete the current session.
Example of a request:
curl -i -XDELETE \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://vcd.selectel.ru/cloudapi/1.0.0/sessions/'
Specify:
<version>
— API version;<token>
— token.