Queries the tags that are added to one or more Resource Orchestration Service (ROS) resources.

Description

  • To specify the query object, you must specify the ResourceId.N or Tag.N parameter in the request. Tag.N consists of Tag.N.Key and Tag.N.Value.
  • If you specify the Tag.N and ResourceId.N parameters, ROS resources that match both the parameters are returned.

This topic provides an example on how to query the tags that are added to a resource in a stack. In this example, the resource ID is 6bc589b5-9c02-4944-8fc3-f3624234****. The stack is deployed in the China (Hangzhou) region.

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 parameters

Parameter Type Required Example Description
Action String Yes ListTagResources

The operation that you want to perform. Set the value to ListTagResources.

RegionId String Yes cn-hangzhou

The region ID of the tag. You can call the DescribeRegions operation to query the most recent region list.

ResourceType String Yes stack

The type of the resource. Valid values:

  • stack: stack
  • stackgroup: stack group
  • template: template
  • templatescratch: scenario
NextToken String No caeba0bbb2be03f84eb48b699f0*****

The token that determines the start point of the next query.

ResourceId.N String No 6bc589b5-9c02-4944-8fc3-f3624234****

The ID of resource N. You can specify up to 50 resource IDs.

Note If you set the ResourceType parameter to stackgroup, you must use the name of the stack group as the resource ID.
Tag.N.Key String No FinanceDept

The key of tag N that is added to the resource. You can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 128 characters in length, and cannot contain http:// or https://. The tag key cannot start with aliyun or acs:.

Tag.N.Value String No FinanceJoshua

The value of tag N that is added to the resource. You can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

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

Response parameters

Parameter Type Example Description
NextToken String caeba0bbb2be03f84eb48b699f0*****

The token that is used to start the next query.

RequestId String C429473A-5C66-4661-B5F8-4F900CD4330A

The ID of the request.

TagResources Array of TagResource

The information about the tags that are added to the resource.

ResourceType String stack

The type of the resource.

TagValue String TayValue1

The tag value of the resource.

ResourceId String c754d2a4-28f1-46df-b557-9586173a****

The ID of the resource.

TagKey String TagKey1

The tag key of the resource.

Examples

Sample requests

http(s)://ros.aliyuncs.com/?Action=ListTagResources
&RegionId=cn-hangzhou
&ResourceType=stack
&ResourceId.N=6bc589b5-9c02-4944-8fc3-f3624234****
&<Common request parameters>

Sample success responses

XML format

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

<ListTagResourcesResponse>
	<RequestId>FFBB9725-261D-4321-B627-C98304200065</RequestId>
	<NextToken></NextToken>
	<TagResources>
		<ResourceId>c754d2a4-28f1-46df-b557-9586173a****</ResourceId>
		<TagKey>TagKey1</TagKey>
		<ResourceType>stack</ResourceType>
		<TagValue>TayValue1</TagValue>
	</TagResources>
</ListTagResourcesResponse>

JSON format

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

{
  "RequestId" : "FFBB9725-261D-4321-B627-C98304200065",
  "NextToken" : "",
  "TagResources" : [ {
    "ResourceId" : "c754d2a4-28f1-46df-b557-9586173a****",
    "TagKey" : "TagKey1",
    "ResourceType" : "stack",
    "TagValue" : "TayValue1"
  } ]
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

400

MissingParameter

One of the input parameters ResourceIds,Tags should be specified.

The error message returned because the ResourceId.N and Tag.N parameters are not specified. Specify at least one of the parameters.

400

InvalidParameter

The specified parameter ResourceType is invalid, {reason}.

The error message returned because the specified ResourceType parameter is invalid. reason indicates the cause of the error.

400

InvalidParameter

The specified parameter Tags is invalid, {reason}.

The error message returned because the specified Tag.N parameter is invalid. reason indicates the cause of the error.

400

Duplicate.TagKey

The Tag.N.Key contain duplicate key.

The error message returned because the specified tag key already exists. Specify a unique tag key.