5.1

Table Of Contents
Define an Action for a Resource Class
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.
Prerequisites
Verify that you are logged in to the vCloud API as a system administrator.
Procedure
1 Retrieve the XML representation of the service.
Use a request like this one:
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.
See the request portion of “Example: Define an Action for a Resource Class,” on page 297 for information
about the contents of this element.
4 POST the ResourceClassAction element to the URL described in Step 2.
Example: Define an Action for a Resource Class
This request specifies a GET action for a URL matching the pattern could expand to a URL like
https://vcloud.example.com/backup/27.
Request:
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/(?&lt;id&gt;[-,a-g,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 via the action.
Response:
201 Created
Content-Type: application/vnd.vmware.admin.resourceClassAction+xml
...
<vmext:ResourceClassAction
xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5"
Chapter 11 vCloud Director Extension Services
VMware, Inc. 297