Querying Resource Tags
Function
This API is used to query tags of a resource.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
tms:resourceTags:list
List
-
-
-
-
URI
GET /v2.0/resources/{resource_id}/tags
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| resource_id | Yes | String | Specifies the resource ID. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | No | String | Specifies the project ID. This parameter is mandatory for region-specific resources. |
| resource_type | Yes | String | Specifies the resource type. This parameter is case-sensitive. Examples include: ecs, scaling_group, images, disk,vpcs, security-groups, shared_bandwidth, eip, and cdn. For more details, see "Querying Service Supported by TMS". |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Specifies the user token. TMS is a global service. When calling the Identity and Access Management (IAM) API to obtain a user token, set the scope field to domain. The value of X-Subject-Token in the response header is the user token. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| tags | Array of TagVo objects | Specifies resource tags. |
| Parameter | Type | Description |
|---|---|---|
| key | String | Specifies the tag key. The value can contain up to 36 characters including letters, digits, hyphens (-), and underscores (_). |
| value | String | Specifies the tag value. The value can contain up to 43 characters including letters, digits, periods (.), hyphens (-), and underscores (_). It can be an empty string. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 404
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 405
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 406
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 409
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 410
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 412
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 429
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 501
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Request error code |
| error_msg | String | Error message |
Status code: 503
| Parameter | Type | Description |
|---|---|---|
| error | RespErrorMessage object | Response error information. |
Example Requests
Querying tags of a resource
GET https://{Endpoint}/v2.0/resources/xxxx/tags?project_id=xxxx&resource_type=disk&resource_id=xxxx Example Responses
Status code: 200
OK
{
"tags" : [ {
"key" : "key1",
"value" : "value1"
}, {
"key" : "key2",
"value" : "value2"
} ]
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 405 | Method Not Allowed |
| 406 | Not Acceptable |
| 409 | Conflict |
| 410 | Gone |
| 412 | Precondition Failed |
| 429 | Too Many Requests |
| 500 | Internal Server Error |
| 501 | Not Implemented |
| 503 | Service Unavailable |
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.