Updated on 2022-08-12 GMT+08:00

Adding or Deleting Cluster Tags in Batches

Function

This API is used to add or delete tags to or from a specified cluster in batches.

You can add a maximum of 10 tags to a cluster.

This API is idempotent.

  • If a tag to be created has the same key as an existing tag in a cluster, the tag will overwrite the existing one.
  • When tags are being deleted and some tags do not exist, the operation is considered successful by default. The character set of the tags will not be checked. A key and a value can respectively contain up to 36 and 43 Unicode characters. When tags are deleted, the tag structure body cannot be missing, and the key cannot be left blank or set to an empty string.

URI

  • Format

    POST /v1.1/{project_id}/clusters/{cluster_id}/tags/action

  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID. For details on how to obtain the project ID, see Obtaining a Project ID.

    cluster_id

    Yes

    Cluster ID

Request

Table 2 Request parameter description

Parameter

Mandatory

Type

Description

action

Yes

String

Operation to be performed. The value can be set to create or delete only.

tags

Yes

List<resource_tag>

Tag list. For details about the parameter, see Table 3.

Table 3 tags parameter description

Parameter

Mandatory

Type

Description

key

Yes

String

Key.

value

Yes

String

Tag value.

Note:

  • This parameter is mandatory for adding a tag.
  • This parameter is optional for deleting a tag.

Response

Response parameters

None.

Example

  • Example request
{ 
    "action": "create", 
    "tags": [ 
        { 
            "key": "key1", 
            "value": "value1" 
        }, 
        { 
            "key": "key", 
            "value": "value3" 
        } 
    ] 
} 
  • Example response

    None.

Status Code

Table 4 describes the status code of this API.

Table 4 Status code

Status Code

Description

204

The operation is successful.