All Products
Search
Document Center

Elasticsearch:TagResources

Last Updated:Sep 21, 2023

Adds tags to resources.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

This operation uses only common request headers. For more information, see Common request headers.

Request syntax

POST /openapi/tags HTTP/1.1

Request parameters

Parameter

Type

Position

Required

Example

Description

Object Body No

The information about the clusters and tags.

ResourceIds Array of String Body Yes ["es-cn-aaa","es-cn-bbb"]

The resource IDs. Use a JSON array to specify the IDs. You can specify up to 20 IDs.

Tags Array Body Yes

The tags of the instance. You can create up to 20 tags.

key String Body Yes env

The key of the tag.

value String Body Yes IT

The value of the tag.

ResourceType String Body Yes INSTANCE

The resource type. Set the value to INSTANCE.

Note
  • If you configure the key parameter, you must configure the value parameter. Otherwise, the InvalidParameter.TagKey error is reported. You can specify an empty string for the value parameter.
  • If duplicate key-value pairs are specified, the Duplicate.TagKey error is reported.
  • If a tag key you specify already exists, the tag value you specify overwrites the existing tag value.

Response parameters

Parameter

Type

Example

Description

Result Boolean true

Indicates whether tags are added to the clusters. Valid values:

  • true
  • false
RequestId String 3D8795D9-8FF5-46B2-86E6-E3B407*******

The ID of the request.

Examples

Sample requests

POST /openapi/tags HTTP/1.1
Host:elasticsearch.aliyuncs.com
Content-Type:application/json

{
    "ResourceIds":["es-cn-oew1q8bev0002****","es-cn-09k1ptccp0009****"],
    "Tags": [
        {
            "key": "env",
            "value": "IT"
        }
    ],
    "ResourceType": "INSTANCE"
}

Sample success responses

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Result" : true,
  "RequestId" : "27627E6B-E26A-406F-B6E1-0247882C****"
}

HTTP status code

For a list of error codes, see Service error codes.