Adding an Assignment
Function
This API is used to add an assignment.
URI
PUT /v1/resource-manager/domains/{domain_id}/policy-assignments
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| domain_id | Yes | String | Specifies the account ID. Maximum length: 36 |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | No | String | Specifies the assignment name. Maximum length: 64 |
| description | No | String | Provides supplementary information about the assignment. Maximum length: 512 |
| policy_filter | No | PolicyFilterDefinition object | Specifies the assignment filter. |
| policy_definition_id | No | String | Specifies the policy ID. Maximum length: 36 |
| parameters | No | Map<String,PolicyParameterValue> | Specifies the assignment parameters. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| region_id | No | String | Specifies the region ID. Maximum: 128 |
| resource_provider | No | String | Specifies the cloud service name. Maximum length: 128 |
| resource_type | No | String | Specifies the resource type. Maximum: 128 |
| resource_id | No | String | Specifies the resource ID. Maximum length: 256 |
| tag_key | No | String | Specifies the tag key. Maximum length: 128 |
| tag_value | No | String | Specifies the tag value. Maximum length: 256 |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| id | String | Specifies the assignment ID. |
| name | String | Specifies the assignment name. |
| description | String | Provides supplementary information about the assignment. |
| policy_filter | PolicyFilterDefinition object | Specifies the assignment filter. |
| state | String | Specifies the assignment status. |
| created | String | Specifies the time when the assignment was added. |
| updated | String | Specifies the time when the assignment was modified. |
| policy_definition_id | String | Specifies the ID of the policy used by the assignment. |
| parameters | Map<String,PolicyParameterValue> | Specifies the assignment parameters. |
| Parameter | Type | Description |
|---|---|---|
| region_id | String | Specifies the region ID. Maximum: 128 |
| resource_provider | String | Specifies the cloud service name. Maximum length: 128 |
| resource_type | String | Specifies the resource type. Maximum: 128 |
| resource_id | String | Specifies the resource ID. Maximum length: 256 |
| tag_key | String | Specifies the tag key. Maximum length: 128 |
| tag_value | String | Specifies the tag value. Maximum length: 256 |
| Parameter | Type | Description |
|---|---|---|
| value | Object | Specifies the value of the assignment parameter. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Specifies the error code. |
| error_msg | String | Specifies the error message. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Specifies the error code. |
| error_msg | String | Specifies the error message. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Specifies the error code. |
| error_msg | String | Specifies the error message. |
Example Request
PUT https://{endpoint}/v1/resource-manager/domains/{domain_id}/policy-assignments
{
"name" : "allowed-images-by-id",
"description" : "The ECS resource is non-compliant if the image it used is not in the allowed list",
"parameters" : {
"listOfAllowedImages" : {
"value" : [ "ea0d6e0e-99c3-406d-a873-3bb45462b624" ]
}
},
"policy_filter" : {
"resource_provider" : "ecs",
"resource_type" : "cloudservers"
},
"policy_definition_id" : "5f3c8b9a9811a13739a32ed9"
} Example Response
Status code: 200
Operation succeeded.
-
"5fb76a240f2daf0b9662a04d"
-
"volume-inuse-check"
-
"The EVS disk is non-compliant if it is unmounted"
-
{ "region_id" : null, "resource_provider" : "evs", "resource_type" : "volumes", "resource_id" : null, "tag_key" : null, "tag_value" : null } -
"Enabled"
-
"2020-11-20T07:03:00"
-
"2020-11-20T07:03:00"
-
"5fa36558aa1e6afc05a3d0a7"
-
{ }
Status Codes
| Status Code | Description |
|---|---|
| 200 | Operation succeeded. |
| 400 | Invalid parameter. |
| 403 | Authentication failed or you do not have the operation permission. |
| 500 | Internal server error. |
Error Codes
See Error Codes.
Last Article: Querying a Built-in Policy
Next Article: Querying All Assignments
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.