You can use the REST API catalog service to log in to vRealize Automation and view information about provisioned resources .

Vorbereitungen

Anmerkung:

The vRealize Automation REST API does not support custom resource actions template API calls. However, you can perform custom resource actions programmatically by using the vRealize Automation Cloud Client.

  • Log in to vRealize Automation as a business group manager.

  • Verify that the host name and fully qualified domain name of the vRealize Automation instance are available.

  • Verify that you have a valid HTTP bearer token that matches your login credentials. See REST API Authentication.

  • Obtain the business group subtenant ID values to specify on the command line. See Syntax for Getting Deployment Details.

Prozedur

  1. Display a list of all provisioned resources.
    $curl --insecure -s
    			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token"
    			 http://
    			 $host/catalog-service/api/consumer/requests/7aaf9baf-aa4e-47c4-997b-edd7c7983a5b/resourceViews

    The output from this command includes HATEOAS links that enable you to quickly obtain additional information about specific deployed resources.

  2. Use the GET: Child Resources HATEOAS link to retrieve a list of child nodes of a deployment.
    $curl --insecure -s
    			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token"
    			 https:// $host
    			 /catalog-service/api/consumer/resourceViews?managedOnly=false&withExtendedData=true&withOperations=true&%24filter=parentResource%20eq%20%27c4d3db3e-e397-44ff-a1c9-0ecebdba12f4%27
  3. In addition, you can use the HATEOAS links to complete day 2 actions.
    • You can use a command like the following to get the template for the resource action request and use it to power off a machine.

      $curl --insecure -s
      			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token"
      			 https://$host/catalog-service/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/02bad06d-f92b-4cf8-b964-37bb5d57be38/requests/template

      Then POST the unmodified template to the corresponding URI.

      $curl --insecure -s
      			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token"https://$host/catalog-service/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/02bad06d-f92b-4cf8-b964-37bb5d57be38/requests 
      {
        "type": "com.vmware.vcac.catalog.domain.request.CatalogResourceRequest",
        "resourceId": "dd37b7a1-829c-4773-b5be-b229453eca4a",
        "actionId": "02bad06d-f92b-4cf8-b964-37bb5d57be38",
        "description": null,
        "data": {
          "description": null,
          "reasons": null
        }
      }
    • You can modify the HATEOAS links to complete more complex day 2 actions that require user input, such as changing a lease. Use a command like the following to get the template for the resource action request.

      $curl --insecure -s
      			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token" https://$host/catalog-service/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/b5739e30-871d-48c7-9012-f2a7cf431dc1/requests/template

      After you edit the template as desired, you can POST it to the corresponding URI.

      HTTP/1.1 200 OK   
      Server: Apache-Coyote/1.1   
      Cache-Control: no-cache, no-store   
      Pragma: no-cache   
      Expires: Sat, 01 August 2015 23:04:50 GMT
      Content-Type: application/json;charset=UTF-8   
      Date: Sat, 01 August 2015 13:04:50 GMT
      {
        "type": "com.vmware.vcac.catalog.domain.request.CatalogResourceRequest",
        "resourceId": "dd37b7a1-829c-4773-b5be-b229453eca4a",
        "actionId": "b5739e30-871d-48c7-9012-f2a7cf431dc1",
        "description": null,
        "data": {
          "provider-ExpirationDate": "2015-07-29T16:44:13.846Z"
        }
      }