Querying the Number of Resource Instances
Function
This API is used to query the number of resource instances based on tags.
Calling Method
For details, see Calling APIs.
URI
POST /v5/{project_id}/{resource_type}/resource-instances/count
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 |
|
Request
- Request parameters
Table 2 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 3 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/count { "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 5 Parameters in the response body Parameter
Type
Description
total_count
Integer
Indicates the total number of records.
- Example response
{ "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.