Skip to content

Instantly share code, notes, and snippets.

@trisharia
Created September 13, 2019 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trisharia/023775442e3daf720898bc1ab22dffc4 to your computer and use it in GitHub Desktop.
Save trisharia/023775442e3daf720898bc1ab22dffc4 to your computer and use it in GitHub Desktop.
Get all vRA/vRA Cloud Cloud Zone by ID
// VMware vRealize Orchestrator action sample
//
// Get vRA/vRA Cloud cloud zone details in JSON format, given its ID
// Assumes the presence of action System.getModule("com.vmware.pso.rest").executeTransientRESTOperation
// Obtain the action here: https://gist.github.com/trisharia/7b62fcdf12600511b3d7e9b635981b2c
//
// For vRA Cloud 7.0+ and vRA 8.0+
//
// Action Inputs:
// cspBaseUrl - string - Base URL for connecting to VMware Cloud Services RESTful API
// e.g., https://api.mgmt.cloud.vmware.com
// cspAuthToken - string - VMware Cloud Services bearer token
// Get this token by running the following action first: https://gist.github.com/trisharia/4262427728b9ca2f22f76c39a5521768
// id - string - ID of the cloud zone
//
// Return type: Any - JSON object of vRA/vRA Cloud cloud zone details
const opMethod = "GET";
const opUrl = "/iaas/zones/{0}";
var headers = new Properties();
headers.put("Authorization", "Bearer " + cspAuthToken);
var urlParamValues = [id];
var opResponse = System.getModule("com.vmware.pso.rest").executeTransientRESTOperation(
cspBaseUrl,null,null,opMethod,opUrl,urlParamValues,headers,null,null);
if (opResponse.statusCode >= 400) {
throw "Failed to get zone (" + opResponse.statusCode + " Error). Details: " + opResponse.responseString;
}
var responseJson = JSON.parse(opResponse.responseString);
return responseJson;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment