Help Center> Elastic Load Balance> API Reference> Shared Load Balancer APIs> Tag> Batch Adding or Deleting Listener Tags

Batch Adding or Deleting Listener Tags

Function

This API is used to add or delete listener tags in batches.

Constraints

  • A maximum of 10 tags can be added to a listener.
  • This API is idempotent.
  • Pay attention to the following when adding tags:
    • If there are duplicate keys in the request body, an error is reported.
    • If there are no duplicate keys in the request body but the key in the request body exists in the database, the key in the database is overwritten.
  • Pay attention to the following during the deletion:
    • If the tag to be deleted does not exist, the deletion is considered successful by default.
    • The value range of the tag character set is not verified.
    • The tag structure body cannot be missing, and the key cannot be left blank or set to an empty string.

URI

POST /v2.0/{project_id}/listeners/{listener_id}/tags/action

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the ID of the project where the tag is used.

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

listener_id

Yes

String

Specifies the ID of the listener to which tags are to be added or from which tags are to be deleted.

Request

Table 2 Parameter description

Parameter

Mandatory

Type

Description

tags

Yes

Array

Lists the tags. For details, see Table 3.

action

Yes

String

Specifies the operation identifier.

The value can be one of the following:

  • create: adds tags to the load balancer.
  • delete: deletes tags from the load balancer.
Table 3 resource_tag parameter description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the tag key.

  • Cannot be left blank.
  • Can contain a maximum of 36 characters.
  • Can contain letters, digits, underscores (_), and hyphens (-).
  • The tag key of a listener must be unique.

value

Yes

String

Specifies the tag value.

  • Can contain a maximum of 43 characters.
  • Can contain letters, digits, underscores (_), periods (.), and hyphens (-).

Response

None

Example Request

  • Example request 1
    POST https://{Endpoint}/v2.0/6a0de1c3-7d74-4f4a-b75e-e57135bd2b97/listeners/7add33ad-11dc-4ab9-a50f-419703f13163/tags/action
    
    {
        "action": "create", 
        "tags": [
            {
                "key": "key1", 
                "value": "value1"
            }, 
            {
                "key": "key2", 
                "value": "value2"
            }
        ]
    }
  • Example request 2
    POST https://{Endpoint}/v2.0/6a0de1c3-7d74-4f4a-b75e-e57135bd2b97/listeners/7add33ad-11dc-4ab9-a50f-419703f13163/tags/action
    
    {
        "action": "delete", 
        "tags": [
            {
                "key": "key1", 
                "value": "value1"
            }, 
            {
                "key": "key2", 
                "value": "value2"
            }
        ]
    }

Example Response

  • Example response 1

    None

  • Example response 2

    None

Status Code

For details, see Status Codes.