Querying the Number of Resource Instances by Tag
Function
Querying the Number of Resource Instances by Tag
URI
POST /v1/{project_id}/{resource_type}/resource-instances/count
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
** Parameter description**: Specifies the project ID. You can obtain the value by calling the IAM API for querying the project list of a specified IAM user. ** Restrictions**: N/A ** Value range**: The value is subject to the return value of the IAM service interface. The value contains 32 to 64 characters. ** Default value**: N/A |
resource_type |
Yes |
String |
Definition: Resource type ** Restrictions**: N/A Range:
** Default value**: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
** Parameter description**: User token. You can obtain the token by calling the IAM API used to query the user token. The token is the value of X-Subject-Token in the response header. ** Restrictions**: N/A ** Value range**: Used by the IAM service to query the user token. ** Default value**: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
matches |
No |
Array of matches objects |
Specifies the search criteria. The tag key is the parameter to match, for example, resource_name. value indicates the value that the field needs to match. The key is a fixed dictionary value and cannot contain duplicate keys or unsupported keys. Check whether fuzzy match is required based on the key value. For example, if key is set to resource_name, fuzzy search (case-insensitive) is performed by default. If value is empty, exact match is performed. Most services do not have resources without names. In this case, an empty list is returned. If key is set to resource_id, exact match is used. Only resource_name for key is supported. Other key values will be available later. |
not_tags |
No |
Array of TagKeyValuesBean objects |
The resources to be queried do not contain tags listed in not_tags. Each resource to be queried contains a maximum of 50 keys. Each tag key can have a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each tag key and each value of the same tag key must be unique. The response returns resources containing no tags in this list. Keys in this list are in an AND relationship while values in each key-value structure are in an OR relationship. If no tag filtering condition is specified, full data is returned. |
tags |
No |
Array of TagKeyValuesBean objects |
Clusters with tags. A cluster with tags can contain a maximum of 50 keys. Each key can have a maximum of 10 values. The value of each key can be an empty array, but it must be included in the tag structure. Each tag key and each value of the same tag key must be unique. The response returns resources containing all tags in this list. Keys in this list are in the AND relationship and values in each key-value structure are in the OR relationship. If no tag filtering condition is specified, full data is returned. |
tags_any |
No |
Array of TagKeyValuesBean objects |
The resources to be queried contain any tags listed in tags_any. Each resource to be queried contains a maximum of 50 keys. Each tag key can have a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each tag key and each value of the same tag key must be unique. The response returns instances containing any tag in this list. Keys in this list are in the OR relationship and values in each key-value structure are also in the OR relationship. If no tag filtering condition is specified, full data is returned. |
not_tags_any |
No |
Array of TagKeyValuesBean objects |
The resources to be queried do not contain any tags listed in not_tags_any. Each resource to be queried contains a maximum of 50 keys. Each tag key can have a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Each tag key and each value of the same tag key must be unique. The response returns resources containing no tag in this list. Keys in this list are in the OR relationship and values in each key-value structure are also in the OR relationship. If no tag filtering condition is specified, full data is returned. |
sys_tags |
No |
Array of TagKeyValuesBean objects |
Only users with the op_service permission can use this field to filter resources.Only one tag structure is contained when this API is called by Tag Management Service (TMS).The key is fixed at _sys_enterprise_project_id.The value is the ID of an enterprise project.Currently, each key can contain only one value. 0 indicates the default enterprise project.sys_tags and tenant tag filtering conditions (without_any_tag, tags, tags_any, not_tags, and not_tags_any) cannot be used at the same time.If sys_tags is unavailable, the tag interface is used for processing. If no tag filtering condition is available, full data is returned. |
without_any_tag |
No |
Boolean |
Clusters without any tags. If this field is set to true, all resources without tags are queried. In this case, the tags, tags_any, not_tags, and not_tags_any fields are ignored. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Key. Only resource_name is supported. |
value |
No |
String |
Value, which is the name of the resource to be matched. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Key. It can contain a maximum of 128 Unicode characters. The tag key cannot be left blank. (The character set of this parameter is not verified during search.) The key cannot be left blank or set to an empty string. Spaces are not allowed. Before verification or usage, delete the single-byte character (SBC) before and after the key. |
values |
Yes |
Array of strings |
List of tag values. Each value can contain a maximum of 255 Unicode characters. Before verification and usage, delete SBC spaces before and after the value. The value can be an empty array but cannot be left blank. If values is left empty, it indicates any value. The values are in the OR relationship. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
resources |
Array of resources objects |
Resource instance list. |
total_count |
Integer |
Specifies the total number of records. |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
Resource id |
resource_name |
String |
Resource name, which is an empty string by default if the resource does not have a name. If the resource is an EIP, the IP address is returned. |
resource_detail |
Object |
Resource details. This field is reserved for subsequent extension, and its value defaults to an empty string. |
tags |
Array of tags objects |
Tag list. If there is no tag, an empty array is used by default. |
sys_tags |
Array of sys_tags objects |
Only the op_service permission can obtain this field. Only one resource_tag structure is included currently. The key is fixed at _sys_enterprise_project_id. value: enterprise project ID. The value 0 indicates the default enterprise project. This field is not returned for the non-op_service permission. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
details |
Array of DbssErrorDetail objects |
PDP5 authentication exception information |
encoded_authorization_message |
String |
PDP5 authentication exception information |
error_code |
String |
Error Codes |
error_msg |
String |
Error message. |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
PDP5 error information |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
details |
Array of DbssErrorDetail objects |
PDP5 authentication exception information |
encoded_authorization_message |
String |
PDP5 authentication exception information |
error_code |
String |
Error Codes |
error_msg |
String |
Error message. |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error Codes |
error_msg |
String |
PDP5 error information |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
details |
Array of DbssErrorDetail objects |
PDP5 authentication exception information |
encoded_authorization_message |
String |
PDP5 authentication exception information |
error_code |
String |
Error Codes |
error_msg |
String |
Error message. |
Example Requests
/v1/{project_id}/{resource_type}/resource-instances/count { "matches" : [ { "key" : "resource_name", "value" : "resource1" } ], "not_tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags_any" : [ { "key" : "key1", "values" : [ "value1", "value2" ] } ], "not_tags_any" : [ { "key" : "key1", "values" : [ "value1", "value2" ] } ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "values" : [ "5aa119a8-d25b-45a7-8d1b-88e127885635" ] } ] }
Example Responses
Status code: 200
Success
{ "total_count" : 1000 }
Status Codes
Status Code |
Description |
---|---|
200 |
Success |
400 |
Failed |
403 |
Authorization failed. |
500 |
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot