Help Center/ Global Accelerator/ API Reference/ API/ Tag/ Querying the Number of Resources by Tag
Updated on 2024-04-03 GMT+08:00

Querying the Number of Resources by Tag

Function

This API is used to query the number of resources by tag.

Calling Method

For details, see Calling APIs.

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_type

Yes

Object

Specifies the resource type.

Request Parameters

Table 2 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 3 Request body parameters

Parameter

Mandatory

Type

Description

tags

No

Array of Tag objects

Specifies the tag list.

Array Length: 1 - 20

matches

No

Array of Match objects

Specifies the matched results.

Array Length: 1 - 1

Table 4 Tag

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies tag key.

Minimum: 1

Maximum: 128

values

Yes

Array of strings

Specifies the values of the tag.

Minimum: 0

Maximum: 255

Array Length: 0 - 10

Table 5 Match

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key of the matched result.

Enumeration values:

  • resource_name

value

Yes

String

Specifies the value of the matched result.

Minimum: 0

Maximum: 255

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

total_count

Integer

Specifies the total number of resources.

request_id

String

Specifies the request ID.

Example Requests

Querying the Number of Resources by Tag

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

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

Example Responses

Status code: 200

Operation successful.

{
  "total_count" : 10,
  "request_id" : "ac1bf54f-6a23-4074-af77-800648d25bc9"
}

Status Codes

Status Code

Description

200

Operation successful.

Error Codes

See Error Codes.