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:

  • INSTANCE
  • TOPIC
  • GROUP
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.

  • The value of N can be a number from 1 to 20.
  • If you include this parameter in a request, the value of this parameter cannot be an empty string.
  • The value of this parameter can be up to 128 characters in length and cannot start with acs: or aliyun, or contain http:// or https://.
Tag.N.Value String No ServiceA

The value of the tag that you want to query.

  • The value of N can be a number from 1 to 20.
  • The value of this parameter can be an empty string.
  • The value of this parameter can be up to 128 characters in length and cannot start with acs: or aliyun, or contain http:// or https://.
ResourceId.N String No test

The ID of the resource whose tags you want to query.

  • If the resource is a Message Queue for Apache RocketMQ instance, specify the ID of the instance.
  • If the resource is a topic, specify the name of the topic.
  • If the resource is a group, specify the ID of the group.

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.

  • ALIYUN::MQ::INSTANCE: indicates that the resource is a Message Queue for Apache RocketMQ instance.
  • ALIYUN::MQ::TOPIC: indicates that the resource is a topic.
  • ALIYUN::MQ::GROUP: indicates that the resource is a group.
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.