All Products
Search
Document Center

Resource Management:ListTargetsForPolicy

Last Updated:Mar 03, 2024

Queries the objects to which a tag policy is attached.

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 the object to which a tag policy is attached. The object is the current logon 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 the objects to which a tag policy is attached. The objects include the Root folder, folders other than the Root folder, and members in 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 the objects to which the tag policy with an ID of p-de62a0bf400e4b69**** is attached. In this example, the Tag Policy feature in multi-account mode is used. The response shows that the tag policy is attached to two members in the related resource directory.

Debugging

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

Authorization information

There is currently no authorization information disclosed in the API.

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****
PolicyIdstringYes

The ID of the tag policy.

p-de62a0bf400e4b69****

For more information about common request parameters, see Common parameters.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

Targetsobject []

The objects to which the tag policy is attached.

TargetIdstring

The ID of the object.

195320939469****
TargetTypeinteger

The type of the object. Valid values:

  • USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
  • ROOT: the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
  • FOLDER: a folder other than the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
  • ACCOUNT: a member in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
ACCOUNT
RequestIdstring

The ID of the request.

2EE71C8D-6DB8-56AC-8B05-3D4C0116E6A1
IsRdboolean

Indicates whether the object belongs to the resource directory. Valid values:

  • true: The object belongs to the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
  • false: The object does not belong to the resource directory. This value is available if you use the Tag Policy feature in single-account mode.
true
RdIdstring

The ID of the resource directory.

Note This parameter is returned only if you use the Tag Policy feature in multi-account mode.
rd-3G****
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****

Examples

Sample success responses

JSONformat

{
  "Targets": [
    {
      "TargetId": "195320939469****",
      "TargetType": 0
    }
  ],
  "RequestId": "2EE71C8D-6DB8-56AC-8B05-3D4C0116E6A1",
  "IsRd": true,
  "RdId": "rd-3G****",
  "NextToken": "caeba0bbb2be03f84eb48b699f0a****"
}

Error codes

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

Change history

Change timeSummary of changesOperation
2023-12-08The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.