You can use the REST API catalog service to perform a power off action. For simple actions that require no user input, the process is straightforward.
About this task
This command leverages the links for the power off action from the command used in the Syntax for Navigating to the Children of a Deployed Resource example.
{
"@type": "link",
"rel": "GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.PowerOff}",
"href": "https://$host/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/02bad06d-f92b-4cf8-b964-37bb5d57be38/requests/template"
},
{
"@type": "link",
"rel": "POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.PowerOff}",
"href": "https://$host/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/02bad06d-f92b-4cf8-b964-37bb5d57be38/requests"
}
Procedure
- 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/02bad06d-f92b-4cf8-b964-37bb5d57be38/requests/template
This example command returns a response.
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": "02bad06d-f92b-4cf8-b964-37bb5d57be38",
"description": null,
"data": {
"description": null,
"reasons": null
}
}
- Use a POST command to send the template without modification 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
}
}
Results
This POST command returns a response indicating success or failure, such as HTTP/1.1 201 CREATED
for success.