Help Center/ Scalable File Service/ API Reference/ APIs/ Tag Management/ Querying the Number of Resources by Tag
Updated on 2025-12-17 GMT+08:00

Querying the Number of Resources by Tag

Function

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

Authorization

Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned. For the specific permissions required, see Permissions Policies and Supported Actions.

URI

  • POST /v3/sfs/tms/{project_id}/file-systems/resource-instances/count
  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    The project ID. For details, see Obtaining a Project ID.

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

Content-type

Yes

String

The MIME type of the request body.

Example: application/json

X-Auth-Token

No

String

The user token.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

without_any_tag

No

boolean

Excludes any tags. If this parameter is set to true, all resources without tags are queried. In this case, the tags field is ignored. If this parameter is set to false or not specified, it does not take effect, meaning that all resources are returned or resources are filtered by tags or matches.

tags

No

List<tag>

Includes tags. A maximum of 20 tags can be specified. Each tag key can have a maximum of 20 tag values. A tag value can be empty but the structure cannot be missing. Tag values of the same key must be unique. Tag keys must be unique, and tag values of the same key must be unique. The response returns resources containing all tags in this list. Keys in this list are in the AND relationship and values in each key-value structure are in the OR relationship. If this parameter is not specified, all resources will be returned.

For details, see Table 3.

sys_tags

No

List<tag>

Includes system tags. This parameter is only available to users with the op_service permission.

It cannot be used with filtering criteria without_any_tag and tags at the same time.

It contains only one tag structure currently.

The key is fixed at _sys_enterprise_project_id.

The value is the ID of an enterprise project.

The key contains only one value. Value 0 indicates the default enterprise project.

For details, see Table 3.

matches

No

List<match>

The fields to be matched. The key in match is a dictionary value fixed at resource_name, meaning that the prefix search is performed based on the value of the key. It will be extended later.

For details, see Table 4.

Response Parameters

Table 3 Response body parameter

Parameter

Mandatory

Type

Description

total_count

Yes

Integer

The total number of records.

Example Request

Querying the number of resources using project ID c80a2157ba1d46c0825265947342077c:

POST https://{endpoint}/v3/sfs/tms/c80a2157ba1d46c0825265947342077c/file-systems/resource-instances/count

Request body example:

{
    "tags":[
        {
            "key":"key1",
            "values":[
                "value1",
                "value2"
            ]
        },
        {
            "key":"key2",
            "values":[
                "value1",
                "value2"
            ]
        }
    ],
    "matches":[
        {
            "key":"resource_name",
            "value":"resource1"
        }
    ],
    "without_any_tag":"true"
}

Example Response

{
    "total_count":1
}

Status Codes

  • Normal

Status Code

Description

200

The number of resources is queried.

  • Abnormal

Status Code

Description

400

Invalid tag parameter.

401

Certification failed.

403

Authentication failed.

404

Resource not found.

500

System error.