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 VMware documentation.
Authorization
To log in and start using the API, find out the API version и get a token.
Request API version
- Execute the request:
curl 'https://vcd.selectel.ru/api/versions'
Current versions of the API have the attribute deprecated
takes on the value false
and the irrelevant ones have true
.
- 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>
— the user name 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>
— user password 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 field
X-VMWARE-VCLOUD-ACCESS-TOKEN
. When the key session expires, the token must be retrieved again; - organization identifier in the field
org:id
in the format ofurn:vcloud:org:<org_id>
where<org_id>
— organization identifier.
Examples of requests
A full description of the VMware Cloud Director API in 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 the token is received.
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 virtual machine;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 at requesting a 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 look at requesting a list of virtual machines in the fieldhref
;<version>
— API version;<token>
— token.
Exit the session
Deletes 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.