Querying Resource Statistics
Function
This API is used to filter resources by tag. TMS enables you to search for resources by tag and displays query results in a list. Using this API requires corresponding services to provide query capabilities. Note that there is a limit in the number of tags for fields: tags, tags_any, not_tags, and not_tags_any.
Note: This API only supports filtering Config resources by tag, and resource_type supports config:policyAssignments, config:aggregators, config:aggregationAuthorizations.
Calling Method
For details, see Calling APIs.
URI
POST /v1/resource-manager/{resource_type}/resource-instances/count
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
resource_type |
Yes |
String |
Resource type. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
without_any_tag |
No |
Boolean |
Tags to be excluded. If this parameter is set to true, all resources that do not have the specified tags will be returned. If this parameter is set to false or is not specified, resources are filtered by tags, matches, and other specified filtering criteria. Default: false |
|
tags |
No |
Array of Tag objects |
Specified tags. Up to 20 tag keys can be specified, and up to 20 values can be specified for each key. Each tag value can be an empty array, but the tag structure cannot be missing. Each tag key must be unique, and the values of the same key must be unique. Resources containing any of the specified tags will be returned. Keys in this list are in an AND relationship while values in each key-value structure is in an OR relationship.If no tag filtering condition is specified, full data is returned. |
|
matches |
No |
Array of Match objects |
Search field. A field contains a key (such as resource_name) and a value. Keys are predefined and must be unique and valid. Whether fuzzy or exact match is used is determined based on the field key. For example, exact match is used for the field key resource_name. If the field value is an empty string, exact match is used. Since very few resources have an empty-string name, an empty list is returned. Exact match is used for the field key resource_id. Currently only resource_name is supported. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
Yes |
String |
Tag key. A key can contain up to 128 Unicode characters and cannot be left blank. The system does not verify the character set of the key when searching for resources. The key element cannot be empty, an empty string, or spaces. Before using the key element, delete single-byte character (SBC) spaces before and after the value. Minimum: 1 Maximum: 128 |
|
values |
Yes |
Array of strings |
Tag values. A key can contain up to 255 Unicode characters. Before verifying or using the value element, delete single-byte character (SBC) spaces before and after the value. The value can be an empty array but cannot be left blank. If no value is specified, any values are supported. Values are in an Or relationship. The system does not verify the character set of bvaluesb when searching for resources, but only verifies the length. Maximum: 255 Array Length: 0 - 20 |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
total_count |
Integer |
The total number of records. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Specifies the error code. |
|
error_msg |
String |
Specifies the error message. |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Specifies the error code. |
|
error_msg |
String |
Specifies the error message. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Specifies the error code. |
|
error_msg |
String |
Specifies the error message. |
Status code: 404
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Specifies the error code. |
|
error_msg |
String |
Specifies the error message. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Specifies the error code. |
|
error_msg |
String |
Specifies the error message. |
Example Requests
Querying the Number of Instances By Tags
POST https://{endpoint}/v1/resource-manager/{resource_type}/resource-instances/count
{
"tags" : [ {
"key" : "key1",
"values" : [ "value1", "value2" ]
}, {
"key" : "key2",
"values" : [ "value1", "value2" ]
} ],
"matches" : [ {
"key" : "resource_name",
"value" : "resource1"
} ]
}
Example Responses
Status code: 200
Succeeded.
{
"total_count" : 1000
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Succeeded. |
|
400 |
Invalid parameter. |
|
401 |
Unauthorized. |
|
403 |
Forbidden. |
|
404 |
Resources not found. |
|
500 |
Internal server error. |
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.