Querying Resource Groups
Function
This API is used to query resource groups.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
ces:resourceGroups:list
List
-
g:EnterpriseProjectId
ces:resourceGroups:get
-
URI
GET /v2/{project_id}/resource-groups
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. It is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID. Constraints N/A Range 1 to 64 characters. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| enterprise_project_id | No | String | Definition ID of the enterprise project. Constraints N/A Range The value contains 36 characters. It can only contain lowercase letters, digits, hyphens (-), and underscores (_). It can also be 0 (ID of the default enterprise project), or all_granted_eps (IDs of all enterprise projects). Default Value N/A |
| group_name | No | String | Definition Resource group name. Fuzzy search is supported. Constraints N/A Range It allows 1 to 128 characters and can contain letters, digits, underscores (_), and hyphens (-). Default Value N/A |
| group_id | No | String | Definition Resource group ID. Constraints N/A Range The value starts with rg and is followed by 22 characters that can include letters and digits. Default Value N/A |
| offset | No | Integer | Definition Pagination start value. Constraints N/A Range [0,10000] Default Value 0 |
| limit | No | Integer | Definition Number of records on each page. Constraints N/A Range [1,100] Default Value 100 |
| type | No | String | Definition Method for adding resources to a resource group. If this parameter is not transferred, all resource group types are queried. Constraints N/A Range Default Value N/A |
| status | No | String | Definition Health status of a resource group. Constraints N/A Range Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. Constraints N/A Range 1 to 16,384 characters. Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| count | Integer | Definition Total number of resource groups. Range [0,1000] |
| resource_groups | Array of OneResourceGroupResp objects | Definition Resource groups. |
| Parameter | Type | Description |
|---|---|---|
| group_name | String | Definition Resource group name. Range The value allows 1 to 128 characters. It can only contain letters, digits, hyphens (-), and underscores (_). |
| group_id | String | Definition Resource group ID. Range The value starts with rg and is followed by 22 characters that can include letters and digits. |
| create_time | String | Definition Time when a resource group was created. The value is a UNIX timestamp in milliseconds. Example: 1603819753000 |
| update_time | String | Definition Time when the resource group was modified. The value is a UNIX timestamp in milliseconds. Example: 1603819753000 |
| enterprise_project_id | String | Definition ID of the enterprise project that a resource group belongs to. Range The value contains 36 characters. It can only contain lowercase letters, digits, and hyphens (-). It can be 0 (ID of the default enterprise project). |
| type | String | Definition Method for adding resources to a resource group. Range |
| status | String | Definition Metric monitoring status of the resource group. Range |
| event_status | String | Definition Event monitoring status of the resource group. Range |
| resource_statistics | resource_statistics object | Definition Resource statistics in the resource group. |
| related_ep_ids | Array of strings | Definition Enterprise projects specified when the resource matching rule is set to Enterprise Project. |
| association_alarm_templates | Array of AssociationAlarmTemplate objects | Definition Associated alarm templates. |
| resource_level | String | Definition Resource level, which indicates the effective resource scope. Range |
| Parameter | Type | Description |
|---|---|---|
| unhealthy | Integer | Definition Number of resources in the Alarm state in the resource group. Range [0,9999999] |
| total | Integer | Definition Total number of resources in the resource group. Range [0,9999999] |
| event_unhealthy | Integer | Definition Number of resources that have triggered alarms in the resource group. Range [0,9999999] |
| namespaces | Integer | Definition Number of resource types in the resource group. For example, if ECS, EIP, and bandwidth are added to the resource group, the value is 2. Range [0,9999999] |
| Parameter | Type | Description |
|---|---|---|
| template_id | String | Definition Alarm template ID. Range The value starts with at and allows 2 to 64 characters. It can contain only letters and digits. |
| template_name | String | Definition Alarm template name. Range The value must start with a letter and allows 1 to 128 characters. It can contain only letters, digits, underscores (_), and hyphens (-). |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Status codes customized by each cloud service when a request error occurs. |
| error_msg | String | Request error message. |
| request_id | String | Request ID. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Status codes customized by each cloud service when a request error occurs. |
| error_msg | String | Request error message. |
| request_id | String | Request ID. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Status codes customized by each cloud service when a request error occurs. |
| error_msg | String | Request error message. |
| request_id | String | Request ID. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Status codes customized by each cloud service when a request error occurs. |
| error_msg | String | Request error message. |
| request_id | String | Request ID. |
Example Requests
Query resource groups.
/v2/{project_id}/resource-groups?offset=0&limit=100
/v2/{project_id}/resource-groups?offset=0&limit=100 Example Responses
Status code: 200
OK
{
"resource_groups" : [ {
"group_name" : "group1",
"create_time" : "2006-01-02T15:04:05.000Z",
"update_time" : "2006-01-02T15:04:05.000Z",
"group_id" : "rg0123456789xxxx",
"enterprise_project_id" : "0",
"type" : "Manual",
"status" : "health",
"event_status" : "no_alarm_rule",
"resource_statistics" : {
"event_unhealthy" : 0,
"namespaces" : 1,
"total" : 14,
"unhealthy" : 0
},
"related_ep_ids" : [ ],
"association_alarm_templates" : [ ],
"resource_level" : "product"
}, {
"group_name" : "band",
"type" : "EPS",
"create_time" : "2006-01-02T15:04:05.000Z",
"update_time" : "2006-01-02T15:04:05.000Z",
"group_id" : "rg0123456789xxxx",
"enterprise_project_id" : "d61d4705-5658-42f5-8e0c-70eb34d17b02",
"status" : "health",
"event_status" : "no_alarm_rule",
"resource_statistics" : {
"event_unhealthy" : 0,
"namespaces" : 0,
"total" : 0,
"unhealthy" : 0
},
"related_ep_ids" : [ "0" ],
"association_alarm_templates" : [ ],
"resource_level" : "product"
}, {
"group_name" : "group2",
"type" : "TAG",
"create_time" : "2006-01-02T15:04:05.000Z",
"update_time" : "2006-01-02T15:04:05.000Z",
"group_id" : "rg0123456789xxxx",
"enterprise_project_id" : "0",
"status" : "unhealthy",
"event_status" : "no_alarm_rule",
"resource_statistics" : {
"event_unhealthy" : 0,
"namespaces" : 1,
"total" : 14,
"unhealthy" : 1
},
"related_ep_ids" : [ ],
"association_alarm_templates" : [ {
"template_id" : "at12321321",
"template_name" : "templatexxx"
} ],
"resource_level" : "dimension"
} ],
"count" : 3
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Parameter verification failed. |
| 401 | Not authenticated. |
| 403 | Authentication failed. |
| 500 | Internal system error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot