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

CreateTags

最近更新时间2024.04.16 14:15:07

首次发布时间2022.09.02 08:59:16

调用 CreateTags 接口为一个或多个资源添加用户标签。

说明

  • 标签的更多信息请参见标签概述
  • 单个资源最多可以添加50个标签,单次调用该接口最多支持添加20个标签。
  • 为同一个资源重复添加相同标签键的标签,则新标签值会自动覆盖原标签值。
  • “删除中”的资源不允许添加标签。

调试

请求参数

名称类型是否必填示例值描述
ActionStringCreateTags要执行的操作,取值:CreateTags。
VersionString2020-04-01API的版本,取值:2020-04-01。

ResourceType

String

instance

资源类型,取值:

  • instance:实例

  • image:镜像

  • reservedinstance:预留实例券

  • scheduledinstance:弹性预约实例

    说明

    弹性预约实例正在邀测中,如需试用,请联系客户经理申请。

ResourceIds.N

String

ResourceIds.1=i-l8u0p77yseabkpak****&ResourceIds.2=i-l8u0p7xyseabkbak****

资源ID。

  • 参数 - N:表示资源的序号,取值范围:1~50。
  • 多个资源之间用&分隔。

Tags.N.Key

String

Tags.1.Key=k1

为资源添加的用户标签的标签键。

  • 参数 - N:表示标签键的序号,取值范围:1~20。

  • 多个标签键之间用&分隔。

命名规则如下:
  • 不能以任何大小写形式的volc:sys:开头。

    volc:sys:开头为系统预留标签键禁止创建。

  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。

  • 长度限制在1~128个字符之间。

Tags.N.Value

String

Tags.1.Value=v1

为资源添加的用户标签的标签值。

  • 参数 - N:表示标签值的序号,取值范围:1~20。

  • 多个标签值之间用&分隔。

命名规则如下:
  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。

  • 允许为空,长度限制在0~256个字符之间。

ClientToken

String

333456899ff****

保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。
取值:仅支持ASCII字符,且不能超过64个字符。

返回数据

名称类型示例值描述

OperationDetails

Array of Struct

-

操作详情,具体请参见下表“ OperationDetails结构 ”。

OperationDetails结构

名称类型示例值描述

Error

Struct

-

操作的资源错误信息,具体请参见下表“ Error结构 ”。

ResourceIdStringi-l8u0p77yseabkpak****操作的资源ID。

Error结构

名称类型示例值描述
CodeStringInvalidResourceId.NotFound批量操作时具体单个请求失败的错误码,具体请参见下表“ 错误码(批量操作时具体单个请求失败)”。
MessageStringThe specified ResourceId does not exist.批量操作时具体单个请求失败的错误信息,具体请参见下表“ 错误码(批量操作时具体单个请求失败)”中的错误信息。

错误码(批量操作时具体单个请求失败)

错误码错误信息描述
InvalidResourceId.NotFoundThe specified ResourceId does not exist.指定的资源不存在。
InvalidResourceStatusThe status of the specified resource does not support this request.当前资源的状态不支持此操作。

OperationDenied.ResourceLocked

The specified operation is denied as your resource is locked for another operation.

指定的操作被拒绝,因为您的资源已被其他操作锁定。

InternalErrorAn internal error has occurred.内部错误,请重试。如果多次尝试失败,请提交工单。
FlowLimitExceededYou've reach the limit on request rate of resources.您已超过资源请求限速。

请求示例

GET /?Action=CreateTags&Version=2020-04-01&ResourceType=instance&ResourceIds.1=i-l8u0p77yseabkpak****&ResourceIds.2=i-l8u0p7xyseabkbak****&Tags.1.Key=k1&Tags.1.Value=v1 HTTP/1.1
Host: open.volcengineapi.com
Region: cn-beijing
ServiceName: ecs

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "CreateTags",
        "Version": "2020-04-01",
        "Service": "ecs",
        "Region": "cn-beijing"
    },
    "Result": {
        "OperationDetails": [
            {
                "Error": null,
                "ResourceId": "i-l8u0p77yseabkpak****"
            },
            {
                "Error": {
                    "Code": "InvalidResourceId.NotFound",
                    "Message": "The specified ResourceId does not exist."
                },
                "ResourceId": "i-l8u0p7xyseabkbak****"
            }
        ]
    }
}

错误码

HttpCode错误码错误信息描述
400InvalidArgumentThe specified argument is invalid.指定的参数不合法。
400QuotaExceeded.MaximumTagsYou've reached the limit on the number of Tags that you can create.已达到单个资源可创建标签上限。
400LimitExceeded.MaximumResourceIdsYou've reached the limit on the number of ResourceIds that you can set.指定的资源ID数量超过最大限制。
400LimitExceeded.MaximumTagsYou've reached the limit on the number of tags that you can create.指定的标签数量超过最大限制。
400InvalidTagKey.MalformedThe specified TagKey is malformed.指定的标签键不合法。
400InvalidTagValue.MalformedThe specified TagValue is malformed.指定的标签值不合法。
400InvalidClientToken.MalformedThe specified ClientToken is malformed.指定的ClientToken不合法。
400IdempotentParameterMismatchThe request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.幂等参数不一致。
404InvalidResourceType.NotFoundThe specified ResourceType does not exist.指定的资源类型不存在。
404InvalidResourceId.NotFoundThe specified ResourceId does not exist.指定的资源不存在。
404InvalidTag.NotFoundThe specified tag does not exist.指定的标签不存在。
409InvalidTagKey.ConflictThe specified TagKey already exists.指定的标签键已存在。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.先前的幂等请求仍在处理中,请稍后重试。
500InternalErrorAn internal error has occurred.内部错误,请重试。如果多次尝试失败,请提交工单。