Help Center/ Intelligent EdgeFabric/ API Reference/ API/ Tag Management/ Adding or Deleting Resource Tags in Batches
Updated on 2023-11-23 GMT+08:00

Adding or Deleting Resource Tags in Batches

Function

This API is used to add or delete tags in batches for a specified instance.

A resource can have a maximum of 20 tags.

  • This API is an idempotent API. If the request body contains duplicate keys during tag creation, an error is reported.
  • During tag creation, duplicate key data is not allowed. If the key already exists in the database, its value is overwritten.
  • When a tag is deleted, the character set range of the tag is not verified. If the tag to be deleted does not exist, the deletion is successful by default. The tags structure cannot be missing during deletion. The key cannot be empty or an empty string.

URI

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

Table 1 Path parameters

Parameter

Type

Description

project_id

String

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

resource_type

String

Resource type.

  • ief-edge_node
  • ief-deployment
  • ief-application
  • ief-device

resource_id

String

Resource ID.

Request

Request parameters

Table 2 Parameters in the request header

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format).

The default value application/json is recommended.

X-Auth-Token

Yes

String

User token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Parameters in the request body

Parameter

Mandatory

Type

Description

tags

No

Array of resource_tag objects

List of tags.

action

Yes

String

Operation to be performed, which can be create or delete.

Table 4 resource_tag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key, which can contain a maximum of 36 Unicode characters.

This parameter cannot be left blank and can contain only letters, digits, hyphens (-), and underscores (_).

value

Yes

String

(This parameter is mandatory when action is set to create and optional when action is set to delete.)

Tag value. Each value can contain a maximum of 43 Unicode characters. If value is specified, tags are deleted by key and value. If value is not specified, tags are deleted by key.

This parameter cannot be left blank and can contain only letters, digits, hyphens (-), and underscores (_).

Example request

{
    "action": "create",
    "tags": [
        {
            "key": "key0",
            "value": "value1_new1"
        },
        {
            "key": "key1",
            "value": "value3_new"
        },
        {
            "key": "key2",
            "value": "value1_new1"
        },
        {
            "key": "key3",
            "value": "value3_new"
        },
        {
            "key": "key4",
            "value": "value1_new1"
        },
        {
            "key": "key5",
            "value": "value3_new"
        },
        {
            "key": "key6",
            "value": "value1_new1"
        },
        {
            "key": "key7",
            "value": "value3_new"
        },
        {
            "key": "key8",
            "value": ""
        }
    ]
}

Response

None

Error Codes

For details, see Error Codes.