Adding Tags to an ECS in a Batch
Function
- This API is used to add tags to a specified ECS in a batch.
- The Tag Management Service (TMS) uses this API to batch manage the tags of an ECS.
Constraints
- An ECS allows a maximum of 20 tags.
- This API is idempotent.
During tag creation, if a tag exists (both the key and value are the same as those of an existing tag), the tag is successfully processed by default.
- A new tag will overwrite the original one if their keys are the same and values are different.
- This API supports checking fine-grained permissions for enterprise projects. For details, see ecs:cloudServers:batchSetServerTags.
Debugging
You can debug this API in API Explorer.
Authorization
- If you are using role/policy-based authorization, see the required permissions in Permissions and Supported Actions.
- If you are using identity policy-based authorization, the permissions listed below are required.
Action | Access Level | Resource Type (*: required) | Condition Key | Alias | Dependencies |
|---|---|---|---|---|---|
ecs:cloudServers:batchCreateServerTags | write | instance * |
|
| - |
URI
POST /v1/{project_id}/cloudservers/{server_id}/tags/action
Parameter | Mandatory | Description |
|---|---|---|
project_id | Yes | Definition Specifies the project ID. For details about how to obtain the ID, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
server_id | Yes | Definition Specifies the ECS ID. Constraints N/A Range N/A Default Value N/A |
Request
Table 2 describes the request parameters.
Parameter | Mandatory | Type | Description |
|---|---|---|---|
tags | Yes | Array of objects | Definition Specifies tags. For details, see Table 3. Constraints N/A Range N/A Default Value N/A |
action | Yes | String | Definition Specifies the operation identifier. Constraints Only lowercase letters are supported. Range create Default Value N/A |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
key | Yes | String | Definition Specifies the tag key. Constraints
Range
Default Value N/A |
value | No | String | Definition Specifies the tag value. Constraints N/A Range
Default Value N/A |
Response
None
Example Request
Batch add two pairs of tags to a specified ECS.
POST https://{endpoint}/v1/{project_id}/cloudservers/{server_id}/tags/action
{
"action": "create",
"tags": [
{
"key": "key1",
"value": "value1"
},
{
"key": "key2",
"value": "value3"
}
]
} Example Response
None
Returned Values
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
