All Products
Search
Document Center

:DescribeTags

最終更新日:Aug 21, 2023

Queries tags that meet the specified filter conditions.

Usage notes

  • Specify ResourceId.N or Tag.N that consists of Tag.N.Key and Tag.N.Value in the request to specify the object to be queried.
  • Tag.N is a resource tag that consists of a key-value pair. If you specify only Tag.N.Key, all tag values that are associated with the specified key are returned. If you specify only Tag.N.Value, an error message is returned.
  • If you specify Tag.N and ResourceId.N to filter tags, ResourceId.N must match all specified key-value pairs.
  • If you specify multiple key-value pairs, all tags that match the key-value pairs are returned.

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
ResourceType String No VPC

The resource type. Valid values:

  • VPC: virtual private cloud (VPC)
  • VSWITCH: vSwitch
  • ROUTETABLE: route table
  • EIP: elastic IP address (EIP)
  • VPNGATEWAY: VPN gateway
  • NATGATEWAY: NAT gateway
  • COMMONBANDWIDTHPACKAGE: EIP bandwidth plan
  • PREFIXLIST: prefix list
  • PUBLICIPADDRESSPOOL: IP address pool
  • IPV4GATEWAY: IPv4 gateway
  • IPV6GATEWAY: IPv6 gateway
  • NETWORKACL: network access control list (ACL)
  • TRAFFICMIRRORFILTER: traffic mirror filter
  • TRAFFICMIRRORSESSION: traffic mirror session
  • FLOWLOG: flow log
  • HAVIP: high availability virtual IP address (HAVIP)
  • DHCPOPTIONSSET: DHCP options set
  • GATEWAYENDPOINT: gateway endpoint
Note The values are case-insensitive.
RegionId String Yes cn-hangzhou

The ID of the region to which the resource belongs.

You can call the DescribeRegions operation to query the most recent region list.

NextToken String No FFmyTO70tTpLG6I3FmYAXGKPd****

The pagination token that is used in the next request to retrieve a new page of results. Valid values:

  • If this is your first query and no next queries are to be sent, ignore this parameter.
  • If a next query is to be sent, set the parameter to the value of NextToken that is returned from the last call.
MaxResult Integer No 50

The number of entries to return on each page. Valid values: 1 to 50. Default value: 50.

Action String Yes DescribeTags

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

ResourceId.N String No vpc-bp16qjewdsunr41m1****

The resource ID. You can enter at most 50 IDs.

Note If you specify this parameter, you must specify ResourceType.
Tag.N.Key String No FinanceDept

The key of tag N to add to the resource. You can specify at most 20 tag keys.

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

Tag.N.Value String No FinanceJoshua

The value of tag N to add to the resource. You can specify at most 20 tag values.

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

Response parameters

Parameter Type Example Description
NextToken String FFmyTO70tTpLG6I3FmYAXGKPd****

The pagination token that is used in the next request to retrieve a new page of results. Valid values:

  • If NextToken is empty, no next page exists.
  • If a value is returned for NextToken, the value is the token that is used for the next query.
RequestId String C46FF5A8-C5F0-4024-8262-B16B639225A0

The request ID.

TagResources Array of TagResource

The list of tags that meet the filter conditions.

TagResource
TagValue String FinanceJoshua

The value of tag N.

TagKey String FinanceDept

The key of tag N.

Examples

Sample requests

http(s)://[Endpoint]/?ResourceType=VPC
&RegionId=cn-hangzhou
&NextToken=FFmyTO70tTpLG6I3FmYAXGKPd****
&MaxResult=50
&Action=DescribeTags
&ResourceId=["vpc-bp16qjewdsunr41m1****"]
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&<Common request parameters>

Sample success responses

XML format

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

<DescribeTagsResponse>
    <NextToken>FFmyTO70tTpLG6I3FmYAXGKPd****</NextToken>
    <RequestId>C46FF5A8-C5F0-4024-8262-B16B639225A0</RequestId>
    <TagResources>
        <TagValue>FinanceJoshua</TagValue>
        <TagKey>FinanceDept</TagKey>
    </TagResources>
</DescribeTagsResponse>

JSON format

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

{
  "NextToken" : "FFmyTO70tTpLG6I3FmYAXGKPd****",
  "RequestId" : "C46FF5A8-C5F0-4024-8262-B16B639225A0",
  "TagResources" : [ {
    "TagValue" : "FinanceJoshua",
    "TagKey" : "FinanceDept"
  } ]
}

Error codes

HttpCode Error code Error message Description
400 BothEmpty.TagsAndResources The specified Tags and ResourcesIds are not allow to both empty. ResourceId.N and Tag.N are not specified. You must specify at least one of the parameters.
400 MissingParameter.TagKey The input parameter TagKey that is mandatory for processing this request is not supplied. TagKey is not specified.
400 MissingParameter.TagValue The input parameter TagValue that is mandatory for processing this request is not supplied. TagValue is not specified.
400 InvalidTagKey The tag keys are not valid. The tag index is invalid.
400 InvalidTagValue The tag values are not valid. The tag value is invalid.
400 InvalidInstanceType.NotFound The instance type is not found The instance type is not found.
400 InvalidInstanceIds.NotFound The instanceIds are not found The instance ID is not found.
400 Forbidden.TagKeys The request do not allow to operate the tag keys You do not have the permissions to specify TagKeys.
400 QuotaExceeded.TagNum Custom Tags quota exceeded The upper limit is reached.
400 Forbidden.NotAllowedCategary The System tag is not valid The system tag is invalid.
400 Forbidden.TagKeys The request does not allow operate this tagkeys You cannot manage the tag key by calling the operation.
400 Forbidden.TagKey.Duplicated The specified tag key already exists. The tag resources are duplicate.
400 SizeLimitExceeded.TagNum The maximum number of tags is exceeded. The number of tags has reached the upper limit.
400 SizeLimitExceeded.ResourceId The maximum number of resource IDs is exceeded. The number of resource group IDs exceeds the upper limit.
403 Forbidden User not authorized to operate on the specified resource. You are unauthorized to perform the operation on the specified resource. Acquire the required permissions and try again.

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