Help Center> Config> API Reference> API> Compliance> Adding an Assignment

Adding an Assignment

Function

This API is used to add an assignment.

URI

PUT /v1/resource-manager/domains/{domain_id}/policy-assignments

Table 1 Path parameter

Parameter

Mandatory

Type

Description

domain_id

Yes

String

Specifies the account ID.

Maximum length: 36

Request Parameters

Table 2 Request body 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.

Table 3 PolicyFilterDefinition

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

Table 4 PolicyParameterValue

Parameter

Mandatory

Type

Description

value

No

Object

Specifies the value of the assignment parameter.

Response Parameters

Status code: 200

Table 5 Response body parameters

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.

Table 6 PolicyFilterDefinition

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

Table 7 PolicyParameterValue

Parameter

Type

Description

value

Object

Specifies the value of the assignment parameter.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 500

Table 10 Response body parameters

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.

  • Example 1

    "5fb76a240f2daf0b9662a04d"
  • Example 2

    "volume-inuse-check"
  • Example 3

    "The EVS disk is non-compliant if it is unmounted"
  • Example 4

    {
      "region_id" : null,
      "resource_provider" : "evs",
      "resource_type" : "volumes",
      "resource_id" : null,
      "tag_key" : null,
      "tag_value" : null
    }
  • Example 5

    "Enabled"
  • Example 6

    "2020-11-20T07:03:00"
  • Example 7

    "2020-11-20T07:03:00"
  • Example 8

    "5fa36558aa1e6afc05a3d0a7"
  • Example 9

    { }

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.