Obtaining Resource Quantity by Tag
Function
This API is used to collect statistics on and obtain the number of resources that meet the specified tag or resource name conditions. For example, in resource management and monitoring, you can perform exact or fuzzy search by tag or resource name to collect statistics on the number of resources. By calling this API, you can query resources based on multiple tags or resource names. If no tag is specified, the total number of resources is returned. You must have sufficient permissions and the target resource must exist. After the query is successful, the total number of resources that meet the query conditions is returned. If the query fails, an error message is returned. Common exceptions include permission verification errors, resource non-existence errors, and parameter verification errors.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
modelarts::listResourcesByTag
List
-
g:TagKeys
modelarts:tag:list
-
URI
POST /v2/{project_id}/modelarts-service-v2/resource-instances/count
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details, see Obtaining a Project ID and Name. Constraints N/A Range Project ID. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| workspace_id | No | String | Definition Workspace ID. workspaceId will be set to null. Constraints N/A Range N/A Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | Yes | String | Definition Message body type or format. Constraints N/A Range Default Value N/A |
| X-Auth-Token | Yes | String | Definition User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. For details about how to obtain the token, see Obtaining a User Token Through Password Authentication. Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| matches | No | Array of TmsMatch objects | Definition Matching item. Currently, only fuzzy match of resource names is supported. Constraints N/A |
| tags | No | Array of CombineTmsTags objects | Definition Tags for matching. Only AND operations of multiple tags are supported. If this parameter is not specified, all resources are queried. Constraints N/A |
| without_any_tag | No | Boolean | Definition Specifies whether to only query resources without tags. Constraints N/A Range true: Query only resources without tags. false: Query all resources. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition Key for matching. Currently, only resource_name is supported. Constraints N/A Range N/A Default Value N/A |
| value | Yes | String | Definition Key value, which is case-insensitive. If the key is resource_name, fuzzy search is supported. Constraints N/A Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| total_count | Integer | Definition Total number of resource instances. Range N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Range: N/A. |
| error_msg | String | Definition: Error message. Range: N/A. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Range: N/A. |
| error_msg | String | Definition: Error message. Range: N/A. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Range: N/A. |
| error_msg | String | Definition: Error message. Range: N/A. |
Status code: 404
Example Requests
This API is used to query the resource list based on the resource_name tag and matching resources whose names contain resource1. Note: Fuzzy match.
https://{endpoint}/v2/{project_id}/modelarts-service-v2/resource-instances/count
{
"matches" : [ {
"key" : "resource_name",
"value" : "service"
} ],
"tags" : [ {
"key" : "model_version",
"values" : [ "0.1", "0.2" ]
} ]
} Example Responses
Status code: 200
Definition
Response body for querying the total number of resources by tag.
{
"total_count" : 10
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Definition Response body for querying the total number of resources by tag. |
| 400 | Invalid parameter. |
| 401 | Authentication failed. |
| 403 | Insufficient permissions. |
| 404 | Resource not found. |
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