You can call the ListTagResources operation to query the labels that are added to specified resources.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request syntax

GET /tags?resource_ids=["String"]&resource_type=String&region_id=String&tags=[{"key":"String","value":"String"}]&next_token=String HTTP/1.1
Content-Type:application/json

Request parameters

Table 1. Request query parameters
Parameter Type Required Example Description
resource_ids Array of String Yes c71cf3d796c374bf48644482cb0c3****

The ID of the cluster.

resource_type String Yes CLUSTER

The type of the resource. Valid values:CLUSTER.

region_id String Yes cn-beijing

The ID of the region.

tags Array of tag No

The list of labels that you want to query. You can specify at most 20 labels.

next_token String No ***

The token that is used to start the next query.

Response syntax

HTTP/1.1 200 OK
Content-Type:application/json

{
  "next_token" : "String",
  "request_id" : "String",
  "tag_resources" : {
    "tag_resource" : [ {
      "tag_key" : "String",
      "tag_value" : "String",
      "resource_id" : "String",
      "resource_type" : "String"
    } ]
  }
}

Response parameters

Table 2. Response body parameters
Parameter Type Example Description
next_token String c374bf4864448****

The token that is used to start the next query.

request_id String E368C761-F8F6-4A36-9B58-BD53D5CD0CEB

The ID of the request.

tag_resources object

The details of the queried labels and resources.

tag_resource Array of tag_resource

The labels of the resource.

tag_key String ack.aliyun.com

The key of the label.

tag_value String c71cf3d796c374bf48644482cb0c3****

The value of the label.

resource_id String i-xxx

The ID of the resource.

resource_type String CLUSTER

The type of the resource. For more information, see Labels.

Examples

Sample requests

GET /tags?resource_ids=["c71cf3d796c374bf48644482cb0c3****"]&resource_type=CLUSTER&region_id=cn-beijing&tags=[{"key":"env","value":"prod"}]&next_token=*** HTTP/1.1
Host:cs.aliyuncs.com
Content-Type:application/json

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<next_token>c374bf4864448****</next_token>
<request_id>E368C761-F8F6-4A36-9B58-BD53D5CD0CEB</request_id>
<tag_resources>
    <tag_resource>
        <tag_key>ack.aliyun.com</tag_key>
        <tag_value>c71cf3d796c374bf48644482cb0c3****</tag_value>
        <resource_id>i-xxx</resource_id>
        <resource_type>CLUSTER</resource_type>
    </tag_resource>
</tag_resources>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "next_token" : "c374bf4864448****",
  "request_id" : "E368C761-F8F6-4A36-9B58-BD53D5CD0CEB",
  "tag_resources" : {
    "tag_resource" : [ {
      "tag_key" : "ack.aliyun.com",
      "tag_value" : "c71cf3d796c374bf48644482cb0c3****",
      "resource_id" : "i-xxx",
      "resource_type" : "CLUSTER"
    } ]
  }
}

Error codes

For a list of error codes, visit the API Error Center.