Running Advanced Queries
Function
This API is used to run advanced queries.
Calling Method
For details, see Calling APIs.
URI
POST /v1/resource-manager/domains/{domain_id}/run-query
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| domain_id | Yes | String | Specifies the account ID. Maximum: 36 |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | No | String | Specifies the invoker's token. |
| X-Security-Token | No | String | Specifies a temporary security credential. This parameter is mandatory when you make an API call using a temporary security credential. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| expression | Yes | String | Specifies the ResourceQL expression. Minimum: 1 Maximum: 4096 |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| query_info | QueryInfo object | Specifies the ResourceQL query field. |
| results | Array of objects | Specifies the ResourceQL query result. |
| Parameter | Type | Description |
|---|---|---|
| select_fields | Array of strings | Specifies the ResourceQL query field. |
Status code: 400
| 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: 429
| 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 IDs of all VMs under your account
POST https://{endpoint}/v1/resource-manager/domains/{domain_id}/run-query { "expression" : "select id from resources where provider = 'ecs' and type = 'cloudservers'" } -
Querying EVS disks with a capacity of 100 GB in the current account.
POST https://{endpoint}/v1/resource-manager/domains/{domain_id}/run-query { "expression" : "select * from resources where provider = 'evs' and type = 'volumes' and properties.size = 100" }
Example Responses
Status code: 200
Operation succeeded.
{
"query_info" : {
"select_fields" : [ "id" ]
},
"results" : [ {
"id" : "91252cc9-bfd9-0709-0912-56b397e0ba3f"
} ]
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Operation succeeded. |
| 400 | Invalid parameters. |
| 403 | User authentication failed. |
| 429 | Limit exceeded. |
| 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.