Using HTTP REST to Process or Review Requests via vRA/vRO

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/15/2020 at 05:10 PM

 

Category:
VMWare
VRo - VCAC

Retrieve Request Info for a Request Already Submitted:
- If you know your request ID, you can get past request runs details of what your submitted.

Documentation:
The api documentation for vCO:
myvrao.mindwatering.net:8281/vco/api/docs


Get Authentication Token:
Authenticate and get the authentication token for subsequent requests.
- To use JSON, add a custom header to the request:
Name: Accept
Value: application/json

$ curl --insecure -H "Accept: application/json" -H 'Content-Type: application/json' --data '{"username":"myadminid@vsphere.local","password":"myadminpassword","tenant":"vsphere.local"}' https://myvrao.mindwatering.net/identity/api/tokens

Notes:
- Update the admin id, the password, the tenant, and the name of your vRA server.
- The return will be in JSON, parse out the "id" value returned. We re-use the token until its expiration. Set it to a variable and a a prefix "Bearer ".
e.g.
export AUTHTOKEN = "Bearer ABCD1234...1234=="
- Use the token and add to the header of each response afterwords.


Get a workflow by name:
URL: myvrao.mindwatering.net:8281/vco/api/workflows/?conditions=name=worfklow%20name
Notes:
- In the above workflow, workflow name, the space was converted to %20.

- Add the authorization token:
Name: Authorization
Value: $AUTHTOKEN

- To use JSON, add a custom header to the request:
Name: Accept
Value: application/json

- The itemHref attribute contains the URL to retrieve (GET) the workflow executions. Locate the itemHref attribute:
...
{
"value": "https://myvrao.mindwatering.net:8281/vco/api/workflows/abc1234a-a123-b123-abcd-123654321abc",
"name" : "itemHref"
},
...

- We use the ID to view the past executions or to execute a new one. Locate the attribute: "id":
...
{
"value": "abc1234a-a123-b123-abcd-987654321abc",
"name" : "id"
},
...

- The parameters of the workflow are included within the JSON input-parameters array:
...
"input-parameters": [
{
"value": {
"string": {
"value": "fieldvalue"
}
},
...


Perform a GET request:
URL: myvrao.mindwatering.net:8281/vco/api/workflows/1234abcd...abcd123/executions/ff12345123a123123a1234a123456/
Note:
- Replace the workflow ID 1234abcd...abcd123 with a real request ID above.
- Replace the execution ID ff123...456 with a real execution/run ID.


Submit a New Workflow Run:
- Use the executions path.
e.g. myvrao.mindwatering.net:8281/vco/api/workflows/1234abcd...abcd123/executions/

- Reuse the JSON of the previous run's GET request.

- Change input-parameters to just parameters when doing a POST. Within the renamed parameters JSON array, re-use the same individual fields and values for the post.

- To send a SecureString parameter:
...
{
"name":"fldSecure",
"type":"SecureString",
"scope":"local",
"value":{ "string":{"value":"securetext"}
},
...

- To use JSON, add two custom headers to the request:
Name: Accept
Value: application/json

Name: Content-Type
Value: application/json


The response from the vCO server should be:
Status Code: 202 (Accepted)
Content-Length: 0
Date: <the current date in GMT>
Location: <the full URL of the post e.g. myvrao.mindwatering.net:8281/vco/api/workflows/1234abcd...abcd123/executions/ff54345123abc3123a1234a123123/ >


Get Run Status:
Use the workflow execution/run ID with a /state to GET the status of the run. So for the above POST, the corresponding status GET would be:
myvrao.mindwatering.net:8281/vco/api/workflows/1234abcd...abcd123/executions/ff54345123abc3123a1234a123123/state

Successful run:
Status: 200 (OK)
Body:
{"value":"completed"}

Failed run:
{"value":"failed"}

Running run:
{"value":"running"}

Waiting run:
{"value":"waiting"}

Cancelled run:
{"value":"canceled"}



previous page