• Auto Scaling

as
  1. Help Center
  2. Auto Scaling
  3. API Reference
  4. API
  5. Tag Management
  6. Querying Resources

Querying Resources

Function

This interface is used to query instances of a specified resource type by project ID.

By default, resources and resource tags are in descending order of their creation time.

URI

POST /autoscaling-api/v1/{project_id}/{resource_type}/resource_instances/action
Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

resource_type

Yes

String

Specifies the resource type. An example value is scaling_group_tag.

Request Message

  • Request parameters
    Table 2 Request parameters

    Parameter

    Mandatory

    Type

    Description

    tags

    No

    List<Tag>

    Specifies the filter containing tags. A maximum of 10 tags are allowed. The structure body cannot be missing.

    tags_any

    No

    List<Tag>

    Specifies the filter containing specified tags. A maximum of 10 tags are allowed.

    not_tags

    No

    List<Tag>

    Specifies the filter containing no tag. A maximum of 10 tags are allowed.

    not_tags_any

    No

    List<Tag>

    Specifies the filter not containing specified tags. A maximum of 10 tags are allowed.

    limit

    No

    String

    Specifies the page size. This parameter is available when action is set to filter. Both the default value and maximum value are 1000, and the minimum value is 1. The value cannot be a negative number.

    marker

    No

    String

    Marks the paging location (index position).

    action

    Yes

    String

    Specifies the operation to perform. The value can only be filter or count.

    filter indicates the pagination query.

    count indicates that the total number of records that meet the query criteria is returned.

    offset

    No

    String

    Specifies the index position. The query starts from the next image indexed by this parameter.

    You do not need to specify this parameter when querying resources on the first page.

    When you query resources on subsequent pages, set the value of offset to the location returned in the response body for the previous query.

    The value must be a number and cannot be a negative number.

    If action is set to count, this parameter does not take effect.

    If action is set to filter, the default value of this parameter is 0.

    matches

    No

    List<match>

    Specifies the fuzzy search field.

    Table 3 Tag field data structure description

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the resource tag key. It contains a maximum of 127 Unicode characters. It cannot be left blank (This parameter is not verified in the search process.) A maximum of 10 keys are allowed and the key cannot be left blank or an empty string. Each key must be unique.

    values

    Yes

    List<String>

    Each value can contain a maximum of 255 Unicode characters.

    Specifies the resource tag values. Each value can contain a maximum of 255 Unicode characters. Each key can contain a maximum of 10 values. Each value of the same key must be unique.

    • The asterisk (*) is reserved for the system. If the value starts with *, it indicates that fuzzy match is performed based on the value following *. The value cannot contain only asterisks (*).
    • If the values are null (not default), it indicates any_value (querying any value). The resources contain one or multiple values listed in values will be found and displayed.
    Table 4 match field data structure description

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    String

    Specifies the key. The value is fixed at resource_name.

    value

    Yes

    String

    Specifies the value. The value is a fixed dictionary value. A value contains a maximum of 255 Unicode characters. If the value is an empty string or resource_id, exact match is used.

  • Example request
    • Sample request when action is set to filter
      {
        "offset": "100", 
        "limit": "100", 
        "action": "filter", 
      
        "matches":[
      {
             "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"
            ]
          }
        ]
      }       
    • Sample request when action is set to count
      {
        "action": "count", 
        "not_tags": [
          {
            "key": "key1", 
            "values": [
              "value1", 
              "*value2"
            ]
          }
        ], 
        "tags": [
          {
            "key": "key1", 
            "values": [
              "value1", 
              "value2"
            ]
      },
      {
            "key": "key2", 
            "values": [
              "value1", 
              "value2"
            ]
          }
        ], 
        "tags_any": [
          {
            "key": "key1", 
            "values": [
              "value1", 
              "value2"
            ]
          }
        ],
      "not_tags_any": [
          {
            "key": "key1", 
            "values": [
              "value1", 
              "value2"
            ]
          }
         ],
      "matches":[
      {
              "key": "resource_name", 
              "value": "resource1"
             }
      ]
      }       

Response Message

  • Response parameters
    Table 5 Response parameters

    Parameter

    Type

    Description

    resources

    List<Resource>

    Specifies the tag resource instance.

    total_count

    Integer

    Specifies the total number of query records.

    marker

    String

    Specifies the paging location identifier.

    Table 6 Resource field description

    Parameter

    Type

    Description

    resource_id

    String

    Specifies the resource ID.

    resource_detail

    String

    Specifies the resource details.

    tags

    List<ResourceTag>

    Specifies the tag list. If there is no tag in the list, tags is taken as an empty array.

    resource_name

    String

    Specifies the resource name. This parameter is an empty string by default if there is no resource name.

    Table 7 ResourceTag field description

    Parameter

    Type

    Description

    key

    String

    Specifies the resource tag key. It can contain a maximum of 36 Unicode characters.

    value

    String

    Specifies the resource tag value.

  • Example response
    • Example response when action is set to filter
      {
       "resources": [{
             "resource_id": "64af4b6f-ec51-4436-8004-7a8f30080c87",
             "resource_detail": "SCALING_GROUP_TAG",
             "tags": [{
                   "key": "key1","value": "value1"
             }],
             "resource_name": "as_scaling_group_1"
       },
       {
             "resource_id": "7122ef51-604b-40e7-b9b2-1de4cd78dc60",
             "resource_detail": "SCALING_GROUP_TAG",
             "tags": [{
                   "key": "key1","value": "value1"
             }],
             "resource_name": "as_scaling_group_2"
       },
       "marker": "2",
       "total_count": 2
      }
    • Example response when action is set to count
      {
             "total_count": 1000
      }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Values

    Description

    400 Bad Request

    The server failed to process the request.

    401 Unauthorized

    You must enter the username and password to access the requested page.

    403 Forbidden

    You are forbidden to access the requested page.

    404 Not Found

    The server could not find the requested page.

    405 Method Not Allowed

    You are not allowed to use the method specified in the request.

    406 Not Acceptable

    The response generated by the server could not be accepted by the client.

    407 Proxy Authentication Required

    You must use the proxy server for authentication so that the request can be processed.

    408 Request Timeout

    The request timed out.

    409 Conflict

    The request could not be processed due to a conflict.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    501 Not Implemented

    Failed to complete the request because the server does not support the requested function.

    502 Bad Gateway

    Failed to complete the request because the request is invalid.

    503 Service Unavailable

    Failed to complete the request because the system is unavailable.

    504 Gateway Timeout

    A gateway timeout error occurred.

Error Codes

See section Error Codes.