• Simple Message Notification

smn
  1. Help Center
  2. Simple Message Notification
  3. API Reference
  4. APIs
  5. Resource Tag Operations
  6. Adding or Deleting Resource Tags in Batches

Adding or Deleting Resource Tags in Batches

Description

  • API name

    BatchCreateOrDeleteResourceTags

  • Function

    Add or delete tags for a specified resource in batches. The TMS service may use this API to manage service resource tags.

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

    NOTE:

    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

  • URI format

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

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID

    resource_type

    Yes

    String

    Resource type

    The value can be smn_topic.

    resource_id

    Yes

    String

    Resource ID

    Obtain a resource ID:

    • Add X-SMN-RESOURCEID-TYPE=name in the request header and set the resource ID to the topic name.
    • Call the GetResourceInstances API to obtain the resource ID.

Request

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    tags

    Yes

    Resource tag structure array

    Tag list. For details, see section Resource Tag Structure.

    When you delete tags, the tag structure cannot be missing, and the key cannot be left blank or be an empty string. The system does not check the character set when deleting a tag.

    action

    Yes

    String

    Operation to be performed, which can be create or delete

  • Request example
    POST /v2/{project_id}/{resource_type}/{resource_id}/tags/action
  • Request body
    Request body when action is set to create
    {
        "action": "create",
        "tags": [
            {
                "key": "key1",
                "value": "value1"
            },
            {
                "key": "key",
                "value": "value3"
            }
        ]
    }

    Request body when action is set to delete

    {
        "action": "delete",
        "tags": [
            {
                 "key": "key1"
             },
            {
                "key": "key2",
                "value": "value3"
            }
        ]
    }

Response

None

Returned Value

  • Normal

    Returned Value

    Description

    204

    No Content

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Incorrect request parameters.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No permission to access the requested resource.

    404 Not Found

    The requested resource does not exist.

    500 Internal Server Error

    Request failed because the server is abnormal.

Error Code

See section Error Code.