How to access VMware Cloud Director via the vCloud API

Overview

To perform some tasks in a CLOUD4Y environment, you may need to access VMware Cloud Director through the vCloud API. This guide demonstrates how to access the vCloud API.

Before you begin

Before using the vCloud API, we recommend that you install a REST client that allows you to access your VDC API. The steps described in this article use POSTMAN. You can also install the RESTClient plugin for Firefox or Chrome browser, the interface in this plugin is the same as Postman.

vCloud API credentials

Before using the vCloud API you need to have login credentials to your VDC in the CLOUD4Y portal. Usually you receive these credentials to the e-mail indicated at registration. These credentials are of the following form:

Username - the username for logging to your CLOUD4Y portal is backwards compatible with the API connectivity.

Organization ID - use this to uniquely identify vOrg when using the vCloud API.

Password - for authentication using the vCloud API. This password is the same as the one you use to log in to the CLOUD4Y portal.

Receiving the current version of the API

To start interacting with the vCloud API you need to configure and receive the current supported version of the server API.

  1. Run the API client
  2. Make a GET request to https://vcd.cloud4y.ru/api/versions
  3. In the Authorization panel select BasicAuth authentication type
  4. In the Username panel, enter your username and vORG name with @.
  5. In the Password panel, specify your vORG password in the cloud

If the request is successful you should receive a "Status: 200 OK" response from the server and the Body response panel will list all the API versions that are not supported (depricated <true>) and supported (depricated <false>) by the server.

In the next request sessions only those versions of the API that are in active status should be used.

 

Obtaining an authorization token

Now you need to get the x-vmware-vcloud-access-token; to do this follow these steps:

  1. Make a POST request to https://vcd.cloud4y.ru/api/sessions you received in the previous request
  2. In the Authorization panel, select BasicAuth authentication type
  3. In the Username panel enter your username and vORG's name with @.
  4. In the Password panel, specify your vORG password in the cloud
  5. In the HEADERS panel add Accept in the Key field and in the Value dialogue box enter application/*+xml;version=34.0

  1. After receiving a response from the server go to the Headers panel
  2. Here you can see several headers and authorization keys, the one we are interested in is the x-vcloud-authorization key. This is a momentary key that is only issued for a limited time. If a session with this key expires, the steps to get an authorization token must be performed again.

 

It is also possible to use the Authorization key for authorization, where you can specify the authorization method (Bearer in our example) and its key.

 

If you switch to the Body answer panel you can find the API URLs for accessing the various VDC components. We recommend saving this data in a separate file to simplify further interaction with the API

 

Authorization and retrieval vApp data within the VDC

After receiving the authorization token, the following steps are required:

  1. Specify GET request method
  2. Enter the address https://vcd.cloud4y.ru/api/query/?type=vApp
  3. In the HEADERS panel add the value x-vcloud-authorization in the "Key" field and in the "Value" dialog enter the key from the previous request

 

  1. In the Authorisation, panel disable authorization

  1. Send API request and receive all requested information.

 

Thus you know how to retrieve data from VDC via API request. In the same way you can manage this data, delete and create entities, configure EDGE Gateway, change vApp parameters. To fully master the Vcloud API we recommend you to refer to the official documentation.

 

Have you tried Cloud4Y's Cloud Hosting service? Not yet?

Send a request and get 10 days of free access

 

Смотреть подробности   
  • 8 Users Found This Useful
Was this answer helpful?

Related Articles

vCloud Director API for NSX. Programmers’ Guide

About vCloud Director API для NSX vCloud Director API для NSX. vCloud Director API for NSX is a...

Changing EDGE settings with the vCloud API

Introduction This tutorial shows how to receive, modify and send XML blocks, which represent the...

Changing Advanced Edge settings via API using PowerShell 7

In this article, we will take a look on some Advanced Edge Gateway actions available to the...

vCloud API programming guide for service providers

This release of vCloud API Programming Guide for Service Providers contains information on...