Batch Adding Tags
Function
You can use this API to add tags to multiple resources. Up to 10 tags can be added to a resource and a maximum of 50 resources can be tagged at a time.
URI
POST /v1.0/resource-tags/batch-create
Request
Parameter | Mandatory | Type | Description |
---|---|---|---|
X-Auth-Token | Yes | String | Specifies the user token. TMS is a global service. So you need to set scope to domain when calling an IAM API to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | No | String | Specifies the project ID. This parameter is mandatory when resource_type is at a region level. |
resources | Yes | Array of ResourceTagBody objects | Specifies resources. |
tags | Yes | Array of CreateTagRequest objects | Specifies tags. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
resource_id | Yes | String | Specifies the resource ID. |
resource_type | Yes | String | Specifies the resource type. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
key | Yes | String | Specifies the key. |
value | Yes | String | Specifies the value. |
Response
Status code: 200
Parameter | Type | Description |
---|---|---|
failed_resources | Array of TagCreateResponseItem objects | Specifies resources for which tags fail to be added. |
Parameter | Type | Description |
---|---|---|
resource_id | String | Specifies the resource ID. |
resource_type | String | Specifies the resource type. |
error_code | String | Error Codes |
error_msg | String | Specifies the error. |
Example Request
You can use this API to batch tag resources.
POST https://{Endpoint}/v1.0/resource-tags/batch-create{"project_id" : "xxxdcffffffff","resources" : [ {"resource_id" : "a28531fa-a8d5-468e-8417-86a80962ee5e","resource_type" : "disk"}, {"resource_id" : "a28531fa-a8d5-468e-8417-86a8096ddddd","resource_type" : "vpc"} ],"tags" : [ {"key" : "ENV","value" : "dev"}, {"key" : "DEPT","value" : "pdd"} ]}
Example Response
Status code: 200
Successful operation
{"failed_resources": []}
Status Codes
See Status Codes.
Error Codes
See Error Codes.
- Function
- URI
- Request
- Response
- Example Request
- Example Response
- Status Codes
- Error Codes