Querying Resources
Function
This API is used to query resources.
URI
POST /v1/{project_id}/{resource_type}/resource_instances/action
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
resource_type |
Yes |
String |
Specifies the resource type. cph-server: cloud phone server |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the user token. It can be obtained by calling an Identity and Access Management (IAM) API. The value of X-Subject-Token in the response header is the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
Yes |
String |
Specifies the operation to be performed. The operation can be filter or count. filter indicates pagination query. count indicates that the total number of query results meeting the search criteria will be returned. |
offset |
No |
String |
Specifies where the query starts. The query starts from the next data record indexed by this parameter. You do not need to specify this parameter when querying resources on the first page. When you query resources on subsequent pages, set this parameter to the location returned in the response body for the previous query.If you set action to count, this parameter is not required.If you set action to filter, offset is 0 by default. The offset value must be a positive number. |
limit |
No |
String |
Specifies the maximum number of records to be queried. If you set action to count, this parameter is not required. If you set action to filter, this parameter takes effect. The value ranges from 1 to 1000 (default). |
without_any_tag |
No |
Boolean |
Specifies any tag that is not contained. If this parameter is set to true, all resources without tags are queried. |
tags |
No |
Array of Tags objects |
A maximum of 10 tag keys are allowed in each query operation. Each tag key can have up to 10 tag values. The structure body is mandatory. The tag key cannot be left blank or be an empty string. Each tag key and values of each key must be unique. Resources identified by different keys are in AND relationship. |
matches |
No |
Array of Match objects |
Specifies the key-value pair to be matched. The key can only be resource_name. The value will be exactly matched. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Specifies the tag key.
|
values |
Yes |
Array of strings |
Specifies the tag value list.
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
resources |
Array of Resource objects |
Lists the resources. |
total_count |
Integer |
Total number of resources |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
Specifies the resource ID. |
resource_detail |
String |
Specifies resource details. |
resource_name |
String |
Specifies the resource name. |
tags |
Array of Tag objects |
Specifies the resource name. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the tag key.
|
value |
String |
Specifies the list of tag values.
|
Example Requests
-
Querying the number of resources
Post https://{CPH Endpoint}/v1/{project_id}/{resource_type}/resource_instances/action { "action" : "count", "tags" : [ { "key" : "key1", "values" : [ "value1", "value2" ] }, { "key" : "key2", "values" : [ "value1", "value2" ] } ], "matches" : [ { "key" : "resource_name", "value" : "resource1" } ] }
-
Querying resources
Post https://{CPH Endpoint}/v1/{project_id}/{resource_type}/resource_instances/action { "offset" : "100", "limit" : "100", "action" : "filter", "tags" : [ { "key" : "key1", "values" : [ "value1", "value2" ] }, { "key" : "key2", "values" : [ "value1", "value2" ] } ], "matches" : [ { "key" : "resource_name", "value" : "resource1" } ] }
Example Responses
Status code: 200
ok
{ "resources" : [ { "resource_detail" : null, "resource_id" : "cdfs_cefs_wesas_12_dsad", "resource_name" : "resouece1", "tags" : [ { "key" : "key1", "value" : "value1" }, { "key" : "key2", "value" : "value1" } ] } ], "total_count" : 1000 }
Status Codes
Status Code |
Description |
---|---|
200 |
ok |
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