Created
September 13, 2019 00:43
-
-
Save trisharia/68fb0bccace7acbc5d88fd7609c13796 to your computer and use it in GitHub Desktop.
Add vRA/vRA Cloud Catalog Source to Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// | |
// Add a vRA/vRA Cloud catalog source to a given project | |
// 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 | |
// projectId - string - Id of the project | |
// catSourceId - string - Id of the catalog source | |
// | |
// Return type: void | |
const opMethod = "POST"; | |
const opUrl = "/catalog/api/admin/entitlements"; | |
const contentType = "application/json"; | |
const urlParamValues =""; | |
var headers = new Properties(); | |
headers.put("Authorization", "Bearer " + authToken); | |
var contentJson = addCatSrcItmPayload = { | |
"projectId": projectId, | |
"definition": { | |
"type": "CatalogSourceIdentifier", | |
"sourceType": "com.vmw.blueprint", | |
"id": catSourceId | |
} | |
}; | |
var content = JSON.stringify(contentJson); | |
var createOpResponse = System.getModule("com.vmware.pso.rest").executeTransientRESTOperation( | |
cspBaseUrl,null,null,opMethod,opUrl,urlParamValues,headers,contentType,content); | |
if (createOpResponse.statusCode >= 400) { | |
throw "Failed to add/update catalog source items to project (" + createOpResponse.statusCode + " Error). Details: " + createOpResponse.responseString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment