After you define a resource class, you can specify the actions that are permitted on resources of that class.
A ResourceClassAction object defines an HTTP method that is allowed on a specific UrlPattern. The UrlPattern can be any of the following URL forms:
1 | Retrieve the XML representation of the service. GET https://vcloud.example.com/api/admin/extension/service/45 |
2 | Examine the response to find the Link for specifying resource class actions. This Link has the following form: <vcloud:Link rel="add" type="application/vnd.vmware.admin.resourceClassAction+xml" href="https://vcloud.example.com/api/admin/extension/service/45/resourceclassactions" /> |
3 | Construct a ResourceClassAction element. For information about the contents of this element, see the request portion of Example: Define an Action for a Resource Class. |
4 | POST the ResourceClassAction element to the URL described in Step 2. |
This example defines a resource class action for a GET request to a UrlPattern that could match URLs including https://vcloud.example.com/api/backup/27 or https://vcloud.example.com/api/backup/vm-27-backup-2013-04-25T01:17:00.000Z.
POST https://vcloud.example.com/api/admin/extension/service/45/resourceclassactions Content-type:application/vnd.vmware.admin.resourceClassAction+xml <?xml version="1.0" encoding="UTF-8"?> <vmext:ResourceClassAction xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" name="Read backups"> <vmext:HttpMethod>GET</vmext:HttpMethod> <vmext:UrlPattern>/api/backup/[-,a-z,0-9]*)</vmext:UrlPattern> </vmext:ResourceClassAction>
The response is a ResourceClassAction element that includes information derived from the contents you POSTed , along with a set of Link elements that you can use to remove the ResourceClassAction or add ACL rules that control access to the resource class through the action.
201 Created Content-Type: application/vnd.vmware.admin.resourceClassAction+xml ... <vmext:ResourceClassAction xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" name="Read backups" id="urn:vcloud:resourceClassAction:268" type="application/vnd.vmware.admin.resourceClassAction+xml" href="https://vcloud.example.com/api/admin/extension/service/resourceclassaction/268" ... > <vcloud:Link rel="remove" href="https://vcloud.example.com/api/admin/extension/service/resourceclassaction/268" /> <vcloud:Link rel="up" type="application/vnd.vmware.admin.resourceClass+xml" href="https://vcloud.example.com/api/admin/extension/service/resourceclass/83" /> <vcloud:Link rel="down:aclRules" type="application/vnd.vmware.vcloud.query.records+xml" href="https://vcloud.example.com/api/admin/extension/service/resourceclassaction/268/aclrules" /> <vmext:HttpMethod>GET</vmext:HttpMethod> <vmext:UrlPattern>/api/backup/[-,a-g,0-9]*)</vmext:UrlPattern> </vmext:ResourceClassAction>