• Scalable File Service

sfs
  1. Help Center
  2. Scalable File Service
  3. API Reference
  4. SFS APIs
  5. Share Tag
  6. Querying Share Details Based on Tags

Querying Share Details Based on Tags

Function

This interface is used to query share details based on tags.

URI

  • POST /v2/{project_id}/sfs/resource_instances/action
  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    string

    Specifies the project ID of the operator.

Request

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    offset

    No

    string

    Specifies the index location. The value is a character string consisting of 0 and positive integers. The default value is 0. The first record in the query result is the offset+1 record that meets the query criteria.

    limit

    No

    string

    Specifies the maximum number of query records. The value is a character string consisting of integers. The default value is 1000. The value ranges from 1 to 1000.

    The number of returned records does not exceed the value of limit.

    action

    Yes

    string

    Specifies the operation identifier. Possible values are filter and count.

    Use filter to query share details using tags.

    matches

    No

    list<match>

    Specifies the share resource query field. If this parameter is left null, all shares of the tenant are searched by default.

    tags

    No

    list<tag>

    Specifies the tag search field, which is a list of tags. Only shares containing all the listed tags can be returned. Tags in this search criteria are in the AND relationship. Specifically, a share can be searched only when it meets all the tag search conditions. In the key-values structure of each tag search condition, tag values are in the OR relationship. If tags is not specified, all shares meet the requirement of this tag search field. This field contains a maximum of 10 tag keys and each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Tag keys must be unique. Tag values in a key-values structure must be unique.

    tags_any

    No

    list<tag>

    Specifies the tag search field, which is a list of tags. Shares that contain any listed tag will be returned. Tags in this search criteria are in the OR relationship. Specifically, a share can be searched as long as it meets one tag search condition. In the key-values structure of each tag search condition, tag values are in the OR relationship. If tags_any is not specified, all shares meet the requirement of this tag search field. This field contains a maximum of 10 tag keys and each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Tag keys must be unique. Tag values in a key-values structure must be unique.

    not_tags

    No

    list<tag>

    Specifies the tag search field, which is a list of tags. Only shares that contain none of the listed tags will be returned. Tags in this search criteria are in the NOR relationship. Specifically, a share can be searched only when it does not meet any tag search conditions. In the key-values structure of each tag search condition, tag values are in the OR relationship. If not_tags is not specified, all shares meet the requirement of this tag search field. This field contains a maximum of 10 tag keys and each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Tag keys must be unique. Tag values in a key-values structure must be unique.

    not_tags_any

    No

    list<tag>

    Specifies the tag search field, which is a list of tags. Shares that do not contain any of the listed tags will be returned. Tags in this search criteria are in the NAND relationship. Specifically, a share can be searched as long as it does not meet one tag search condition. In the key-values structure of each tag search condition, tag values are in the OR relationship. If not_tags_any is not specified, all shares meet the requirement of this tag search field. This field contains a maximum of 10 tag keys and each tag key has a maximum of 10 tag values. The tag value corresponding to each tag key can be an empty array but the structure cannot be missing. Tag keys must be unique. Tag values in a key-values structure must be unique.

    sys_tags

    No

    list<tag>

    Only the op_service permission can use this field to filter resources.

    1. Currently, TMS can invoke only one tag structure key, _sys_enterprise_project_id.
    2. Currently, key contains only one value. 0 indicates the default enterprise project.
    3. sys_tags and tenant tag filtering conditions (tags, tags_any, not_tags, and not_tags_any) cannot be used at the same time.

    In the request parameters, tag search fields tags, tags_any, not_tags, and not_tags_any are optional and can be combined with each other. Such tag search fields are in the AND relationship.

  • Description of field match:

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    string

    Specifies the key. The value is fixed to resource_name.

    value

    Yes

    string

    Specifies the value. value indicates the share name. An empty string specifies an exact match and only shares whose names are empty can be queried. A non-empty string specifies a fuzzy query (case insensitive). The value can contain a maximum of 255 characters.

  • Description of field tag:

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    string

    Specifies the key of the tag. A tag key consists of up to 127 characters. This parameter cannot be left empty.

    values

    Yes

    list<string>

    Lists the values. Each value can contain a maximum of 255 characters. If the value is left empty, any value is matched. The values are in the OR relationship.

  • Example request
    {
        "offset": "0",
        "limit": "100",
        "action": "filter",
        "matches": [{
            "key": "resource_name",
            "value": "share_name"
        }],
        "tags": [{
            "key": "key1",
            "values": ["value2"]
        }, {
            "key": "key2",
            "values": []
        }],
        "tags_any": [{
            "key": "key3",
            "values": ["value3"]
        }, {
            "key": "key4",
            "values": []
        }],
        "not_tags": [{
            "key": "key5",
            "values": ["value5"]
        }, {
            "key": "key6",
            "values": []
        }],
        "not_tags_any": [{
            "key": "key7",
            "values": ["value7", "value8"]
        }, {
            "key": "key9",
            "values": []
        }]
    }
  • Example request (without passing matches)
    {
        "offset": "0",
        "limit": "100",
        "action": "filter",
        "tags": [{
            "key": "key1",
            "values": ["value2"]
        }, {
            "key": "key2",
            "values": []
        }]
    }
  • Example request (without passing limit and offset)
    {
        "action": "filter",
        "matches": [{
            "key": "resource_name",
            "value": "share_name"
        }],
        "tags": [{
            "key": "key1",
            "values": ["value2"]
        }, {
            "key": "key2",
            "values": []
        }]
    }
  • Example request (without passing tags, not_tags, tags_any, and not_tags_any)
    {
        "offset": "0",
        "limit": "100",
        "action": "filter",
        "matches": [{
            "key": "resource_name",
            "value": "share_name"
        }]
    }
  • Example request (with the action field only)
    {
        "action": "filter"
    }

Response

  • Parameter description

    Parameter

    Type

    Description

    resources

    List<resource>

    Specifies the list of shares that meet the query criteria.

    total_count

    Integer

    Specifies the total number of shares that meet the query criteria.

    NOTE:

    total_count specifies the total number of shares that meet the query criteria, instead of the number returned after you set offset and limit.

  • Data structure of the resource field

    Parameter

    Type

    Description

    resource_id

    String

    Specifies the share ID.

    resouce_detail

    Object

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

    tags

    List<resource_tag>

    Specifies a list of tags. If no tags exist, the value is an empty array by default.

    sys_tags

    List<tag>

    Only the op_service permission can obtain this field.

    1. Currently, only one tag structure key is used, _sys_enterprise_project_id.
    2. Currently, key contains only one value. 0 indicates the default enterprise project.

    This field cannot be returned in non-op_service scenarios.

    resource_name

    String

    Specifies the resource name.

  • Data structure of the resource_tag field

    Parameter

    Type

    Description

    key

    String

    Specifies the key of the tag. The value can contain a maximum of 36 characters. This parameter cannot be left empty. It can only contain letters, digits, hyphens (-), and underscores (_).

    value

    String

    Specifies the value of the tag. The value contains a maximum of 43 characters and can be an empty string. It can only contain letters, digits, hyphens (-), and underscores (_).

  • Example response
    {
        "resources":[
            {
                "resource_detail":{},
                "resource_id":"b1f3f06f-344d-446b-a4bf-647a225debae",
                "resource_name":"share_name",
                "tags":[
                    {
                        "key":"key1", 
                        "value": "value1"
                    },
                    {
                        "key":"key2", 
                        "value": "value2"
                    }
                ]
            }
        ],
        "total_count":1
    }

Status Codes

  • Normal

    200

  • Abnormal

    Status Code

    Description

    400 Bad Request

    Invalid value.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    You are forbidden to access the requested page.

    404 Not Found

    The requested resource was not found.

    500 Internal Server Error

    The request is not completed because of a service error.