Use the vRealize Automation REST API on vRealize Orchestrator
Overview
The vRealize Automation REST API can be used on vRealize Orchestrator directly with the vCACCAFE
plugin, instead of using the HTTP-REST
plugin, which can be much more simplier.
Get the vRA REST endpoint
If you have already used the vRealize Automation REST API, you should have noticed that there is around twenty endpoints !
On this article, we'll take the example of listing all the blueprints using vRO.
The REST API call to perform this operation is :
1https://vra-fqdn/composition-service/api/blueprints
Thereby the endpoint is composition service
.
Find the vCAC endpoint
Once the vRealize Automation REST endpoint defined, you need to find it on the vCAC plugin.
With your favorite REST client ( like Postman
), perform the following REST call on your vRealize Automation server after being authenticated :
https://vra-fqdn/component-registry/endpoints?$filter=endPointType/protocol eq 'REST'&limit=9999
It will collect all the vRealize Automation REST endpoints.
On the result, locate your endpoint and get the typeId
which is the endpoint name on the vCAC plugin.
In this case, the vCAC endpoint found is com.vmware.csp.core.cafe.catalog.requested.item.info.provider
for the composition-service
.
1 {
2 "@type": "EndPoint",
3 "id": "ed42c762-1487-458a-bc33-b7efc285b426",
4 "createdDate": null,
5 "lastUpdated": null,
6 "url": "https://my-vra-server/composition-service/api",
7 "endPointType": {
8 "typeId": "com.vmware.csp.core.cafe.catalog.requested.item.info.provider",
9 "protocol": "REST"
10 },
11 "serviceInfoId": "b7d3fdea-4808-45d8-af95-cf3aac0c8259",
12 "endPointAttributes": null,
13 "sslTrusts": null
14 },
Great ! The vCAC endpoint now found, you can use it directly on vRO.
Using the vRA REST API on vRO
On vRealize Orchestrator, you can create a rest client with the vCACCAFEHost object and its method createRestClient() with the vCAC endpoint on the parameter.
You will be able to do some basic REST operations like GET, POST and PUT.
Here is the code to list all the blueprints defined on a vRA tenant :
1/*
2 * List all the blueprints defined on a tenant
3 *
4 * @param {vCACCAFEHost} host Targeted vCACAFE Host Tenant.
5 *
6*/
7
8//Create the rest client for the targeted tenant
9restClient = host.createRestClient("com.vmware.csp.core.cafe.catalog.requested.item.info.provider");
10
11//List all the blueprints defined on the tenant
12blueprints = restClient.get("/blueprints").getBodyAsJson();
13
14//Display the name for each blueprint found
15for each(var blueprint in blueprints){
16 System.log("Blueprint found : "+blueprint.name);
17}