
# 更新安全组
#### 功能介绍
更新安全组。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=VPC&version=v2&api=NeutronUpdateSecurityGroup)中调试该接口。
#### URI
PUT /v2.0/security-groups/{security_group_id}
#### 请求参数
表1请求参数 
| 参数名称           | 类型                                                                        | 是否必选 | 说明                                                                                                                                          |
|:---|:---|:---|:---|
| security_group | [security_group]object | 是    | security_group对象。请参见[表2]。 更新操作时至少指定一项属性。 |
   
 表2Security Group对象 
| 参数名称        | 是否必选 | 类型     | 说明    |
|:---|:---|:---|:---|
| name        | 否    | String | 安全组名称 |
| description | 否    | String | 安全组描述 |
   
#### 请求示例
更新id为d29ae17d-f355-4992-8747-1fb66cc9afd2的安全组，名称更新为sg-test02。
```
PUT https://{Endpoint}/v2.0/security-groups/d29ae17d-f355-4992-8747-1fb66cc9afd2 
{
    "security_group": {
           "name": "sg-test02"
    }
}
```
#### 响应参数
表3响应参数 
| 参数名称           | 类型                                                                            | 说明                                                                              |
|:---|:---|:---|
| security_group | [security_group] object | security_group对象。请参见[表4]。 |
   
 表4Security Group对象 
| 参数名称                 | 类型                                                                                        | 说明                                                                                  |
|:---|:---|:---|
| id                   | String                                                                                    | 安全组的id 使用说明：查询安全组列表非必选               |
| tenant_id            | String                                                                                    | 项目ID                                                                                |
| name                 | String                                                                                    | 安全组名称                                                                               |
| description          | String                                                                                    | 安全组描述                                                                               |
| security_group_rules | Array of [Security Group Rule] objects | security_group_rule列表，参见[表5]     |
| project_id           | String                                                                                    | 项目ID，请参见[获取项目ID](https://support.huaweicloud.com/api-vpc/vpc_api_0011.html)。        |
| created_at           | String                                                                                    | 资源创建时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss |
| updated_at           | String                                                                                    | 资源更新时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss |
   
 表5Security Group Rule对象 
| 参数名称                    | 类型      | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|
| id                      | String  | 安全组规则id 使用说明：查询安全组规则非必选                                                                                                                                                                                                                                                                                                                                                           |
| description             | String  | 安全组规则描述                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| security_group_id       | String  | 所属安全组id                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| remote_group_id         | String  | 所属安全组的对端id                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| direction               | String  | 规则方向                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| remote_ip_prefix        | String  | 对端ip网段                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| protocol                | String  | 协议类型或直接指定IP协议号                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| port_range_max          | Integer | 最大端口，当协议类型为ICMP时，该值表示ICMP的code                                                                                                                                                                                                                                                                                                                                                                                                                 |
| port_range_min          | Integer | 最小端口，当协议类型为ICMP时，该值表示ICMP的type。 protocol为tcp和udp时，port_range_max和port_range_min必须同时输入，且port_range_max应大于等于port_range_min。 protocol为icmp时，指定ICMP code（port_range_max）时，必须同时指定ICMP type（port_range_min）。                                                                                                              |
| ethertype               | String  | 网络类型 支持IPv4，IPv6                                                                                                                                                                                                                                                                                                                                                                   |
| tenant_id               | String  | 项目ID                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| remote_address_group_id | String  | - 功能说明：远端IP地址组ID。  - 约束：和remote_ip_prefix，remote_group_id功能互斥。   |
| project_id              | String  | 项目ID，请参见[获取项目ID](https://support.huaweicloud.com/api-vpc/vpc_api_0011.html)。                                                                                                                                                                                                                                                                                                                                                                   |
| created_at              | String  | 资源创建时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss                                                                                                                                                                                                                                                                                                                                              |
| updated_at              | String  | 资源更新时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss                                                                                                                                                                                                                                                                                                                                              |
   
#### 响应示例
```
{
    "security_group": {
        "id": "d29ae17d-f355-4992-8747-1fb66cc9afd2",
        "name": "sg-test02",
        "description": "",
        "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "security_group_rules": [
            {
                "id": "6332de3e-98fb-4f8c-b44a-fcb8ff09881e",
                "direction": "egress",
                "protocol": null,
                "ethertype": "IPv6",
                "description": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
                "port_range_max": null,
                "port_range_min": null,
                "security_group_id": "d29ae17d-f355-4992-8747-1fb66cc9afd2",
                "remote_address_group_id": "0150a3a7-82ca-4569-865c-04e46e5e9249" 
            },
            {
                "id": "3f51e52c-0e85-40f7-a137-85927392e436",
                "direction": "egress",
                "protocol": null,
                "ethertype": "IPv4",
                "description": null,
                "remote_group_id": null,
                "remote_ip_prefix": null,
                "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
                "port_range_max": null,
                "port_range_min": null,
                "security_group_id": "d29ae17d-f355-4992-8747-1fb66cc9afd2",
                "remote_address_group_id": null
            }
        ],
        "created_at": "2018-09-20T02:15:34",
        "updated_at": "2018-09-20T02:16:31"
    }
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
