CreateRole
API Request
URLs
POST zstack/v1/identities/roles
Headers
Authorization: OAuth the-session-uuid
Body
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "role-1",
"description": "role for test",
"statements": [
"statement for test"
],
"policyUuids": [
"c950762ed8ab31818b320c704a1a276f"
]
},
"systemTags": [],
"userTags": []
}

Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"role-1","description":"role for test","statements":["statement for test"],"policyUuids":["c950762ed8ab31818b320c704a1a276f"]}}' http://localhost:8080/zstack/v1/identities/roles
Request Parameters
Name | Type | Location | Description | Optional Value | Starting Version |
---|---|---|---|---|---|
name | String | body (contained in the params structure) | The resource name. | 0.6 | |
description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 0.6 | |
statements | List | body (contained in the params structure) | Optional. | 0.6 | |
policyUuids | List | body (contained in the params structure) | Optional. | 0.6 | |
resourceUuid | String | body (contained in the params structure) | Optional. | 0.6 | |
systemTags | List | body | Optional. | 0.6 | |
userTags | List | body | Optional. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"uuid": "7e9df59e6d453b2187a0da3ee94f63c9",
"name": "role-1",
"description": "role for test",
"type": "Customized",
"state": "Enabled",
"statements": [
"statement for test"
]
}
}
Name | Type | Description | Starting Version |
---|---|---|---|
error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
inventory | RoleInventory | See inventory. | 0.6 |
#error
Name | Type | Description | Starting Version |
---|---|---|---|
code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
description | String | The brief description of the error. | 0.6 |
details | String | The details about the error. | 0.6 |
elaboration | String | The reserved field. Default value: null. | 0.6 |
opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
Name | Type | Description | Starting Version |
---|---|---|---|
uuid | String | The resource UUID. | 0.6 |
name | String | The resource name. | 0.6 |
description | String | The detailed description of the resource. | 0.6 |
createDate | Timestamp | The creation date. | 0.6 |
lastOpDate | Timestamp | The last operation date. | 0.6 |
type | RoleType | See type. | 0.6 |
state | RoleState | See state. | 0.6 |
statements | List | See statements. | 0.6 |
#type
Name | Type | Description | Starting Version |
---|---|---|---|
name | String | The resource name. | 0.6 |
ordinal | int | 0.6 |
#state
Name | Type | Description | Starting Version |
---|---|---|---|
name | String | The resource name. | 0.6 |
ordinal | int | 0.6 |
#statements
Name | Type | Description | Starting Version |
---|---|---|---|
uuid | String | The resource UUID. | 0.6 |
createDate | Timestamp | The creation date. | 0.6 |
lastOpDate | Timestamp | The last operation date. | 0.6 |
statement | PolicyStatement | See statement. | 0.6 |
#statement
Name | Type | Description | Starting Version |
---|---|---|---|
name | String | The resource name. | 0.6 |
principals | List | 0.6 | |
actions | List | 0.6 | |
resources | List | 0.6 | |
effect | StatementEffect | See effect. | 0.6 |
#effect
Name | Type | Description | Starting Version |
---|---|---|---|
name | String | The resource name. | 0.6 |
ordinal | int | 0.6 |
SDK Sample
Java
SDK
CreateRoleAction action = new CreateRoleAction();
action.name = "role-1";
action.description = "role for test";
action.statements = asList("statement for test");
action.policyUuids = asList("c950762ed8ab31818b320c704a1a276f");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateRoleAction.Result res = action.call();
Python
SDK
CreateRoleAction action = CreateRoleAction()
action.name = "role-1"
action.description = "role for test"
action.statements = [statement for test]
action.policyUuids = [c950762ed8ab31818b320c704a1a276f]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateRoleAction.Result res = action.call()