Queries the tags that are attached to a specified resource.
Operation description
When you call the ListTagResources operation, specify at least one of the following parameters in the request: Key and ResourceId. You can specify a resource ID to query all tags that are attached to the specified resource. You can also specify a tag key to query the tag value and resource to which the tag is attached.
- If you include the Key parameter in a request, you can obtain the tag value and the ID of the resource to which the tag is attached.
- If you include the ResourceId parameter in a request, you can obtain the keys and values of all tags that are attached to the specified resource.
Debugging
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
mq:ListTagResources | List |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
InstanceId | string | No | The ID of the ApsaraMQ for RocketMQ instance to which the resource whose tags you want to query belongs. Note
This parameter is required when you query the tags of a topic or a group.
| MQ_INST_188077086902****_BXSuW61e |
ResourceType | string | Yes | The type of the resource whose tags you want to query. Valid values:
| TOPIC |
NextToken | string | No | The token that determines the start point of the next query. | caeba0****be03f84eb48b699f0a4883 |
Tag | object [] | No | The tags that you want to query. A maximum of 20 tags can be included in the list. | |
Key | string | No | The key of the tag that you want to detach from the resource.
| CartService |
Value | string | No | The value of the tag that you want to query.
| ServiceA |
ResourceId | array | No | The list of resource IDs. | |
string | No | The ID of the resource whose tags you want to query.
| test |
Response parameters
Examples
Sample success responses
JSON
format
{
"NextToken": "caeba0****be03f84eb48b699f0a4883",
"RequestId": "301D2CBE-66F8-403D-AEC0-82582478****",
"TagResources": [
{
"ResourceType": "ALIYUN::MQ::TOPIC",
"InstanceId": "MQ_INST_188077086902****_BXSuW61e",
"TagValue": "ServiceA",
"ResourceId": "TopicA",
"TagKey": "CartService"
}
]
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|
Query resource tags in the console
You can also query the tags that are attached to a resource in the ApsaraMQ for RocketMQ console.**** For more information, see Manage tags.