• Data Ingestion Service

dis
  1. Help Center
  2. Data Ingestion Service
  3. API Reference
  4. API Description
  5. Tag Management APIs
  6. Querying a List of Streams with Specified Tags

Querying a List of Streams with Specified Tags

Function

This API is used to filter streams by tag.

By default, streams and tags are sorted in descending order of creation time.

URI

POST /v2/{project_id}/stream/resource_instances/action

The following table describes URI parameters.

Table 1 URI parameter description

Parameter

Mandatory

Description

project_id

Yes

Project ID. For details about how to obtain the project ID, see Obtaining Project IDs.

Request

Request parameters

Table 2 Parameter description

Parameter

Mandatory

Type

Description

tags

No

List<tag>

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

List<tag>

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 must be unique and values of a key must be unique.

not_tags

No

List<tag>

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. Keys must be unique and values of a key must be unique.

not_tags_any

No

List<tag>

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.

limit

No

String

Number of records. This parameter is not available when action is set to count. The default value is 1000 when action is set to filter. The maximum value is 1000, and the minimum value is 1. The value cannot be a negative number.

offset

No

String

Index position. The query starts from the next piece of data specified by the offset parameter. This parameter is not required when you query data on the first page. The value in the response body 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.

action

Yes

String

Operation to be performed. The value can be filter or count.

The value filter indicates pagination query. The value count indicates that the total number of query results meeting the search criteria will be returned.

matches

No

List<match>

Search field. key indicates the field to be matched, for example, resource_name. value indicates the matched value. This field is a fixed dictionary value.

Determine whether fuzzy match is required based on different fields. For example, if key is resource_name, fuzzy search is used by default. If value is an empty string, exact match is used. If key is resource_id, exact match is used. Only resource_name is queried at the first phase, and other keys will be queried later.

Table 3 tag field description

Parameter

Mandatory

Type

Description

key

Yes

String

Key. It contains a maximum of 127 Unicode characters. It cannot be left empty. (This parameter is not verified in the search process.)

values

Yes

List<String>

List of values. A value contains a maximum of 255 Unicode characters.

If the values are null, it indicates any_value. The relationship between values is OR. By default, only the first value is used for search.

Table 4 match field description

Parameter

Mandatory

Type

Description

key

Yes

String

Key. Currently, only resource_name is available, indicating a cluster name. Other keys will be supported later.

value

Yes

String

Value. A value contains a maximum of 64 Unicode characters.

Response

Response parameter

The following table describes the response parameters.

Table 5 Response parameters

Parameter

Mandatory

Type

Description

resources

Yes

String

Resource list.

total_count

Yes

String

Total number of records.

Table 6 Description of the resource field data structure

Parameter

Mandatory

Type

Description

resource_id

Yes

String

Resource ID.

resource_detail

Yes

Object

Resource details. The value is a resource object used for extension. The value is left blank by default.

tags

Yes

List<resource_tag>

Tag list. This parameter is left blank by default if there is no tag.

resource_name

Yes

string

Resource name. This parameter is left blank by default if there is no resource name.

Table 7 Description of the resource_tag field data structure

Parameter

Mandatory

Type

Description

key

Yes

String

Key.

A tag key consists of a maximum of 36 characters, including A-Z, a-z, 0-9, hyphens (-), and underscores (_).

value

Yes

String

Value.

The value consists of a maximum of 43 characters, including A-Z, a-z, 0-9, periods (.), hyphens (-), and underscores (_), and can be an empty string.

Example

  • Request example

Filter request example

POST /{version}/{project_id}/{resource_type}/resource_instances/action

Request body when action is set to filter

{
  "offset": "100", 
  "limit": "100", 
"action": "filter", 
  "matches":[
{
        "key": "resource_name", 
        "value": "streamA"
       }
], 
   "not_tags": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ], 
  "tags": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ], 
  "tags_any": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ],
"not_tags_any": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ]
}

Request body when action is set to count

{
  "action": "count", 
  "not_tags": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ], 
  "tags": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    },
  {
      "key": "key2", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ], 
  "tags_any": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
  ],
"not_tags_any": [
    {
      "key": "key1", 
      "values": [
        "value1", 
        "value2"
      ]
    }
   ],
"matches":[
{
        "key": "resource_name", 
        "value": "streamA"
       }
]
}
  • Response example

Response body when action is set to filter

    { 
      "resources": [
         {
            "resource_detail": null, 
            "resource_id": "cdfs_cefs_wesas_12_dsad", 
            "resource_name": "streamA", 
            "tags": [
                {
                   "key": "key1",
                   "value": "value1"
                },
                {
                   "key": "key2",
                   "value": "value1"
                }
             ]
         }
       ], 
      "total_count": 1000
}

Response body when action is set to count

{
       "total_count": 1000
}

Status Code

Table 8 lists the status code of this API.

Table 8 Status code

Status Code

Description

200

OK