Updated on 2024-01-04 GMT+08:00

Query Resource Groups

Function

This API is used to query all resource groups you created.

Debugging

You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.

URI

GET /V1.0/{project_id}/resource-groups

  • Parameter description
    Table 1 Parameter description

    Parameter

    Type

    Mandatory

    Description

    project_id

    String

    Yes

    Specifies the project ID.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    group_name

    String

    No

    Specifies the resource group, for example, Resource-Group-ECS-01.

    group_id

    String

    No

    Specifies the resource group ID, for example, rg1603786526428bWbVmk4rP.

    status

    String

    No

    Specifies the resource group status, which can be health, unhealth, or no_alarm_rule.

    • health: No alarms have been generated for the resource group.
    • unhealth: An alarm or alarms have been generated for a resource or resources in the resource group.
    • no_alarm_rule: No alarm rules have been set for the resource group.

    start

    Integer

    No

    Specifies the start value of pagination. The value is an integer. The default value is 0.

    limit

    Integer

    No

    Specifies the maximum number of records that can be queried at a time. Supported range: 1 to 100 (default)

  • Example
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/resource-groups

Request

None

Response

  • Response parameters
    Table 2 Parameter description

    Parameter

    Type

    Mandatory

    Description

    resource_groups

    Array of objects

    No

    Specifies information about one or more resource groups.

    For details, see Table 3.

    meta_data

    MetaData object

    No

    Specifies the number of metadata records in the query result.

    For details, see Table 5.

    Table 3 resource_groups data structure description

    Parameter

    Type

    Mandatory

    Description

    group_name

    String

    No

    Specifies the resource group name, for example, ResourceGroup-Test01.

    group_id

    String

    No

    Specifies the resource group ID, for example, rg1603786526428bWbVmk4rP.

    create_time

    Long

    No

    Specifies the time the resource group is created. The time is a UNIX timestamp and the unit is ms. Example: 1603819753000

    relation_ids

    Array of strings

    No

    Specifies the enterprise project IDs.

    type

    String

    No

    Specifies the method for adding resources to a resource group. The value can be EPS (synchronizing resources from enterprise projects), TAG (dynamic tag matching), or Manual (manually adding resources).

    Minimum length: 0

    Maximum length: 32

    resources

    Array of Resource objects

    No

    Specifies information about one or more resources.

    Array length: 0 to 20

    instance_statistics

    InstanceStatistics object

    No

    Specifies the resource statistics in the resource group.

    For details, see Table 4.

    status

    String

    No

    Specifies the resource group status, which can be health, unhealth, or no_alarm_rule.

    • health: No alarms have been generated for the resource group.
    • unhealth: An alarm or alarms have been generated for a resource or resources in the resource group.
    • no_alarm_rule: No alarm rules have been set for the resource group.

    enterprise_project_id

    String

    No

    Specifies the enterprise project associated with the resource group. The default value 0 indicates enterprise project default.

    Table 4 instance_statistics data structure description

    Parameter

    Type

    Mandatory

    Description

    unhealth

    Integer

    No

    Specifies the number of resources in the Alarm state in the resource group.

    total

    Integer

    No

    Specifies the total number of resources in the resource group.

    type_statistics

    Integer

    No

    Specifies the total number of resource types in the resource group. For example, if ECS, EIP and bandwidth are added to the resource group, the type_statistics value is 2.

    Table 5 meta_data data structure description

    Parameter

    Type

    Mandatory

    Description

    total

    Integer

    No

    Specifies the total number of query results.

    • Example response
      {
        "resource_groups": [
         {
           "group_name": "ResourceGroup-Test01",
           "create_time": 1606374365000,
           "group_id": "rg16063743652226ew93e64p",
           "relation_ids": ["0"],
           "instance_statistics": {
             "unhealth": 2,
             "total": 10,
             "type_statistics": 1
           },
           "status": "unhealth",
           "enterprise_project_id": "0",
           "type": "TAG",
           "resources": []
         },
         {
           "group_name": "RS",
           "create_time": 1606327955000,
           "group_id": "rg1606327955657LRj1lrE4y",
           "relation_ids": ["0"],
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0",
           "type": "TAG",
           "resources": []
         },
         {
           "group_name": "RS",
           "create_time": 1606327947000,
           "group_id": "rg1606327947514v9OWqAD3N",
           "relation_ids": ["0"],
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0",
           "type": "TAG",
           "resources": []
         },
         {
           "group_name": "RS",
           "create_time": 1606327946000,
           "group_id": "rg1606327946625PYogr059N",
           "relation_ids": ["0"],
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0",
           "type": "TAG",
           "resources": []
         },
         {
           "group_name": "ResourceGroupCorrect_2",
           "create_time": 1606325669000,
           "group_id": "rg1606325669900Rk4eKkLMZ",
           "relation_ids": ["0"],
           "instance_statistics": {
             "unhealth": 0,
             "total": 1,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0",
           "type": "TAG",
           "resources": []
         }
       ],
       "meta_data": {
         "total": 5
       }
      }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    Access to the requested page is forbidden.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

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

    503 Service Unavailable

    The service is currently unavailable.

Error Codes

See Error Codes.