Creating a Resource Group (Recommended)
Function
This API is used to create a resource group.
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:create
Write
-
g:EnterpriseProjectId
-
-
URI
POST /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 |
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 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
group_name |
Yes |
String |
Definition Resource group name. Constraints N/A Range The value allows 1 to 128 characters. It can only contain letters, digits, hyphens (-), and underscores (_). Default Value N/A |
|
enterprise_project_id |
No |
String |
Definition ID of the enterprise project that a resource group belongs to. Constraints N/A Range The value can be 0 (default enterprise project ID) or consists of digits, letters, or hyphens (-). Default Value N/A |
|
type |
No |
String |
Definition Method for adding resources to a resource group. Constraints N/A Range The value can only be EPS (synchronizing resources from enterprise projects), TAG (dynamic tag matching), NAME (matching resources by instance name), or COMB (matching resources by multiple criteria). If this parameter is not specified, resources are manually added. Default Value N/A |
|
tags |
No |
Array of ResourceGroupTagRelation objects |
Definition Associated tags during dynamic tag matching. Constraints This parameter is mandatory when type is set to TAG. A maximum of 50 tags are allowed. |
|
association_ep_ids |
No |
Array of strings |
Definition ID of the enterprise project from which resources in the resource group come. Constraints This parameter is mandatory when type is set to EPS. The value can contain a maximum of 50 enterprise project IDs. |
|
providers |
No |
String |
Definition Cloud service name in the dcs,ecs format. For details about supported cloud services (providers), see section "Supported Services and Resource Types" in Config API Reference. Constraints N/A Range [0,512] Default Value N/A |
|
enterprise_project_id_and_tags |
No |
Array of EnterpriseProjectIdAndTags objects |
Definition Parameter for matching resources by enterprise project or tag. Constraints A maximum of 50 conditions are allowed. |
|
resources |
No |
Array of Resource objects |
Definition Resource details when resources are manually added. Constraints Max. 1,000 resources |
|
product_resources |
No |
Array of ProductResource objects |
Definition Resource details when the resource level is cloud product and resources are manually added. Constraints A maximum of 50 resources are allowed. |
|
instances |
No |
Array of Instance objects |
Definition Parameter transferred for matching resources by instance name. Constraints This parameter is mandatory when type is set to NAME. The value can contain a maximum of 50 instances. |
|
product_names |
No |
String |
Name of a cloud product when the resource level is cloud product. Generally, the value format is Service namespace,First-level dimension of the service, for example, SYS.ECS,instance_id. Multiple cloud products are separated by semicolons (;), for example, SERVICE.BMS,instance_id;SYS.ECS,instance_id. Constraints: N/A Range [0,10,240] Default Value N/A |
|
resource_level |
No |
String |
Definition Resource level, which indicates the effective resource scope. If you select Cloud product for Resource Level, resources from the selected cloud product and its dimensions will be added to the resource group. If you select Specific dimension for Resource Level, only resources from the specific sub-dimension will be added. Constraints N/A Range product: cloud product
Default Value N/A |
|
comb_relation |
No |
CombRelation object |
Definition Matching resources by combined conditions. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
Yes |
String |
Definition TMS tag key specifications. Constraints N/A Range [1,128] Default Value N/A |
|
operator |
No |
String |
Definition Tag operator, which indicates the relationship between the tag key and value. Constraints N/A Range
Default Value N/A |
|
value |
No |
String |
Definition TMS tag value specifications. Constraints N/A Range [0,255] Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
enterprise_project_id |
No |
String |
Definition Enterprise project ID. Constraints N/A Range The value allows 1 to 128 characters and can only contain letters, digits, underscores (_), and hyphens (-). Default Value N/A |
|
tag |
No |
ResourceGroupTagRelation object |
Definition Tag matching rule. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
namespace |
Yes |
String |
Definition Namespace of a service. For details about the namespace of each service, see Namespace. Constraints N/A Range The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). The value must contain 3 to 32 characters. Default Value N/A |
|
dimensions |
Yes |
Array of ResourceDimension objects |
Definition Resource dimension information. Constraints A maximum of four dimensions are allowed. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
Definition Dimension of a resource. For example, the dimension of an ECS can be instance_id. A maximum of four dimensions are supported. For the metric dimension of each resource, see Service Metric Dimensions. Constraints N/A Range The value starts with a letter and allows 1 to 32 characters. It can contain letters, digits, underscores (_), and hyphens (-). Default Value N/A |
|
value |
Yes |
String |
Definition Resource dimension value, which is an instance ID, for example, 4270ff17-aba3-4138-89fa-820594c39755. Constraints N/A Range 1 to 256 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
product_name |
Yes |
String |
Definition Cloud product that the resource belongs to. Generally, the value format is Service namespace,First-level dimension name of the service, for example, SYS.ECS,instance_id. Constraints N/A Range [0,128] Default Value N/A |
|
namespace |
Yes |
String |
Definition Namespace of a service. For details about the namespace of each service, see Namespace. Constraints N/A Range The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). The value must contain 3 to 32 characters. Default Value N/A |
|
product_instances |
Yes |
Array of ProductInstance objects |
Definition Product instance details. Constraints N/A Range Max. 1,000 instances |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
first_dimension_name |
Yes |
String |
Definition First-level dimension of the resource. For example, the dimension of an ECS is instance_id. Constraints N/A Range Resource dimension. The value must start with a letter and allows a maximum of 32 characters. It can only contain digits, letters, underscores (_), and hyphens (-). Default Value N/A |
|
first_dimension_value |
Yes |
String |
Definition First-level dimension value of the resource, which is the resource ID, for example, 4270ff17-aba3-4138-89fa-820594c39755. Constraints N/A Range 1 to 256 characters Default Value N/A |
|
resource_name |
Yes |
String |
Definition Resource name. Constraints N/A Range 1 to 128 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
product_name |
Yes |
String |
Definition Cloud product name. Constraints N/A Range 1 to 16 characters Default Value N/A |
|
logical_operator |
Yes |
String |
Definition Logical operator. Constraints N/A Range ALL: All conditions are matched. ANY: Any condition is matched. Default Value N/A |
|
instance_names |
Yes |
Array of ResourceNameItem objects |
Definition Parameter array for matching resources by resource name. Constraints Max. 10 names |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
resource_name |
No |
String |
Definition Resource name condition value. Constraints N/A Range [0,128] Default Value N/A |
|
operator |
Yes |
String |
Definition Instance operator, which indicates the operation relationship between the actual resource name and the resource name condition value. Constraints N/A Range
Default Value N/A |
|
resource_name_is_ignore_case |
No |
Boolean |
Definition Resource name (case insensitive). Constraints N/A Range
Default Value false |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
logical_operator |
Yes |
String |
Definition Logical operator. Constraints N/A Range
Default Value N/A |
|
conditions |
Yes |
Array of Condition objects |
Definition Combined matching conditions for resource groups. Constraints A maximum of 50 conditions are allowed. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
enterprise_project_id |
No |
String |
Definition Enterprise project ID. Constraints N/A Range The value can be 0 (ID of the default enterprise project) or consists of digits, letters, or hyphens (-). Default Value N/A |
|
instance_name |
No |
CombResourceName object |
Matching resources by resource name. |
|
tag |
No |
ResourceGroupTagRelation object |
Definition Tag matching rule. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
resource_name |
No |
String |
Definition Resource name condition value. Constraints N/A Range 1 to 128 characters Default Value N/A |
|
operator |
Yes |
String |
Definition Instance operator, which indicates the operation relationship between the actual resource name and the resource name condition value. Constraints N/A Range
Default Value N/A |
|
resource_name_is_ignore_case |
No |
Boolean |
Definition Resource name (case insensitive). Constraints N/A Range
Default Value false |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
group_id |
String |
Definition Resource group ID. Constraints N/A Range The value starts with rg and is followed by 22 characters that may include letters, digits, or a combination of both. It can contain 2 to 24 characters. Default Value N/A |
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
Creating a resource group whose group _name is rg_test and type is TAG.
{
"group_name" : "rg_test",
"enterprise_project_id" : "0",
"type" : "TAG",
"tags" : [ {
"key" : "key1",
"value" : "value1"
} ],
"association_ep_ids" : [ "d61d4705-5658-42f5-8e0c-70eb34d17b02" ]
}
Example Responses
Status code: 200
Created
{
"group_id" : "rg0123456789xxx"
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Created |
|
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