Querying All Built-in Policies
Function
This API is used to query all built-in policies.
URI
GET /v1/resource-manager/policy-definitions
Request Parameters
| 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
| Parameter | Type | Description |
|---|---|---|
| value | Array of PolicyDefinition objects | Specifies the policy list. |
| page_info | PageInfo object | Specifies the pagination object. |
| 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. |
| 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: |
| Parameter | Type | Description |
|---|---|---|
| current_count | Integer | Specifies the resource quantity on the current page. Minimum value: 0 Maximum value: 200 |
| next_marker | String | Specifies the marker value of the next page. |
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: 404
| 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
None
Example Response
Status code: 200
Operation succeeded.
-
[ { "id" : "5fa365476eed194ccb2c04d1", "name" : "volumes-encrypted-check", "policy_type" : "builtin", "description": "The mounted EVS disk is non-compliant if it is not encrypted.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "evs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "volumes" }, { "value" : "${resource().properties.status}", "comparator" : "equals", "pattern" : "in-use" }, { "anyOf" : [ { "value" : "${resource().properties.metadata}", "comparator" : "notContainsKey", "pattern" : "systemEncrypted" }, { "value" : "${resource().properties.metadata.systemEncrypted}", "comparator" : "equals", "pattern" : "0" } ] } ] }, "keywords" : [ "evs", "ecs" ], "parameters" : { } }, { "id" : "5fa9f89b6eed194ccb2c04db", "name" : "required-tag-check", "policy_type" : "builtin", "description": "The resource is non-compliant if it does not contain a specific tag.", "policy_rule_type" : "dsl", "policy_rule" : { "anyOf" : [ { "value" : "${contains(resource().tags, parameters('specifiedTagKey'))}", "comparator" : "equals", "pattern" : false }, { "allOf" : [ { "value" : "${length(parameters('specifiedTagValue'))}", "comparator" : "greater", "pattern" : 0 }, { "value" : "${getValue(resource().tags, parameters('specifiedTagKey'))}", "comparator" : "notIn", "pattern" : "${parameters('specifiedTagValue')}" } ] } ] }, "keywords" : [ "tag" ], "parameters" : { "specifiedTagKey" : { "name" : null, "description" : "the specified tag key", "allowed_values" : null, "default_value" : null, "type" : "String" }, "specifiedTagValue" : { "name" : null, "description" : "The list of allowed tag value, permit all if empty", "allowed_values" : null, "default_value" : null, "type" : "Array" } } }, { "id" : "5fa265c0aa1e6afc05a0ff07", "name" : "allowed-images-by-id", "policy_type" : "builtin", "description": "The ECS resource is non-compliant if the image it used is not in the allowed list.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "ecs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "cloudservers" }, { "value" : "${resource().properties.metadata.meteringImageId}", "comparator" : "notIn", "pattern" : "${parameters('listOfAllowedImages')}" } ] }, "keywords" : [ "ecs", "ims" ], "parameters" : { "listOfAllowedImages" : { "name" : null, "description" : "The list of allowed image IDs", "allowed_values" : null, "default_value" : null, "type" : "Array" } } }, { "id" : "5fa36558aa1e6afc05a3d0a7", "name" : "volume-inuse-check", "policy_type" : "builtin", "description": "The EVS disk is non-compliant if it is unmounted.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "evs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "volumes" }, { "value" : "${resource().properties.status}", "comparator" : "equals", "pattern" : "available" } ] }, "keywords" : [ "evs" ], "parameters" : { } }, { "id" : "5fa3a1196eed194ccb2c04d7", "name" : "allowed_volume_specs", "policy_type" : "builtin", "description": "The EVS disk is non-compliant if its specification is not in the allowed list.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "evs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "volumes" }, { "value" : "${resource().properties.volumeType}", "comparator" : "notIn", "pattern" : "${parameters('listOfAllowedSpecs')}" } ] }, "keywords" : [ "evs" ], "parameters" : { "listOfAllowedSpecs" : { "name" : null, "description" : "The list of allowed disk specifications", "allowed_values" : null, "default_value" : null, "type" : "Array" } } }, { "id" : "5f8d549bffeecc14f1fb522a", "name" : "allowed_ecs_flavors", "policy_type" : "builtin", "description": "The ECS resource is non-compliant if its flavor type is not in the allowed list.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "ecs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "cloudservers" }, { "value" : "${resource().properties.flavor.name}", "comparator" : "notIn", "pattern" : "${parameters('listOfAllowedFlavors')}" } ] }, "keywords" : [ "ecs" ], "parameters" : { "listOfAllowedFlavors" : { "name" : null, "description" : "The list of allowed flavor types", "allowed_values" : null, "default_value" : null, "type" : "Array" } } }, { "id" : "5fa3a1196eed194ccb2c04d5", "name" : "eip-unbound-check", "policy_type" : "builtin", "description": "The EIP resource is non-compliant if it is not bound to any other resources.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "vpc" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "publicips" }, { "value" : "${resource().properties.status}", "comparator" : "equals", "pattern" : "DOWN" } ] }, "keywords" : [ "vpc" ], "parameters" : { } }, { "id" : "5f8d5428ffeecc14f1fb5205", "name" : "ecs-instance-no-public-ip", "policy_type" : "builtin", "description": "The ECS resource is non-compliant if it binds a public IP.", "policy_rule_type" : "dsl", "policy_rule" : { "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 } ] }, "keywords" : [ "ecs" ], "parameters" : { } }, { "id" : "5fa265c0aa1e6afc05a0ff10", "name" : "ecs-instance-in-vpc", "policy_type" : "builtin", "description": "The ECS resource is non-compliant if it is not in a specific VPC.", "policy_rule_type" : "dsl", "policy_rule" : { "allOf" : [ { "value" : "${resource().provider}", "comparator" : "equals", "pattern" : "ecs" }, { "value" : "${resource().type}", "comparator" : "equals", "pattern" : "cloudservers" }, { "value" : "${resource().properties.metadata.vpcId}", "comparator" : "notEquals", "pattern" : "${parameters('vpcId')}" } ] }, "keywords" : [ "ecs", "vpc" ], "parameters" : { "vpcId" : { "name" : null, "description" : "VPC ID that contains the ECS instance", "allowed_values" : null, "default_value" : null, "type" : "String" } } } ] -
{ "current_count" : 9, "next_marker" : null }
Status Codes
| Status Code | Description |
|---|---|
| 200 | Operation succeeded. |
| 400 | Invalid parameter. |
| 403 | Authentication failed or you do not have the operation permission. |
| 404 | Resource not found. |
| 500 | Internal server error. |
Error Codes
See Error Codes.
Last Article: Compliance
Next Article: Querying a Built-in Policy
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.