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

TagResources

最近更新时间2024.03.22 08:30:20

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

调用 TagResources 接口,为资源添加用户标签。

调用说明

  • 为同一个资源重复添加相同标签键的标签,则后添加的标签值会自动覆盖之前的标签值。
  • 每个资源最多可添加50个标签,每次调用该接口最多可添加20个标签。

调试

请求参数

参数名称
类型
是否必选
示例值
描述
ActionStringTagResources要执行的操作,取值为TagResources。
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之间使用&分隔。

Tags.N.Key

String

Tags.1.Key=k1&Tags.2.Key=k2

用户标签的标签键(Key)。

  • 参数 - N:表示标签键(Key)的序号,取值范围:1~20。
  • 多个标签键(Key)之间用&分隔。
  • 不能以 volc:sys开头,包括任意大小写形式。
  • 长度取值范围为1~128字符,允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 若标签键开头或结尾存在空格,系统会自动为其去除。

说明

同一资源的标签键不允许重复。

Tags.N.Value

String

Tags.1.Value=v1&Tags.2.Value=v2

用户标签的标签值(Value)。

  • 参数 - N:表示标签值(Value)的序号,取值范围:1~20。
  • 多个标签值(Value)之间用&分隔。
  • 长度取值范围为0~256字符,不填默认为空。
  • 允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 大小写敏感。
  • 若标签值(Value)开头或结尾存在空格,系统会自动为其去除。

说明

如果传入该参数,则必须先传入Tags.N.Key

返回数据

参数名称
类型
示例值
描述
RequestIdString2021062415303301022514515207C4****请求ID。

请求示例

GET /?Action=TagResources&Version=2020-04-01&ResourceType=vpc&ResourceIds.1=vpc-273w3e33y2y9s7fap8u2j****&ResourceIds.2=vpc-bp15zckdt37pq72zv****&Tags.1.Key=k1&Tags.2.Key=k2&Tags.1.Value=v1&Tags.2.Value=v2 HTTP/1.1
Host: open.volcengineapi.com
ServiceName: vpc
Region: cn-beijing

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "TagResources",
        "Version": "2020-04-01",
        "Service": "vpc",
        "Region": "cn-beijing"
    },
    "Result": {
        "RequestId": "2021062415303301022514515207C4****"
    }
}

错误码

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

HttpCode
错误码
错误信息
描述
400InvalidTagKey.MalformedThe specified parameter tag key is invalid.标签键不合法。
400InvalidTagValue.MalformedThe specified parameter tag value is invalid.标签值不合法。
400LimitExceeded.TagsYou've reached the limit on the number of tags that you can operate at one time.已达到单次可操作标签数量的上限。
400LimitExceeded.ResourceYou've reached the limit on the number of resources that you can operate at one time.已达到单次可操作资源数量的上限。
400InvalidResource.NotFoundThe specified resource does not exist.指定的资源不存在。
400InvalidResourceType.MalformedThe specified parameter resource type is invalid.资源类型不合法。
400QuotaExceeded.ResourceTagsYou've reached the limit on the number of resource tags that you can create.已达到单个资源可创建用户标签的数量的配额上限。
400QuotaExceeded.ResourceSystemTagsYou've reached the limit on the number of system tags that you can create.已达到单个资源可创建系统标签的数量的配额上限。
400InvalidTag.DisorderThe specified index order of tag is malformed.指定标签的索引顺序参数格式不合法。
404InvalidResource.NotFoundThe specified resource does not exist.指定的资源不存在。