Updated on 2022-09-14 GMT+08:00

Query Resource Groups

Function

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

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 indicates that no alarms have been generated 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

    instance_statistics

    InstanceStatistics object

    No

    Specifies the resource statistics in the resource group.

    For details, see Table 4.

    status

    string

    No

    Specifies the status of the resource group.

    Possible statuses are:

    • 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",
           "instance_statistics": {
             "unhealth": 2,
             "total": 10,
             "type_statistics": 1
           },
           "status": "unhealth",
           "enterprise_project_id": "0"
         },
         {
           "group_name": "RS",
           "create_time": 1606327955000,
           "group_id": "rg1606327955657LRj1lrE4y",
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0"
         },
         {
           "group_name": "RS",
           "create_time": 1606327947000,
           "group_id": "rg1606327947514v9OWqAD3N",
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0"
         },
         {
           "group_name": "RS",
           "create_time": 1606327946000,
           "group_id": "rg1606327946625PYogr059N",
           "instance_statistics": {
             "unhealth": 0,
             "total": 2,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0"
         },
         {
           "group_name": "ResourceGroupCorrect_2",
           "create_time": 1606325669000,
           "group_id": "rg1606325669900Rk4eKkLMZ",
           "instance_statistics": {
             "unhealth": 0,
             "total": 1,
             "type_statistics": 1
           },
           "status": "no_alarm_rule",
           "enterprise_project_id": "0"
         }
       ],
       "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.