Querying Resources by Tag
Description
This API is used to query the specified DB instances by tag.
Restrictions
A maximum of 10 tags can be added to a DB instance. The tag key must be unique.
|
Name |
Type |
IN |
Mandatory |
Description |
|---|---|---|---|---|
|
project_id |
string |
path |
Yes |
Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID. |
Request Parameters
|
Parameter |
Type |
IN |
Mandatory |
Description |
|---|---|---|---|---|
|
X-Auth-Token |
string |
header |
Yes |
User token |
|
Parameter |
Type |
Mandatory |
Description |
|---|---|---|---|
|
offset |
String |
No |
The index position. The query starts from the next piece of data indexed by this parameter.
|
|
limit |
String |
No |
The number of resources to be queried.
|
|
action |
String |
Yes |
The operation identifier.
|
|
matches |
Array of objects |
No |
The search field.
|
|
tags |
Array of objects |
No |
The included tags. Each tag contains a maximum of 10 keys. For more information, see Table 4. |
|
Parameter |
Type |
Mandatory |
Description |
|---|---|---|---|
|
key |
String |
Yes |
The tag key.
NOTE:
The character set of this parameter is not verified in the search process. |
|
values |
Array of strings |
Yes |
Lists the tag values.
If the values are null, it indicates querying any value. The values are in OR relationship. |
|
Parameter |
Type |
Mandatory |
Description |
|---|---|---|---|
|
key |
String |
Yes |
The query criteria. The value can be instance_name or instance_id, indicating that the query is based on the instance name or instance ID. |
|
value |
String |
Yes |
The name or ID of the DB instance to be matched. You can call the API for querying DB instances to obtain the DB instance name or ID. If you do not have an instance, you can call the API used for creating an instance. |
- Request example
Query specified DB instances by tag.
{ "offset": "100", "limit": "100", "action": "filter", "matches": [ { "key": "instance_name", "value": "test-single" } ], "tags": [ { "key": "key1", "values": [ "value1", "value2" ] } ] }Query the total number of resources.{ "action": "count", "tags": [ { "key": "key1", "values": [ "value1", "value2" ] }, { "key": "key2", "values": [ "value1", "value2" ] } ], "matches": [ { "key": "instance_name", "value": "test-single" }, { "key": "instance_id", "value": "958693039f284d6ebfb177375711072ein02" } ] }
Response Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
instances |
Array of objects |
The instance list. For details, see Table 7. |
|
total_count |
Integer |
The total number of queried records. |
|
Parameter |
Type |
Description |
|---|---|---|
|
instance_id |
String |
The instance ID, which can be obtained by calling the API for querying instances. If you do not have an instance, you can call the API used for creating an instance. |
|
instance_name |
String |
The DB instance name. |
|
tags |
Array of objects |
The tag list. If there is no tag in the list, tags is taken as an empty array. For more information, see Table 8. |
|
Parameter |
Type |
Description |
|---|---|---|
|
key |
String |
The tag key.
Character set: 0-9, A-Z, a-z, "_", and "-". |
|
value |
String |
The tag value.
Character set: 0-9, A-Z, a-z, "_", ".", and "-". |
- Example response
Return specified DB instances by tag.
{ "instances": [ { "instance_id": "2acbf2223caf3bac3c33c6153423c3ccin02", "instance_name": "test-single", "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value1" } ] } ] }Number of returned records.
{ "total_count": 4 }
Status Code
For details, see Status Code.
Error Code
For details, see Error Code.
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