top of page
Brock Peterson

vROps Cloud APIs

APIs are a powerful way to interact programmatically with products, such as vROps Cloud, which has a rich set of APIs and detailed Swagger-based documentation. Looking around for documentation, I found a blog from VMware Staff Cloud Solutions Architect Cosmin Trif, but I wanted a bit more, here's what I came up with.


First, log into your VMware Cloud Services portal.



Select your name top right, then click MY Account.



Generate an API Token first which you will then exchange for an API Authentication Token. This will allow you to interact securely with the vROps Cloud API. Click GENERATE TOKEN.



Give it a name, adjust the Token TTL as you wish, select the desired Roles and the other options you might want, then click GENERATE.



You now have your API Token which you can exchange for an API Authentication Token. Once done click CONTINUE.


Back on your API Tokens tab, click the ? bubble, it'll tell you how to exchange your API Token for an API Authentication Token.



There are several different ways to interact with the vROps Cloud API, the two most popular are via REST Clients: cURL and Postman. Documentation on each can be found here. cURL is is on my vROps master node, so I'm going to run commands from there.


To exchange the API Token for an API Authentication Token, run this command:

curl --location --request POST 'https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'refresh_token=your_api_token_goes_here'

This will return a JSON string in the following format, documentation can be found here.

{
"id_token",
"token_type",
"expires_in",
"scope",
"access_token",
"refresh_token”          
}

Now that we have our API Authentication Token, let's explore the endpoints and data available to us via the API. API documentation is available via the URL of your vROps Cloud instance. For example, if the URL of your instance is https://www.mgmt.cloud.vmware.com, the API reference is available from: https://www.mgmt.cloud.vmware.com/vrops-cloud/suite-api/doc/swagger-ui.html. Mine looks something like this:



The Swagger-based documentation for the vROps Cloud API is quite robust, with examples, Try it out features, and more. Let's run a couple cURL commands, we'll get started by showing all the adapters we are running:

curl -X GET https://www.mgmt.cloud.vmware.com/vrops-cloud/suite-api/api/adapters -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: CSPToken access_token_goes_here"

You'll get a JSON string like this:



Maybe we'd like to determine the current user:

curl -X GET https://www.mgmt.cloud.vmware.com/vrops-cloud/suite-api/api/auth/currentuser -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: CSPToken access_token_goes_here"

You'll get a JSON string like this:


There are more than 25 vROps Cloud API endpoints available, with GET, POST, PUT, PATCH, DELETE, and other available methods. If you're just getting started with APIs, here's a great video on Postman. VMware {code} is another great resource for Postman collections as well.





1,793 views

Commentaires


bottom of page