Updated on 2024-10-31 GMT+08:00

Querying Network ACLs Using Tags

Function

This API is used to query network ACLs using tags.

Debugging

You can debug this API through automatic authentication in API Explorer.

URI

POST /v3/{project_id}/firewalls/resource-instances/filter

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Number of records to be queried.

The value can be from 1 to 1000.

The default value is 1000.

Default: 1000

offset

No

Integer

The index position. The query starts from the next piece of data indexed by this parameter.

The value is 0 by default, indicating that the query starts from the first piece of data. The value cannot be a negative number.

Default: 0

Request Parameters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

matches

No

Array of Match objects

The key-value pair to be matched in the query. The key is a fixed dictionary value and must be a unique and supported key. The key can only be resource_name.

tags

No

Array of ListTag objects

The resources to be queried contain all tags listed in tags. A maximum of 50 tags can be specified. Each tag key can have a maximum of 10 tag values. Each tag value can be an empty array but the structure cannot be missing. Each tag key must be unique, and each tag value of a tag must also be unique. Resources with all tags listed in tags will be returned. Keys in this list are in an AND relationship while values in each key-value structure are in an OR relationship. If tags is not specified, all resources will be returned.

Table 4 Match

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key. Currently, the tag key can only be the resource name.

Minimum: 1

Maximum: 128

value

Yes

String

Tag value. Each value can contain a maximum of 255 Unicode characters.

Minimum: 0

Maximum: 255

Table 5 ListTag

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key.

The key cannot be left blank.

Minimum: 1

Maximum: 128

values

Yes

Array of strings

Tag values. If values is left blank, it indicates any_value (querying any value). The values are in the OR relationship.

Maximum: 255

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

resources

Array of ListResourceResp objects

Resources

total_count

Integer

Resource quantity

request_id

String

Request ID

Table 7 ListResourceResp

Parameter

Type

Description

resource_id

String

Resource ID

resource_detail

Object

Resource details that are used for extension. This parameter is left blank by default.

resource_name

String

Resource name. This parameter is an empty string by default if there is no resource name.

tags

Array of ResourceTag objects

A list of tags for queried resources to match against. This parameter is an empty array by default if there is no tag.

Table 8 ResourceTag

Parameter

Type

Description

key

String

  • Tag key

  • Tag keys must be unique for each resource.

Minimum: 1

Maximum: 128

value

String

  • Tag value.

Maximum: 255

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

error_msg

String

Error message.

error_code

String

Error code.

Status code: 401

Table 10 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

error_msg

String

Error message.

error_code

String

Error code.

Status code: 403

Table 11 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

error_msg

String

Error message.

error_code

String

Error code.

Status code: 404

Table 12 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

error_msg

String

Error message.

error_code

String

Error code.

Status code: 500

Table 13 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

error_msg

String

Error message.

error_code

String

Error code.

Example Requests

Query network ACLs using tags and matches. A maximum of 100 records can be returned. The query starts from the first record.

https://{{Endpoint}}/v3/{project_id}/firewalls/resource-instances/filter?limit=100&offset=0

{
  "tags" : [ {
    "key" : "key1",
    "values" : [ "value1" ]
  } ],
  "matches" : [ {
    "key" : "resource_name",
    "value" : "network_aclv3_test"
  } ]
}

Example Responses

Status code: 200

Normal request response

{
  "resources" : [ {
    "resource_id" : "55046c0b-f38e-4bc4-988a-06529b34a7db",
    "resource_detail" : "",
    "resource_name" : "network_aclv3_test",
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    }, {
      "key" : "key2",
      "value" : "value2"
    } ]
  }, {
    "resource_id" : "1828c600-793d-4570-987b-ac59f3ef0734",
    "resource_detail" : "",
    "resource_name" : "network_aclv3_test",
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    }, {
      "key" : "key5",
      "value" : "value5"
    } ]
  } ],
  "request_id" : "2d9cef8c-4e17-40bc-9111-f3fc97b97294",
  "total_count" : 2
}

Status Codes

Status Code

Description

200

Normal request response

400

Invalid parameter

401

Authentication failure

403

Insufficient permissions

404

Not found

500

System exception

Error Codes

See Error Codes.