Help Center/ Global Accelerator/ API Reference/ API/ Tag/ Querying Resources by Tag
Updated on 2025-11-10 GMT+08:00

Querying Resources by Tag

Function

This API is used to query resources by tag.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    ga::listResourcesByTag

    List

    -

    g:TagKeys

    • ga:tag:listResourcesByTag

    -

URI

POST /v1/{resource_type}/resource-instances/filter

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_type

Yes

Object

Resource type. Value range:

  • ga-accelerators: Global accelerators

  • ga-listeners: Listeners

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Specifies the number of results on each page.

offset

No

Integer

Specifies the number of bytes to skip before starting to read data.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token. The token can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

tags

No

Array of Tag objects

Specifies the tag list.

matches

No

Array of Match objects

Specifies the matched results.

Table 5 Tag

Parameter

Mandatory

Type

Description

key

Yes

String

The tag key.

values

Yes

Array of strings

The list of tag values.

Table 6 Match

Parameter

Mandatory

Type

Description

key

Yes

String

The key for matching a resource instance.

Range:

resource_name: Resource name

value

Yes

String

The value for matching a resource instance.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

resources

Array of ResourceTags objects

Specifies the resource list.

total_count

Integer

Specifies the total number of resources.

Table 8 ResourceTags

Parameter

Type

Description

resource_id

String

Specifies the resource ID.

resource_name

String

Specifies resource name.

tags

Array of ResourceTag objects

Specifies the tag.

Table 9 ResourceTag

Parameter

Type

Description

key

String

The tag key.

  • A key can contain 1 to 128 characters. It cannot be left blank.

  • A key can contain UTF-8 letters, digits, spaces, and the following characters _.:=+-@

  • Do not enter a tag key starting with sys. Tag keys starting with sys are system tags.

value

String

The tag value.

  • A value can contain 0 to 255 characters.

  • A value can contain UTF-8 letters, digits, spaces, and the following characters _.:/=+-@

  • The tag value can be empty or null.

Example Requests

Querying Resources by Tag

POST https://{ga_endpoint}/v1/{resource_type}/resource-instances/filter

{
  "tags" : [ {
    "key" : "tagKey",
    "values" : [ "tagValue" ]
  } ],
  "matches" : [ {
    "key" : "resourceName",
    "value" : "name"
  } ]
}

Example Responses

Status code: 200

Operation successful.

{
  "resources" : [ {
    "resource_id" : "c2b210b2-60c4-449d-91e2-9e9ea1dd7443",
    "resource_name" : "resourceName",
    "tags" : [ {
      "key" : "tagKey",
      "value" : "tagValue"
    } ]
  } ],
  "total_count" : 1
}

Status Codes

Status Code

Description

200

Operation successful.

Error Codes

See Error Codes.