Using Tags to Filter Resources (Streams)
Function
This API is used to filter resources (streams) by tag.
URI
POST /v2/{project_id}/stream/resource_instances/action
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token The token 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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
Yes |
String |
Operation to be performed.
Enumeration values:
|
limit |
No |
String |
Number of queried records. This parameter is not displayed if action is set to count. The default value is 1000 if action is set to filter. The value must be an integer ranging from 1 to 1000. Default: 1000 |
offset |
No |
String |
Index position. The query starts from the next data record indexed by this parameter. This parameter is not required when you query data on the first page. The value in the response returned for querying data on the previous page will be included in this parameter for querying data on subsequent pages. This parameter is not available when action is set to count. If action is set to filter, the value must be a number, and the default value is 0. The value cannot be a negative number. |
tags |
No |
Array of Tags objects |
The return result contains resources corresponding to all tags in this parameter. This parameter contains a maximum of 10 keys, and each key contains a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. |
tags_any |
No |
Array of Tags objects |
The return result contains resources corresponding to any tag in this parameter. This parameter contains a maximum of 10 keys, and each key contains a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Keys and the values of a key must be unique. |
not_tags |
No |
Array of Tags objects |
The return result does not contain resources corresponding to all tags in this parameter. This parameter contains a maximum of 10 keys, and each key contains a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Each tag key must be unique, and the tag values of one key must also be unique. |
not_tags_any |
No |
Array of Tags objects |
The return result does not contain resources corresponding to any tag in this parameter. This parameter contains a maximum of 10 keys, and each key contains a maximum of 10 values. The structure body cannot be missing, and the key cannot be left blank or set to an empty string. Keys must be unique and values of a key must be unique. |
matches |
No |
String |
Search criteria. The tag key is the field to match. Currently, only resource_name is supported. value indicates the matched value. This field is a fixed dictionary value. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Key
Maximum: 36 |
values |
No |
Array of strings |
List of tag values If values is an empty list, it indicates any_value. The values are in the OR relationship. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
resources |
Array of Tags objects |
Resource List. |
total_count |
Integer |
Array of Tags objects. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Key
Maximum: 36 |
values |
Array of strings |
List of tag values If values is an empty list, it indicates any_value. The values are in the OR relationship. |
Example Requests
- Resource (stream) filtering by tag and record querying
POST https://{Endpoint}/v2/{project_id}/stream/resource_instances/action { "action" : "count", "tags" : [ { "key" : "key1", "values" : [ "value1", "value2" ] }, { "key" : "key2", "values" : [ "value1", "value2" ] } ], "matches" : [ { "key" : "resource_name", "value" : "resource1" } ] }
- Resource (stream) filtering by tag and querying by page.
POST https://{Endpoint}/v2/{project_id}/stream/resource_instances/action { "offset" : "0", "limit" : "100", "action" : "filter", "matches" : [ { "key" : "resource_name", "value" : "resource1" } ], "tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ] }
Example Responses
Status code: 200
Request body for filtering resources (streams) by tag.
{ "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 |
Request body for filtering resources (streams) by tag. |
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