• Workspace

workspace
  1. Help Center
  2. Workspace
  3. API Reference
  4. Desktop Tags
  5. Filtering Desktops Using Tags

Filtering Desktops Using Tags

Function

This interface is used to filter desktops using tags.

URI

  • URI format

    POST /v1.0/{project_id}/workspace/resource_instances/action

  • URI parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    string

    Specifies the user ID.

Request

  • Request body parameter description

    Parameter

    Mandatory

    Type

    Description

    tags

    No

    List data structure [1]

    Tags are included.

    tags_any

    No

    List data structure [1]

    All tags are included.

    not_tags

    No

    List data structure [1]

    No tag is included.

    not_tags_any

    No

    List data structure [1]

    Any tags are excluded.

    limit

    No

    string

    Queries the number of records (there is no such parameter when the action is count). If the action is filter, the default value is 10. The value of limit ranges from 0 to 1000.

    offset

    No

    string

    (Index position), starting from the next data specified by offset. When you query the first page of data, this parameter is not required; when you query the subsequent pages of data, the value in the response body will be brought into this parameter during the query of the previous page of data (the action is count when there is no such parameter). If the action is filter, the default value is 1. The value of offset ranges from an integer greater than 0.

    action

    Yes

    string

    Operation identifier (case-sensitive): filter, count (total number of queries).

    Filter means paging query, and count only needs to return the total number of queries according to conditions.

    matchs

    No

    List data structure [3]

    Search field. Key is the field to be matched. Currently, only key is supported for resource_name for the fuzzy match, and value is the matching value.

[1]tags field data structure description

Parameter

Mandatory

Type

Description

key

Yes

string

Specifies the key of the tag that cannot be empty and can contain a maximum of 36 characters, including uppercase and lowercase letters, digits, hypen(-), and underscore (_).

values

No

List data structure [2]

Specifies the collection of tag values.

[2] values field data structure description

Parameter

Mandatory

Type

Description

value

Yes

string

Specifies the value of the tag that has a maximum length of 43 characters, including uppercase and lowercase letters, digits, hypen (-), and underscore (_).

[2] match field data structure description

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key. The first period is limited to resource_name, which is to be extended.

value

Yes

String

Specifies the value. Each value has a maximum length of 255 unicode characters and cannot be empty.

  • Request example
    GET /v1.0/9c53a566cb3443ab910cf0daebca90c4/workspace/resource_instances/action
  • Request body when action is filter
    {
    "offset": "100",
    "limit": "100",
    "action": "filter",
    "matchs":[
    {
    "key": "resource_name",
    "value": "resource1"
    }
    ],
    "not_tags": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "tags": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "tags_any": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "not_tags_any": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ]
    }
  • Request body when action is count
    {
    "action": "count",
    "not_tags": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "tags": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "tags_any": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "not_tags_any": [
    {
    "key": "key1",
    "values": [
    "value1",
    "value2"
    ]
    }
    ],
    "matchs":[
    {
    "key": "resource_name",
    "value": "resource1"
    }
    ]
    }

Response

  • Description

    Name

    Type

    Description

    resources

    List data structure [1]

    Specifies the resource list.

    total_count

    Integer

    Specifies the total counts.

    offset

    string

    Specifies the paging location identifier (index location).

[1]tags field data structure description

Name

Type

Description

resource_id

String

Specifies the resource ID.

resouce_detail

String

Specifies resource details in JSON string, which is used for extension.

tags

List data structure [2]

Specifies the tag list.

resource_name

String

Specifies the resource name.

[2]tag field data structure description

Name

Type

Description

key

string

Specifies the tag key.

value

string

Specifies the tag value.

  • Response example
Response body when action is filter.
    {
      "offset": "200", 
      "resources": [
         {
            "resource_detail": "", 
            "resource_id": "8e07d3e9-454e-4fc9-ba56-c631d05c4712", 
            "resource_name": "resouece1", 
            "tags": [
                {
                   "key": "key1",
                   "value": "value1"
                }
             ]
         }
       ], 
      "total_count": 1000
}
Response body when action is count
{
       "total_count": 1000
}

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    The request syntax is incorrect and cannot be understood by the server.

    401 Unauthorized

    Authentication fails.

    403 Forbidden

    You are not authorized to perform the operation.

    404 Not Found

    The requested resource is not found.

    405 Method Not Allowed

    The method specified in the request is not allowed.

    500 Internal Server Error

    Internal service error. For details about error codes, see Error Code Description.

    503 Service Unavailable

    The service is unavailable.