Representational State Transfer (REST) is a is a software architectural style that describes a uniform interface for numerous software packages and hardware systems in IT environments. The most common protocol for these requests and responses is HTTP, which provides operations (HTTP methods) such as OPTIONS, GET, POST, PUT, PATCH and DELETE.
The OpenAPI Specification (OAS), previously known as the Swagger Specification, is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful web services.
Applications implemented based on OpenAPI interface files can automatically generate documentation of methods, parameters and models. This helps keep the documentation, client libraries, and source code in sync.
Examples of VMware products providing Swagger Specifications are vRealize Automation (vRA) and vRealize Operations (vROps).
To call REST operations from within vRealize Orchestrator (vRO), we can use the HTTP-REST plugin, which allows us to manage REST Web services by providing interaction between vRO and REST hosts. We can define REST services and their operations as inventory objects by running configuration workflows, and perform REST operations on the defined objects. The plug-in contains a set of standard workflows related to managing REST hosts and invoking REST operations.
Compared to a manually created REST Host, a Swagger REST Host comes with configured operations which reduces the risk of misconfiguration when manually adding every operation.
In this article, we’ll cover the creation of a vROps REST host from a Swagger endpoint inside the vRA embedded vRO.
First, we must identify the Swagger specification URL for the public APIs of vROps:
- In a web browser navigate to the vROps API documentation, e.g. https://vrops1a.lab.local/suite-api/doc/swagger-ui.html#/.
- There select the OpenAPI Specification(OAS) v2 entry from the Related Files dropdown menu.
- It will open the spec file in a new browser tab at https://vrops1a.lab.local/suite-api/doc/v2/api-docs?group=Public%20APIs
Second, we will create a REST host from this specification URL:
- In vRO, navigate to Library > Workflows and enter the “swagger” in the workflow search box.
- Locate the Add a REST host by Swaggers spec from a URL workflow and click Run.
- Define the properties to create a new host. Enter the vROps Swagger Spec URL as noted above.
- Leave the access credentials empty on the Spec Authentication tab.
- Select Basic as the Authentication type.
- Provide the user name and password for shared session mode.
- Deselect the SSL certificate verification for the target host.
- Click Run.
The workflow should successfully complete as depicted below.
Now it’s time to verify the REST host along with the automatically configured REST operations.
- In vRO, navigate to Administration > Inventory and expand HTTP-REST.
- Select the host, we’ve created above and expand it. You can verify the configured host details along with the created REST operations.
Now we can perform actions on this REST host.
Leave a Reply