Querying ECSs by Tag (Discarded)
Function
This API is used to filter ECSs by tag and obtain all tags and resources used by an ECS.
URI
POST /v1/{project_id}/cloudservers/resource_instances/action
Parameter |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
Specifies the project ID. For details about how to obtain the ID, see Obtaining a Project ID. |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
Yes |
String |
Specifies the operation. Value filter indicates to filter ECSs by tag. The ECSs that meet the filter criteria are displayed. |
limit |
No |
String |
Limits the maximum number of queried ECSs. The value cannot be a negative number. The maximum value is 1000.
|
offset |
No |
String |
Specifies the start of the record to be returned. The value must be a number that is greater than or equal to 0. This parameter is optional when data on the first page is queried.
|
tags |
No |
Array of objects |
Displays the ECSs with all the specified tags. For details, see Table 3.
|
not_tags |
No |
Array of strings |
Displays the ECSs with none of specified tags.
|
matches |
No |
Array of objects |
Specifies the search field, which is used to search for ECSs. Currently, only resource_name can be used for search. For more information, see Table 4. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the tag key.
|
values |
Yes |
Array of strings |
Specifies tag values.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the key field to be matched. The tag key can only be resource_name. In such a case, the tag value is the ECS name.
|
value |
Yes |
String |
Specifies the tag value. The tag key can only be resource_name. In such a case, the tag value is the ECS name.
|
Response
Response parameters
Table 5 describes the response parameters.
Parameter |
Type |
Description |
---|---|---|
resources |
Array of objects |
Specifies returned ECSs. For details, see Table 6. |
total_count |
Integer |
Specifies the total number of queried ECSs. |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
Specifies the ECS ID. |
resource_detail |
String |
Reserved |
tags |
Array of objects |
Lists tags. |
resource_name |
String |
Specifies the resource name, which is the ECS name. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the tag key.
|
value |
String |
Specifies the tag value.
|
Examples
- Example request
POST https://{endpoint}/v1/{project_id}/cloudservers/resource_instances/action
{ "offset": "100", "limit": "1", "action": "filter", "matches":[ { "key": "resource_name", "value": "ecs_test" }], "tags": [ { "key": "key1", "values": [ "value1", "value2" ] }] }
- Example response
{ "resources": [ { "resource_detail": null, "resource_id": "31760ffa-6711-406d-bc94-bce4ae925a8a", "resource_name": "ecs_test", "tags": [ { "key": "key1", "value": "value1" } ] } ], "total_count": 1000 }
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.