In vRealize Automation 8.x , you can use REST queries to substitute the scripting objects included in the vRealize Automation 7.x plug-in, which can be used to construct, access, and document all program-based objects.

The equivalent of these objects at the REST level is documented in the Models section in Swagger. The Swagger models include JSON examples for object properties that can be included in a vRealize Orchestrator action. The Swagger documentation is essential for understanding the properties of the objects returned by REST queries and constructing objects to pass as the body of PUT, POST, PATCH requests.

The following example, createZone, is used to create a zone:

if (vraHost == null || regionId == null || name == null) return null; 

var customPropertiesObject = 
System.getModule("com.vmware.vra.extensibility.plugin.rest.iaas").propertiesToCustomPrope
rtiesObject(customProperties); 
var tagsObject = 
System.getModule("com.vmware.vra.extensibility.plugin.rest.iaas").propertiesToTagsObject(ta
gs); 
var tagsToMatchObject = 
System.getModule("com.vmware.vra.extensibility.plugin.rest.iaas").propertiesToTagsObject(ta
gsToMatch); 

var url = "/iaas/api/zones" 
var zone = 
{ 
  "customProperties": customPropertiesObject, 
  "folder": folder, 
  "regionId": regionId, 
  "tagsToMatch": tagsToMatchObject, 
  "name": name, 
  "description": description, 
  "placementPolicy": placementPolicy, 
  "tags": tagsObject 
} 

var content = JSON.stringify(zone); 
var operation = "POST"; 

try { 

    var contentAsString = 
System.getModule("com.vmware.vra.extensibility.plugin.rest").invokeRestOperation(vraHost, 
operation, url, content); 
    var object = JSON.parse(contentAsString); 
  return object.id; 
    } catch (e) { 
         throw "POST " + url + "Failed" + 
    \n Error : " + e; 
}

The vRealize Automation plug-in included in 7.x also includes "singleton" objects that provide a global access point to properties (Enumerations : constants) and methods. The methods provide special functionalities. For example, methods to find objects by their properties. The latest version of the vRealize Orchestrator plug-in for vRealize Automation includes a special singleton object called VraEntitiesFinder including methods to get plug-in objects for a specific vRealize Automation host by type or by ID. These methods also support providing a string- based filter similar to the filters used by the vRealize Automation UI and documented in vRA API documentations.

For cases where vRAEntitiesFinder does not support the search you are looking for, it is possible to provide equivalent functionality through actions using REST queries The following example includes code from the sample action getNetworksByTagsQS that can be used to find networks.

if (vraHost == null) return null; 

var tagsFilters = new Array(); 
for each (var tag in tags) { 
  tagsFilters.push(getTagFilter(tag)); 
} 

// Query service parameter 
var tagsFilter = tagsFilters.join(" and "); 
if (tags.length == 0) var parameters = "expand"; 
else var parameters = "expand&$filter=" + encodeURIComponent(tagsFilter).replace("'",
"%27"); 

var url = "/iaas/api/fabric-networks"; 
return 
System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectsProperty(vraHost, 
url, parameters, "name"); 

function getTagFilter(tag) { 
  tag = tag.replace(":","*"); 
  return "(expandedTags.item.tag eq '*" + tag + "*'))" 
}