An organization administrator can create a role by aggregating a set of rights in a Role element and POSTing it to the organization's add URL for roles.

Verify that you are logged in to the vCloud API as an organization administrator or system administrator.

1

Create a Role element that defines the role with a name and a set of rights.

To get the RightReference objects you will need to populate the Role, retrieve the administrative view of the cloud, using a request like this one:

GET https://vcloud.example.com/api/admin
2

POST the Role element to the organization's add URL for roles.

See the request portion of Example: Create a Role.

The server creates a Role element and returns its representation to the client.

This example adds a role named vAppWrangler to the organization created in Example: Create an Organization. The response is a Role element, most of which does not appear in the example. The response includes links that an administrator can use to edit or remove the role.

Request:

POST https://vcloud.example.com/api/admin/roles
Content-Type: application/vnd.vmware.admin.role+xml
...
<?xml version="1.0" encoding="UTF-8"?>
<Role name="vAppWrangler" xmlns="http://www.vmware.com/vcloud/v1.5">
   <Description>Create and manage vApps</Description>
   <RightReferences>
      <RightReference
          type="application/vnd.vmware.admin.right+xml"
          name="vApp: View"
          href="https://vcloud.example.com/api/admin/right/16"/>
      <RightReference
         type="application/vnd.vmware.admin.right+xml"
         name="vApp: Power Operations"
         href="https://vcloud.example.com/api/admin/right/9"/>
      <RightReference
         type="application/vnd.vmware.admin.right+xml"
         name="vApp: Download"
         href="https://vcloud.example.com/api/admin/right/11"/>
    </RightReferences>
</Role>

Response:

201 Created
Content-Type: application/vnd.vmware.admin.role+xml
...
<Role
   name="vAppWrangler"
   id="urn:vcloud:role:102"
   xmlns="http://www.vmware.com/vcloud/v1.5"
   href="https://vcloud.example.com/api/admin/role/102" ...>
   <Link
      rel="edit"
      type="application/vnd.vmware.admin.role+xml"
      href="https://vcloud.example.com/api/admin/role/102"/>
   <Link
      rel="remove"
      href="https://vcloud.example.com/api/admin/role/102"/>
   <Description>Create and manage vApps</Description>
   <RightReferences>
      ...
   </RightReferences>
</Role>