Help Center> Organizations> API Reference> API> Managing Tags> Querying Number of Resource Instances by Resource Type and Tag
Updated on 2024-03-15 GMT+08:00

Querying Number of Resource Instances by Resource Type and Tag

Function

This API is used to query the number of resource instances by resource type and tag.

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

resource_type

Yes

String

Resource type. It can be organizations:policies, organizations:ous, organizations:accounts, or organizations:roots.

Enumeration values:

  • organizations:policies

  • organizations:ous

  • organizations:accounts

  • organizations:roots

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Security-Token

No

String

Security token (session token) of your temporary security credentials. If a temporary security credential is used, this header is required.

Minimum: 1

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

without_any_tag

No

Boolean

If this parameter is set to true, all resources without tags are queried.

tags

No

Array of TagsDTO objects

A maximum of 10 keys can be queried at a time, and each key can contain a maximum of 10 values. The structure body must be included. The tag key cannot be left blank or be an empty string. Each key must be unique, and each value for a key must be unique. Resources that contain all keys and one or multiple values listed in tags will be found and returned. If no tag filtering criteria is specified, all data is returned.

Array Length: 0 - 20

matches

No

Array of Match objects

List of tags you want to attach to the new account.

Table 4 TagsDTO

Parameter

Mandatory

Type

Description

key

Yes

String

Key. Each tag key can contain a maximum of 127 Unicode characters and cannot be left blank.

Minimum: 1

Maximum: 128

values

Yes

Array of strings

List of values. Each value can contain a maximum of 255 Unicode characters.

Minimum: 0

Maximum: 255

Array Length: 0 - 10

Table 5 Match

Parameter

Mandatory

Type

Description

key

Yes

String

Key. The value can be policy, organizational-unit, or account.

Minimum: 0

Maximum: 128

value

Yes

String

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

Minimum: 0

Maximum: 256

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

total_count

Integer

Total number of records.

Example Requests

Querying the number of resource instances by resource type and tag

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

{
  "without_any_tag" : true,
  "tags" : [ {
    "key" : "string",
    "values" : [ "string" ]
  } ],
  "matches" : [ {
    "key" : "string",
    "value" : "string"
  } ]
}

Example Responses

Status code: 200

Successful

{
  "total_count" : 0
}

Status Codes

Status Code

Description

200

Successful

Error Codes

See Error Codes.