Querying Resource Pools by Tag¶
Function¶
This API is used to query resources by tag. Multiple tags can be ANDed. Fuzzy search by resource name is supported.
URI¶
POST /v1/{project_id}/pools/resource-instances/filter
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID. For details, see Obtaining a Project ID and Name. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
limit | No | Integer | Maximum number of records returned on each page. The value ranges from 1 to 1000. Minimum: 1 Maximum: 1000 Default: 1000 |
offset | No | Integer | Start page for pagination display. The default value is 0. Minimum: 0 Default: 0 |
Request Parameters¶
Parameter | Mandatory | Type | Description |
---|---|---|---|
Content-Type | No | String | Content-Type |
X-Auth-Token | Yes | String | User token |
Parameter | Mandatory | Type | Description |
---|---|---|---|
tags | No | Array of CombineTag objects | Tags. Only multiple tags can be ANDed. If this parameter is not specified, all resources are queried. |
matches | No | Array of matches objects | Matching item. Currently, only fuzzy match of resource names is supported. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
key | Yes | String | Tag key Minimum: 1 Maximum: 128 |
values | Yes | Array of strings | Merged tag values with the same key Array Length: 0 - 200 |
Parameter | Mandatory | Type | Description |
---|---|---|---|
key | Yes | String | Name of the matching item. The options are as follows:
Minimum: 1 Maximum: 128 |
value | Yes | String | Value of the matching item, no matter whether it is large or small. If key is set to resource_name, fuzzy match is used. Minimum: 0 Maximum: 255 |
Response Parameters¶
Status code: 200
Parameter | Type | Description |
---|---|---|
total_count | Integer | Total number of resources |
resources | Array of resources objects | Resource list |
Parameter | Type | Description |
---|---|---|
resource_name | String | Resource name |
resource_id | String | Resource ID |
tags | Array of Tag objects | All tags of the current resource |
Parameter | Type | Description |
---|---|---|
key | String | Tag key Minimum: 1 Maximum: 128 |
value | String | Tag value Minimum: 0 Maximum: 255 |
Status code: 400
Parameter | Type | Description |
---|---|---|
error_code | String | Error codes of ModelArts |
error_msg | String | Error message |
Status code: 401
Parameter | Type | Description |
---|---|---|
error_code | String | Error codes of ModelArts |
error_msg | String | Error message |
Status code: 403
Parameter | Type | Description |
---|---|---|
error_code | String | Error codes of ModelArts |
error_msg | String | Error message |
Status code: 404
Parameter | Type | Description |
---|---|---|
error_code | String | Error codes of ModelArts |
error_msg | String | Error message |
Example Requests¶
https://v1/{project_id}/modelarts-pool/resource-instances/filter
{
"offset" : "100",
"limit" : "100",
"matches" : [ {
"key" : "resource_name",
"value" : "resource1"
} ],
"tags" : [ {
"key" : "key1",
"values" : [ "*value1", "value2" ]
} ]
}
Example Responses¶
Status code: 200
Response to a normal request.
{
"resources" : [ {
"resource_detail" : null,
"resource_id" : "6efce7bf-677d-400f-b451-3543ed997a24",
"resource_name" : "service-79ca",
"tags" : [ {
"key" : "model_version",
"value" : "0.1"
}, {
"key" : "gpu_type",
"value" : "v100"
} ]
} ],
"total_count" : 1000
}
Status Codes¶
Status Code | Description |
---|---|
200 | Response to a normal request. |
400 | Invalid parameters. |
401 | Authentication failed. |
403 | Insufficient permission. |
404 | Resource not found. |
Error Codes¶
See Error Codes.