Updated on 2024-04-12 GMT+08:00

Adding a Tag

Function

Add a tag.

URI

POST /v1/{project_id}/{resource_type}/{resource_id}/tags/action

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.

Minimum length: 1 character.

Maximum length: 64 characters.

resource_type

Yes

String

Resource type.

resource_id

Yes

String

Resource ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum length: 1 character.

Maximum length: 10,000 characters.

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Minimum length: 30 characters.

Maximum length: 30 characters.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Method of adding tags.

is_open

No

Boolean

Whether to invoke external APIs.

tags

Yes

Array of tagsBody objects

Tag field information.

Table 4 tagsBody

Parameter

Mandatory

Type

Description

key

No

String

Tag key.

value

No

String

Tag value.

Response Parameters

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 36

error_msg

String

Error description.

Minimum: 2

Maximum: 512

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 36

error_msg

String

Error description.

Minimum: 2

Maximum: 512

Example Requests

/v1/2a473356cca5487f8373be891bffc1cf/groups/0933a172-379e-44d0-9ed9-f491b1c528ea/tags/action

{
  "action" : "create",
  "is_open" : false,
  "tags" : [ {
    "key" : "zzz",
    "value" : "zzz"
  }, {
    "key" : "sgq",
    "value" : "123"
  } ]
}

Example Responses

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "error_code" : "LTS.1836",
  "error_msg" : "action is create or delete"
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.0203",
  "error_msg" : "Internal Server Error"
}

Status Codes

Status Code

Description

201

The tag is added.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.