Share via


Create (POST) a UserRole [SPFSDK][VMMREF]

 

Applies To: Windows Azure Pack

Create a UserRole [SPFSDK][VMMREF] entity by using the HTTP POST operation.

Here is a list of examples related to this collection operation.

  • Example: Create a new UserRole

Request

For more information about the placeholders used in the URI, see URL placeholders.

Method

Request URI

HTTP Version

POST

https://{server-name}:{auth-port}/{subscription-id}/services/systemcenter/vmm/UserRoles

HTTP/1.1

Request URI Parameters

This operation does not have any request URI parameters.

Request Headers

This operation does not use any non-standard request headers.

For more information about the common request headers used by this operation, see Common HTTP request information.

Request Body

The request body should contain a single (depending on the request headers) XML or JSON encoded UserRole [SPFSDK][VMMREF] entity that you want to create. Here is the request body of a single entity.

{
  "odata.type": "VMM.UserRole",
  "AddCloudResourceExtension@odata.type": "Collection(VMM.UserRoleCloudResourceExtension)",
  "AddCloudResourceExtension": [],
  "AddMember@odata.type": "Collection(Edm.String)",
  "AddMember": [],
  "AddResource@odata.type": "Collection(VMM.UserRoleResource)",
  "AddResource": [],
  "AddScope@odata.type": "Collection(VMM.UserRoleScope)",
  "AddScope": [],
  "CloudPermission@odata.type": "Collection(VMM.UserRoleCloudPermission)",
  "CloudPermission": [],
  "CloudPermissionInput@odata.type": "Collection(VMM.UserRoleCloudPermissionInput)",
  "CloudPermissionInput": [],
  "Description": null,
  "ID": "00000000-0000-0000-0000-000000000000",
  "Members@odata.type": "Collection(Edm.String)",
  "Members": [],
  "Name": "New User Role 1",
  "ParentUserRoleId": null,
  "Permission@odata.type": "Collection(Edm.String)",
  "Permission": [],
  "PermissionInput@odata.type": "Collection(VMM.UserRolePermission)",
  "PermissionInput": [],
  "Profile": null,
  "Quotas@odata.type": "Collection(VMM.UserRoleScope)",
  "Quotas": [],
  "RemoveCloudResourceExtension@odata.type": "Collection(VMM.UserRoleCloudResourceExtension)",
  "RemoveCloudResourceExtension": [],
  "RemoveMember@odata.type": "Collection(Edm.String)",
  "RemoveMember": [],
  "RemoveResource@odata.type": "Collection(VMM.UserRoleResource)",
  "RemoveResource": [],
  "RemoveScope@odata.type": "Collection(VMM.UserRoleScope)",
  "RemoveScope": [],
  "UserRoleDataPath@odata.type": "Collection(VMM.UserRoleDataPath)",
  "UserRoleDataPath": [],
  "UserRoleProfile": "SelfServiceUser",
  "VMId": null,
  "VMNetworkQuota@odata.type": "Collection(VMM.VMNetworkQuota)",
  "VMNetworkQuota": [],
  "VMTemplateId": null
}

Response

Response Codes

This operation does not return any non-standard OData response codes. If successful, it will return code 201 Created.

Response Headers

This operation does not use any non-standard response headers.

For more information about the common response headers used by this operation, see Common HTTP response information.

Response Body

The response body will contain a single (depending on the request headers) XML or JSON encoded UserRole [SPFSDK][VMMREF] entity as it exists on the server.

{
  "odata.metadata": "https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/$metadata#UserRoles/@Element",
  "AddMember": [],
  "AddResource": [],
  "AddScope": [],
  "AddCloudResourceExtension": [],
  "Description": null,
  "ID": "5cd5a60b-0895-4fee-82fc-856e108c579d",
  "Members": [],
  "Name": "New User Role 1",
  "ParentUserRoleId": null,
  "Permission": [],
  "CloudPermission": [],
  "Profile": null,
  "Quotas": [],
  "RemoveMember": [],
  "UserRoleProfile": null,
  "PermissionInput": [],
  "CloudPermissionInput": [],
  "RemoveResource": [],
  "RemoveScope": [],
  "RemoveCloudResourceExtension": [],
  "VMId": null,
  "VMTemplateId": null,
  "UserRoleDataPath": [],
  "VMNetworkQuota": []
}

Example: Create a new UserRole

This example demonstrates how to create a new user role.

For more information about how to get started with using the code examples provided in this programming guide, see Program in Visual Studio with the Windows Azure Pack IaaS Resource Provider [SPFSDK].

SpfVMM.UserRole userRole = new SpfVMM.UserRole();

userRole.UserRoleProfile = "SelfServiceUser";
userRole.Name = "New User Role 1";

vmmService.AddToUserRoles(userRole);
vmmService.SaveChanges();

HTTP Request

POST https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/UserRoles HTTP/1.1
DataServiceVersion: 3.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Content-Type: application/json;odata=minimalmetadata
Accept: application/json;odata=minimalmetadata
Accept-Charset: UTF-8
DataServiceUrlConventions: KeyAsSegment
User-Agent: Microsoft ADO.NET Data Services
Authorization: Bearer {ENCODED AUTHENTICATION TOKEN}
x-ms-principal-id: tenant@fabrikam.com
Host: contoso.com:30005
Content-Length: 1544
Expect: 100-continue

{"odata.type":"VMM.UserRole","AddCloudResourceExtension@odata.type":"Collection(VMM.UserRoleCloudResourceExtension)","AddCloudResourceExtension":[],"AddMember@odata.type":"Collection(Edm.String)","AddMember":[],"AddResource@odata.type":"Collection(VMM.UserRoleResource)","AddResource":[],"AddScope@odata.type":"Collection(VMM.UserRoleScope)","AddScope":[],"CloudPermission@odata.type":"Collection(VMM.UserRoleCloudPermission)","CloudPermission":[],"CloudPermissionInput@odata.type":"Collection(VMM.UserRoleCloudPermissionInput)","CloudPermissionInput":[],"Description":null,"ID":"00000000-0000-0000-0000-000000000000","Members@odata.type":"Collection(Edm.String)","Members":[],"Name":"New User Role 1","ParentUserRoleId":null,"Permission@odata.type":"Collection(Edm.String)","Permission":[],"PermissionInput@odata.type":"Collection(VMM.UserRolePermission)","PermissionInput":[],"Profile":null,"Quotas@odata.type":"Collection(VMM.UserRoleScope)","Quotas":[],"RemoveCloudResourceExtension@odata.type":"Collection(VMM.UserRoleCloudResourceExtension)","RemoveCloudResourceExtension":[],"RemoveMember@odata.type":"Collection(Edm.String)","RemoveMember":[],"RemoveResource@odata.type":"Collection(VMM.UserRoleResource)","RemoveResource":[],"RemoveScope@odata.type":"Collection(VMM.UserRoleScope)","RemoveScope":[],"UserRoleDataPath@odata.type":"Collection(VMM.UserRoleDataPath)","UserRoleDataPath":[],"UserRoleProfile":"SelfServiceUser","VMId":null,"VMNetworkQuota@odata.type":"Collection(VMM.VMNetworkQuota)","VMNetworkQuota":[],"VMTemplateId":null}

HTTP Response

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 643
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Location: https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/UserRoles/5cd5a60b-0895-4fee-82fc-856e108c579d
Server: Microsoft-IIS/8.5
X-Content-Type-Options: nosniff
request-id: d3df681c-b278-0000-2c66-e3d378b2cf01
DataServiceVersion: 3.0;
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
Date: Fri, 10 Oct 2014 23:10:12 GMT

{"odata.metadata":"https://contoso.com:30005/ae122d5f-3aab-4d75-ad48-d6593246a49e/services/systemcenter/vmm/$metadata#UserRoles/@Element","AddMember":[],"AddResource":[],"AddScope":[],"AddCloudResourceExtension":[],"Description":null,"ID":"5cd5a60b-0895-4fee-82fc-856e108c579d","Members":[],"Name":"New User Role 1","ParentUserRoleId":null,"Permission":[],"CloudPermission":[],"Profile":null,"Quotas":[],"RemoveMember":[],"UserRoleProfile":null,"PermissionInput":[],"CloudPermissionInput":[],"RemoveResource":[],"RemoveScope":[],"RemoveCloudResourceExtension":[],"VMId":null,"VMTemplateId":null,"UserRoleDataPath":[],"VMNetworkQuota":[]}

See Also

UserRoles Collection [SPFSDK][VMMREF]
UserRole [SPFSDK][VMMREF]