创建安全组
功能介绍
创建安全组。
 
    在创建安全组后,默认配置允许任何IP地址访问TCP协议的22端口和3389端口,这意味着允许SSH连接和RDP访问,存在一定安全隐患。
调试
您可以在API Explorer中调试该接口。
URI
POST /v1/{project_id}/security-groups
请求参数
| 
         名称  | 
       
         是否必选  | 
       
         参数类型  | 
       
         说明  | 
      
|---|---|---|---|
| 
         security_group  | 
       
         是  | 
       
         security_group object  | 
       
         安全组对象,请参见表3。  | 
      
| 
         名称  | 
       
         是否必选  | 
       
         参数类型  | 
       
         说明  | 
      
|---|---|---|---|
| 
         name  | 
       
         是  | 
       
         String  | 
       
        
  | 
      
| 
         vpc_id  | 
       
         否  | 
       
         String  | 
       
         安全组所在的vpc的资源标识。 
          说明: 
          当前该参数只作提示用,不约束安全组在此vpc下,不建议继续使用。  | 
      
| 
         enterprise_project_id  | 
       
         否  | 
       
         String  | 
       
        
 
          说明: 
          关于企业项目ID的获取及企业项目特性的详细信息,请参见《企业管理用户指南》。  | 
      
请求示例
- 创建一个安全组,命名为sg-01,所在vpc id为3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85。 
     
POST https://{Endpoint}/v1/{project_id}/security-groups { "security_group": { "name": "sg-01", "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85", "enterprise_project_id": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2" } } 
响应参数
| 
         名称  | 
       
         参数类型  | 
       
         说明  | 
      
|---|---|---|
| 
         security_group  | 
       
         security_group object  | 
       
         安全组对象,请参见表5。  | 
      
| 
         名称  | 
       
         参数类型  | 
       
         说明  | 
      
|---|---|---|
| 
         name  | 
       
         String  | 
       
         安全组名称。  | 
      
| 
         description  | 
       
         String  | 
       
         安全组描述。  | 
      
| 
         id  | 
       
         String  | 
       
         安全组唯一标识。  | 
      
| 
         vpc_id  | 
       
         String  | 
       
         安全组所在的vpc的资源标识。 
          说明: 
          当前该参数只作提示用,不约束安全组在此vpc下,不建议继续使用。  | 
      
| 
         security_group_rules  | 
       
         Array of security_group_rule objects  | 
       
         默认安全组规则列表,保证安全组内互通。  | 
      
| 
         enterprise_project_id  | 
       
         String  | 
       
        
 
          说明: 
          关于企业项目ID的获取及企业项目特性的详细信息,请参见《企业管理用户指南》。  | 
      
| 
         名称  | 
       
         参数类型  | 
       
         说明  | 
      
|---|---|---|
| 
         id  | 
       
         String  | 
       
         安全组规则标识。  | 
      
| 
         description  | 
       
         String  | 
       
        
  | 
      
| 
         security_group_id  | 
       
         String  | 
       
         安全组标识。  | 
      
| 
         direction  | 
       
         String  | 
       
        
  | 
      
| 
         ethertype  | 
       
         String  | 
       
        
  | 
      
| 
         protocol  | 
       
         String  | 
       
        
  | 
      
| 
         port_range_min  | 
       
         Integer  | 
       
        
  | 
      
| 
         port_range_max  | 
       
         Integer  | 
       
        
  | 
      
| 
         remote_ip_prefix  | 
       
         String  | 
       
        
  | 
      
| 
         remote_group_id  | 
       
         String  | 
       
        
  | 
      
| 
         remote_address_group_id  | 
       
         String  | 
       
        
  | 
      
| 
         tenant_id  | 
       
         String  | 
       
        
  | 
      
响应示例
{
    "security_group": {
        "id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", 
        "name": "qq", 
        "description": "", 
        "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85", 
        "enterprise_project_id": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2",
        "security_group_rules": [
           {
                "id": "f11a3824-ac19-4fad-b4f1-c5f4a6dd0a80",
                "tenant_id": "060576782980d5762f9ec014dd2f1148", 
                "security_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "remote_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "direction": "ingress", 
                "protocol": null, 
                "description": "", 
                "ethertype": "IPv6", 
                "remote_ip_prefix": null, 
                "remote_address_group_id": null,
                "port_range_max": null,
                "port_range_min": null
            }, 
            {
                "id": "3d6480e8-9ea4-46dc-bb1b-8db190cd5677",
                "tenant_id": "060576782980d5762f9ec014dd2f1148", 
                "security_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "remote_group_id": null, 
                "direction": "egress", 
                "protocol": null, 
                "description": "", 
                "ethertype": "IPv6", 
                "remote_ip_prefix": null, 
                "remote_address_group_id": null,
                "port_range_max": null,
                "port_range_min": null
            }, 
            {
                "id": "9581f18c-1fdd-43da-ace9-7758a56ef28a", 
                "tenant_id": "060576782980d5762f9ec014dd2f1148", 
                "security_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "remote_group_id": null, 
                "direction": "egress", 
                "protocol": null, 
                "description": "", 
                "ethertype": "IPv4", 
                "remote_ip_prefix": null, 
                "remote_address_group_id": null,
                "port_range_max": null,
                "port_range_min": null
            }, 
            {
                "id": "a3ba270e-e58b-432d-a912-aeb7eace9fb8", 
                "tenant_id": "060576782980d5762f9ec014dd2f1148", 
                "security_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "remote_group_id": "69c999ad-d9ef-4d79-94fd-35e6ceb75325", 
                "direction": "ingress", 
                "protocol": null, 
                "description": "", 
                "ethertype": "IPv4", 
                "remote_ip_prefix": null, 
                "remote_address_group_id": null,
                "port_range_max": null,
                "port_range_min": null
            }
        ]
    }
}
  状态码
请参见状态码。
错误码
请参考错误码。