Updated on 2024-11-18 GMT+08:00

Listing Resources

Function

This API is used to list resources by tag. Resources are sorted by the time when they are created, in descending order.

URI

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

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

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

    limit

    No

    Int

    The number of records to be queried. The value ranges from 1 to 1000, and the default value is 1000.

    offset

    No

    Int

    The index location. The query starts from the next data record indexed by this parameter. The default value is 0, indicating that the query starts from the first data record. The value cannot be a negative number.

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 of the specified 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, which means that all resources are returned or resources are filtered by tags or matches.

tags

No

List<tag>

Includes specified tags. A maximum of 20 tags can be specified. Tag keys must be unique. 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.

The response returns resources containing all tags in this list. Keys in this list are in an AND relationship while values in each key-value structure is in an OR relationship. If this parameter is not specified, all resources will be returned.

For details, see Table 3.

sys_tags

No

List<tag>

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

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

This field 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.

Table 3 tag

Parameter

Mandatory

Type

Description

key

Yes

String

The tag key. A tag key can contain a maximum of 128 characters. It can contain letters, digits, and spaces representable in UTF-8 and special characters (_.:=+-@). It cannot start or end with a space and cannot be left empty. Tag keys starting with _sys_ are system tags, and you cannot start a tag key with _sys_.

values

Yes

List<String>

The tag value list. A value can be an empty array but cannot be left blank. If the list specified by values is empty arrays, any tag value can be queried. The values are in the OR relationship.

Table 4 match

Parameter

Mandatory

Type

Description

key

Yes

String

The key. The key is fixed at resource_name currently. Other key values will be available later.

value

Yes

String

The value. Each tag value can contain a maximum of 255 Unicode characters. The character set is not verified.

Response Parameters

Table 5 Response body parameters

Parameter

Mandatory

Type

Description

resources

Yes

List<resource>

The resource list. For details, see Table 6.

total_count

Yes

Integer

The total number of records.

Table 6 resource

Parameter

Mandatory

Type

Description

resource_id

Yes

String

The resource ID.

resource_detail

Yes

Object

The resource details. This value is left empty by default. The value is a resource object used for extension.

tags

Yes

List<resource_tag>

The tag list. If there is no tag, an empty array is used by default.

For details, see Table 3.

sys_tags

No

List<resource_tag>

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

This field contains only one resource_tag structure key currently.

The key is fixed at _sys_enterprise_project_id.

The value is the ID of the enterprise project. Value 0 indicates the default enterprise project.

For details, see Table 3.

resource_name

Yes

String

The resource name. This parameter is an empty string if there is no resource name.

Example Request

Listing resources (with the project ID set to **c80a2157ba1d46c0825265947342077c**, offset to **0**, and limit to **10**):

POST https://{endpoint}/v3/sfs/tms/c80a2157ba1d46c0825265947342077c/file-systems/resource-instances/filter?limit=10&offset=0

Request body example:

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

Example Response

{
    "resources":[
        {
            "resource_detail":"",
            "resource_id":"resouece1",
            "resource_name":"resouece1",
            "tags":[
                {
                    "key":"key1",
                    "value":"value1"
                }
            ],
            "sys_tags":[]
        }
    ],
    "total_count":1
}

Status Codes

  • Normal

Status Code

Description

200

Resources listed.

  • Abnormal

Status Code

Description

400

Invalid tag parameter.

401

Certification failed.

403

Authentication failed.

404

Resource not found.

500

System error.