• Domain Name Service

dns
  1. Help Center
  2. Domain Name Service
  3. API Reference
  4. API Description
  5. Tag Management
  6. Adding or Deleting Resource Tags in Batches

Adding or Deleting Resource Tags in Batches

Function

Add or delete tags for a specified resource in batches.

Tag Management Service (TMS) may use this API to manage service resource tags.

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

The API is idempotent.

  • When you are to create tags, if there are duplicate keys in the request body, an error is reported.

    If a to-be-created tag has the same key as an existing tag, the tag will be created and 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.

URI

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

For details, see Table 1.
Table 1 Parameters in the URI

Parameter

Mandatory

Type

Description

project_id

Yes

string

Project ID of the tenant

resource_type

Yes

string

Resource type, which can be DNS-public_zoneDNS-private_zoneDNS-public_recordsetDNS-private_recordset, or DNS-ptr_record

resource_id

Yes

string

Resource ID

Request

  • Parameter description
    Table 2 Parameters in the request

    Parameter

    Mandatory

    Type

    Description

    tags

    Yes

    List<tag>

    Tag list. The tag list structure cannot be empty when you delete tags.

    action

    Yes

    string

    Operation, which can be create or delete (case sensitive)

    Table 3 Parameters in the tag list

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    string

    Tag key, which cannot be left blank or be an empty string. It can contain only digits, letters, hyphens (-), and underscores (_).

    When action is set to create, the key contains 36 Unicode characters at most.

    When action is set to delete, the key contains 127 Unicode characters at most.

    value

    No

    string

    Tag value, which can be an empty string. It can contain only digits, letters, hyphens (-), and underscores (_).

    When action is set to create, the tag value is mandatory and contains 43 Unicode characters at most.

    When action is set to delete, the tag value is optional and contains 255 Unicode characters at most. If you leave it blank, tags are deleted by key.

  • Example request
    {
        "action": "create",
        "tags": [
            {
                "key": "key1",
                "value": "value1"
            },
            {
                "key": "key2",
                "value": "value2"
            }
        ]
    }
    or
    {
        "action": "delete",
        "tags": [
            {
                "key": "key1",
                "value": "value1"
            },
            {
                "key": "key2",
                "value": "value2"
            }
        ]
    }

Response

None

Returned Value

  • Normal
    Table 4 Return code for successful requests

    Returned Value

    Description

    204

    No Content

  • Abnormal
    Table 5 Return code for failed requests

    Returned Value

    Description

    400

    Invalid tag.

    401

    Authentication failed.

    403

    Insufficient permission.

    404

    The requested resource was not found.

    500

    An exception occurs in the system.