All Products
Search
Document Center

Resource Management:ListPolicies

Last Updated:Jun 20, 2024

Queries a list of tag policies.

Operation description

If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query all tag policies that are created for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query all tag policies that are created for the resource directory. For more information about the modes of the Tag Policy feature, see Modes of the Tag Policy feature.

This topic provides an example on how to call the API operation to query all tag policies that are created for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that two tag policies are created.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
tag:ListPoliciesRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringNo

The region ID. Set the value to cn-shanghai.

cn-shanghai
MaxResultintegerNo

The number of entries to return on each page.

Default value: 50. Maximum value: 1000.

50
NextTokenstringNo

The token that is used to start the next query.

caeba0bbb2be03f84eb48b699f0a****
PolicyIdsarrayNo

The ID of a tag policy. This parameter specifies a filter condition for the query.

stringNo

The ID of a tag policy. This parameter specifies a filter condition for the query.

p-557cb141331f41c7****
PolicyNamesarrayNo

The name of a tag policy. This parameter specifies a filter condition for the query.

stringNo

The name of a tag policy. This parameter specifies a filter condition for the query.

test
UserTypestringNo

The mode of the Tag Policy feature. This parameter specifies a filter condition for the query. Valid values:

  • USER: single-account mode
  • RD: multi-account mode

For more information about the modes of the Tag Policy feature, see Modes of the Tag Policy feature.

Note The value of this parameter is not case-sensitive.
USER

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The ID of the request.

72477CFF-5B24-5E30-9861-3DD9C4BD46E5
NextTokenstring

Indicates whether the next query is required.

  • If the value of this parameter is empty ("NextToken": ""), all results are returned, and the next query is not required.
  • If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.
caeba0bbb2be03f84eb48b699f0a****
PolicyListobject []

The tag policies.

PolicyNamestring

The name of the tag policy.

example
PolicyDescstring

The description of the tag policy.

This is a tag policy example.
PolicyContentstring

The document of the tag policy.

{\"tags\":{\"CostCenter\":{\"tag_value\":{\"@@assign\":[\"Beijing\",\"Shanghai\"]},\"tag_key\":{\"@@assign\":\"CostCenter\"}}}}
PolicyIdstring

The ID of the tag policy.

p-de62a0bf400e4b69****
UserTypestring

The mode of the Tag Policy feature. Valid values:

  • USER: single-account mode
  • RD: multi-account mode

For more information about the modes of the Tag Policy feature, see Modes of the Tag Policy feature.

USER

Examples

Sample success responses

JSONformat

{
  "RequestId": "72477CFF-5B24-5E30-9861-3DD9C4BD46E5",
  "NextToken": "caeba0bbb2be03f84eb48b699f0a****",
  "PolicyList": [
    {
      "PolicyName": "example",
      "PolicyDesc": "This is a tag policy example.",
      "PolicyContent": "{\\\"tags\\\":{\\\"CostCenter\\\":{\\\"tag_value\\\":{\\\"@@assign\\\":[\\\"Beijing\\\",\\\"Shanghai\\\"]},\\\"tag_key\\\":{\\\"@@assign\\\":\\\"CostCenter\\\"}}}}",
      "PolicyId": "p-de62a0bf400e4b69****",
      "UserType": "USER"
    }
  ]
}

Error codes

For a list of error codes, visit the Service error codes.