The HTTP-REST Plug-in allows for the interaction between vRealize Orchestrator (vRO) and REST hosts by defining services and their operations as inventory objects. When creating a workflow to remove the requirement to specify the REST:RESTHost type object as input parameter, I prefer to discover and return the type object by name this is particularly useful when executing a workflow to which the inventory object is determined by decision logic. The actual name of the inventory object in this example may be enumerated from a resource element or from a call to the configuration management database (CMDB).
The HTTP-REST plug-in exposes Javascript API classes related to REST object management and contains methods related to CRUD operations for REST hosts. In order to return a specified REST:RESTHost from the RESTHostManagerClass, the method ‘getHost(String):RESTHost’ allows for a REST:RESTHost to be returned from the plug-in’s inventory.
The following module action requires the name of the REST:RESTHost object specified as an input parameter. A collection of REST:RESTHost objects will be returned from the RESTHostManager class from the plugin’s inventory and return the REST:RESTHost type object from the associated object identifier as a string, a match will then be performed on the specified name from the input parameter and if true return the REST:RESTHost type.
The package which contains the module action and workflow item is available at https://github.com/dean1609/vRO/tree/master/com.deangrant.http.rest.
// Returns a collection of REST:RESTHost object types from the inventory service plugin | |
var getHosts = RESTHostManager.getHosts() | |
// Iterates the collection to return the REST:RESTHost object type and perform a match on the name attribute provided as an input parameter and returns the REST:RESTHost type if true. | |
for(var restHostId in getHosts){ | |
var restHost = RESTHostManager.getHost(getHosts[restHostId]) | |
if(restHost.name == name){ | |
return restHost | |
} // if(restHost.name == name) | |
} // var restHost = RESTHostManager.getHost(getHosts[restHostId]) |