Help Center> Config> API Reference> API> Compliance> Querying a Built-in Policy

Querying a Built-in Policy

Function

This API is used to query a built-in policy based on its ID.

URI

GET /v1/resource-manager/policy-definitions/{policy_definition_id}

Table 1 Path parameter

Parameter

Mandatory

Type

Description

policy_definition_id

Yes

String

Specifies the policy ID.

Maximum length: 36

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Language

No

String

Specifies the language of the information to return.

Default value: zh-cn

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

id

String

Specifies the policy ID.

name

String

Specifies the policy name.

policy_type

String

Specifies the policy type.

description

String

Provides supplementary information about the policy.

policy_rule_type

String

Specifies the syntax type of the policy.

policy_rule

Object

Specifies how the policy is executed.

keywords

Array of strings

Specifies the list of key words.

parameters

Map<String,PolicyParameterDefinition>

Specifies the policy parameters.

Table 4 PolicyParameterDefinition

Parameter

Type

Description

name

String

Specifies the policy parameter name.

description

String

Provides supplementary information about the policy parameter.

allowed_values

Array of objects

Specifies the allowed values of the policy parameter.

default_value

String

Specifies the default value of the policy parameter.

type

String

Specifies the type of the policy parameter.

Possible values are as follows:

  • Array

  • Boolean

  • Integer

  • Float

  • String

  • DateTime

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 404

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the error code.

error_msg

String

Specifies the error message.

Example Request

GET https://{endpoint}/v1/resource-manager/policy-definitions/5f8d5428ffeecc14f1fb5205

Example Response

Status code: 200

Built-in policy

  • Example 1

    "5f8d5428ffeecc14f1fb5205"
  • Example 2

    "ecs-instance-no-public-ip"
  • Example 3

    "builtin"
  • Example 4

    "An ECS is non-compliant if it has a public IP address."
  • Example 5

    "dsl"
  • Example 6

    {
      "allOf" : [ {
        "value" : "${resource().provider}",
        "comparator" : "equals",
        "pattern" : "ecs"
      }, {
        "value" : "${resource().type}",
        "comparator" : "equals",
        "pattern" : "cloudservers"
      }, {
        "value" : "${length(filter(resource().properties.addresses, lambda x: equals(x.OsExtIpsType, 'floating')))}",
        "comparator" : "greater",
        "pattern" : 0
      } ]
    }
  • Example 7

    [ "ecs" ]
  • Example 8

    { }

Status Codes

Status Code

Description

200

Operation succeeded.

400

Invalid parameter.

403

Authentication failed or you do not have the operation permission.

404

Policy not found.

500

Internal server error.

Error Codes

See Error Codes.