You need to enable JavaScript to run this app.
导航

ListTagsForResources

最近更新时间2024.01.09 11:10:16

首次发布时间2022.09.02 08:52:39

调用 ListTagsForResources 接口,查询满足指定条件的标签信息。

调试

请求参数

参数名称
类型
是否必选
示例值
描述
ActionStringListTagsForResources要执行的操作,取值为ListTagsForResources。
VersionString2020-04-01API版本信息,当前版本为2020-04-01。

ResourceType

String

vpc

资源的类型,取值如下:

  • vpc:私有网络。
  • subnet:子网。
  • eni:网卡。
  • securitygroup:安全组。
  • eip:公网IP。
  • bandwidthpackage:共享带宽包。
  • ngw:NAT网关。
  • vpngateway:VPN网关。
  • directconnectconnection:物理专线。
  • directconnectgateway:专线网关。
  • directconnectvirtualinterface:虚拟接口。

ResourceIds.N

String

ResourceIds.1=vpc-273w3e33y2y9s7fap8u2j****&ResourceIds.2=vpc-bp15zckdt37pq72zv****

资源的ID。

  • 参数 - N:表示资源 ID的序号,单次调用数量上限50个。
  • 多个资源 ID之间使用&分隔。

TagType

String

custom

标签类型,取值如下:

  • custom:用户标签。
  • system:系统标签。

说明

该参数不传或传入为空时,查询全部类型的标签。

TagFilters.N.Key

String

TagFilters.1.Key=k1&TagFilters.2.Key=k2&TagFilters.3.Key=k3

标签的标签键。

  • 参数 - N:表示标签键的序号,取值范围:1~10。
  • 多个标签键之间用&分隔。多个标签键之间的关系为逻辑“与(AND)”,即查询同时添加多个标签键的资源。
  • 不允许重复。

TagFilters.N.Values.N

String

TagFilters.1.Values.1=v1&TagFilters.1.Values.2=v2&TagFilters.3.Values.1=v1

标签的标签值。

  • 第一个N:表示标签键的序号,取值范围:1~10。
  • 第二个N:表示标签值的序号,取值范围:1~3。同一标签键多个标签值之间的关系为逻辑“或(OR)”,即查询同一标签键下添加其中一个标签值的资源。
  • 多个标签值之间用&分隔。

说明

  • 若传入该参数,则必须先传入TagFilters.N.Key
  • 传入空字符串时,表示查询标签值为空的资源。
NextTokenStringcaeba0bbb2be03f84eb48b699f0a****分页查询凭证,用于标记分页的位置,初次调用该接口时无需设置。下次查询时,取值为上一次API调用返回的NextToken参数值。
MaxResultsInteger50单次查询的数量,默认为 10,最大为100。

返回数据

参数名称
类型
示例值
描述
RequestIdString2021062415303301022514515207C4****请求ID。
NextTokenStringcaeba0bbb2be03f84eb48b699f0a****本次调用返回的查询凭证值,返回为空表示没有下一页。
ResourceTagsArray of Struct-资源附加的标签信息。具体参见下表“ResourceTag结构”。

ResourceTag结构

参数名称
类型
示例值
描述
ResourceTypeStringvpc资源的类型。
ResourceIdStringvpc-273w3e33y2y9s7fap8u2j****资源的ID。
TagKeyStringk1资源附加标签的标签键。
TagValueStringv1资源附加标签的标签值。

请求示例

GET /?Action=ListTagsForResources&Version=2020-04-01&ResourceType=vpc&ResourceIds.1=vpc-273w3e33y2y9s7fap8u2j****&ResourceIds.2=vpc-bp15zckdt37pq72zv**** HTTP/1.1
Host: open.volcengineapi.com
Service: vpc
Region: cn-beijing

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "ListTagsForResources",
        "Version": "2020-04-01",
        "Service": "vpc",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "2021062415303301022514515207C4****",
        "NextToken": "caeba0bbb2be03f84eb48b699f0a****",
        "ResourceTags": [
            {
                "ResourceType": "vpc",
                "ResourceId": "vpc-273w3e33y2y9s7fap8u2j****",
                "TagKey": "k1",
                "TagValue": "v1"
            },
            {
                "ResourceType": "vpc",
                "ResourceId": "vpc-bp15zckdt37pq72zv****",
                "TagKey": "k2",
                "TagValue": "v2"
            }
        ]
    }
}

错误码

此处仅展示当前API的错误码,更多错误码请参见公共错误码

HttpCode
错误码
错误信息
描述
400LimitExceeded.ResourceYou've reached the limit on the number of resources that you can operate at one time.已达到单次可操作资源数量的上限。
400InvalidResourceType.MalformedThe specified parameter resource type is invalid.资源类型不合法。
400InvalidTagType.MalformedThe specified parameter tag type is invalid.标签类型不合法。
400InvalidTagFilterKey.MalformedThe specified parameter tag filter key is invalid.过滤标签键不合法。
400InvalidTagFilterValue.MalformedThe specified parameter tag filter value is invalid.过滤标签值不合法。
400LimitExceeded.TagFilterKeyYou've reached the limit on the number of tag keys that you can filter.已达到单次可指定过滤标签键数量的上限。
400LimitExceeded.TagFilterValueYou've reached the limit on the number of tag values that you can filter.已达到单次可指定过滤标签值数量的上限。
400InvalidNextToken.MalformedThe specified parameter NextToken is invalid.查询NextToken不合法。
400InvalidMaxResults.MalformedThe specified parameter MaxResults is malformed.查询数量不合法。
400InvalidTagFilter.DisorderThe specified index order of tag filter is malformed.指定标签过滤项的索引顺序参数格式不合法。
404InvalidResource.NotFoundThe specified resource does not exist.指定的资源不存在。