Queries the tags that are attached to a resource.
Note
When you call the ListTagResources operation, you must specify at least one of the following parameters in the request: Tag.N.Key and ResourceId.N. 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 the resource to which the tag is attached.
- If you configure the Tag.N.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 configure the ResourceId.N parameter in a request, you can obtain the keys and values of all tags that are attached to the specified resource.
QPS limit
Each Alibaba Cloud account can call this operation up to 10 times per second. If the number of requests that you send to call this operation within a second exceeds the queries per second (QPS) limit, throttling is triggered. This may interrupt your business. For information about the QPS limit of each operation, see API rate limits.
Authorization
By default, Alibaba Cloud accounts can call this operation. A Resource Access Management (RAM) user can call this operation only after the RAM user is granted the required permissions. The following table describes the permissions that must be granted to a RAM user to call this operation. For information about how to grant permissions, Policies.
API |
Action |
Resource |
---|---|---|
ListTagResources |
mq:QueryInstanceBaseInfo mq:ListTagResources |
acs:mq:*:*:* acs:mq:*:*:{InstanceId} |
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | ListTagResources |
The operation that you want to perform. Set the value to ListTagResources. |
InstanceId | String | No | MQ_INST_188077086902****_BXSuW61e |
The ID of the Message Queue for Apache 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.
|
ResourceType | String | Yes | TOPIC |
The type of the resource whose tags you want to query. The value is an enumerated value. Valid values:
|
NextToken | String | No | caeba0****be03f84eb48b699f0a4883 |
The token that is used to query the next page. |
Tag.N.Key | String | No | CartService |
The key of the tag that you want to query.
|
Tag.N.Value | String | No | ServiceA |
The value of the tag that you want to query.
|
ResourceId.N | String | No | test |
The ID of the resource whose tags you want to query.
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
NextToken | String | caeba0****be03f84eb48b699f0a4883 |
The token that is used to query the next page. |
RequestId | String | 301D2CBE-66F8-403D-AEC0-82582478**** |
The ID of the request. The system generates a unique ID for each request. You can troubleshoot issues based on the request ID. |
TagResources | Array of TagResource |
The details of the resource and tags, including the resource ID, the resource type, and the keys and values of tags. |
|
ResourceType | String | ALIYUN::MQ::TOPIC |
The type of the resource.
|
InstanceId | String | MQ_INST_188077086902****_BXSuW61e |
The ID of the Message Queue for Apache RocketMQ instance to which the resource belongs. |
TagValue | String | ServiceA |
The value of the tag. |
ResourceId | String | TopicA |
The ID of the resource. |
TagKey | String | CartService |
The key of the tag. |
Examples
Sample requests
http(s)://ons.cn-hangzhou.aliyuncs.com/?Action=ListTagResources
&ResourceType=TOPIC
&ResourceId.1=TopicA
&InstanceId=MQ_INST_188077086902****_BXSuW61e
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<ListTagResourcesResponse>
<RequestId>301D2CBE-66F8-403D-AEC0-82582478****</RequestId>
<NextToken>caeba0****be03f84eb48b699f0a4883</NextToken>
<TagResources>
<ResourceId>TopicA</ResourceId>
<InstanceId>MQ_INST_188077086902****_BXSuW61e</InstanceId>
<TagKey>CartService</TagKey>
<ResourceType>ALIYUN::MQ::TOPIC</ResourceType>
<TagValue>ServiceA</TagValue>
</TagResources>
</ListTagResourcesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "301D2CBE-66F8-403D-AEC0-82582478****",
"NextToken" : "caeba0****be03f84eb48b699f0a4883",
"TagResources" : {
"ResourceId" : "TopicA",
"InstanceId" : "MQ_INST_188077086902****_BXSuW61e",
"TagKey" : "CartService",
"ResourceType" : "ALIYUN::MQ::TOPIC",
"TagValue" : "ServiceA"
}
}
Error codes
For a list of error codes, visit the API Error Center.
View tags of a resource in the console
In Message Queue for Apache RocketMQ console, you can view the tags that are attached to a resource. For more information, see Manage tags.