Querying the Resource Instance List
Function
This API is used to query resource instances based on tags.
Calling Method
For details, see Calling APIs.
URI
POST /v5/{project_id}/{resource_type}/resource-instances/filter
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
project_id |
String |
Yes |
Specifies a project ID. You can obtain the project ID by referring to Obtaining the Project ID. |
resource_type |
String |
Yes |
|
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
limit |
Integer |
No |
|
offset |
Integer |
No |
|
Request
- Request parameters
Table 3 Request parameters Parameter
Type
Mandatory
Description
without_any_tag
Boolean
No
- When this parameter is set to true, all resources without tags are queried. In this case, the tags field is ignored. If this parameter is set to false or is not specified, all resources are queried or resources are filtered by "tags" or "matches".
tags
Array of Tag objects
No
- Specifies a tag list.
- A maximum of 20 tags can be specified.
matches
Array of Match objects
No
- Specifies a search field, including a key and a value. The match key is the field to be matched, for example, resource_name. The match value is the value to be matched. The key is a fixed dictionary value.
Table 4 Tag Parameter
Type
Mandatory
Description
key
String
Yes
- Specifies a tag key.
- The value is a string of 1 to 128 characters.
values
Array of String
Yes
- Specifies the value list of a tag. If values is an empty list, it indicates any_value. The relationship between values is OR.
- The value is a sting of 0 to 255 characters.
- A maximum of 20 values can be specified.
- Example request
POST https://{Endpoint}/v5/{project_id}/{resource_type}/resource-instances/filter { "tags": [{ "key": "key1", "values": [ "value1", "value2" ] }, { "key": "key2", "values": [ "value1", "value2" ] } ], "matches": [{ "key": "resource_name", "value": "resource1" }], "without_any_tag": "false" }
Response
- Response parameters
Returned status code 200: successful query
Table 6 Parameters in the response body Parameter
Type
Description
resources
Array of Resource objects
Indicates the resource object list.
total_count
Integer
Indicates the total number of records.
Table 7 Resource Parameter
Type
Description
resource_id
String
Indicates a resource ID.
resource_detail
object
Specifies resource details. This parameter is reserved for extension and is left empty by default.
tags
Array of ResourceTag objects
Specifies a tag list.
resource_name
String
Indicates a resource name.
- Example response
{ "resources": [{ "resource_id": "134f9fb1-demo-a8df-va86-2040a5c13325", "resource_name": "resouece1", "tags": [{ "key": "key1", "value": "value1" }] }], "total_count": 1000 }
Status Codes
For details, see Status 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