
# 更新安全组信息（废弃）
#### 功能介绍
更新安全组。
当前API已废弃，请使用"[更新安全组](https://support.huaweicloud.com/api-vpc/vpc_sg02_0004.html)"。
#### URI
PUT /v2.1/{project_id}/os-security-groups/{security_group_id}
参数说明请参见[表1]。
 表1参数说明 
| 参数                | 是否必选 | 描述                                                                                                        |
|:---|:---|:---|
| project_id        | 是    | 项目ID。 获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-ecs/ecs_01_0016.html)。 |
| security_group_id | 是    | 安全组ID，在URI中指定。                                                                                            |
   
#### 请求消息
请求参数如[表2]所示。
 表2请求参数 
| 参数             | 是否必选 | 参数类型   | 描述                                                                                   |
|:---|:---|:---|:---|
| security_group | 是    | Object | security_group对象，在消息体中指定，参见[表3]。 |
   
 表3请求参数security_group对象 
| 参数          | 是否必选 | 参数类型   | 描述                                                                  |
|:---|:---|:---|:---|
| name        | 是    | String | 安全组名称。 长度不超过255个字符。 |
| description | 是    | String | 安全组描述。 长度不超过255个字符。  |
   
#### 响应消息
响应参数如[表4]所示。
 表4响应参数 
| 参数             | 是否必选 | 参数类型   | 描述                                                                           |
|:---|:---|:---|:---|
| security_group | 是    | Object | security_group对象，请参见[表5]。 |
   
 表5响应参数security_group对象 
| 参数          | 是否必选 | 参数类型             | 描述                                                                         |
|:---|:---|:---|:---|
| description | 是    | String           | 安全组描述信息。 长度不超过255个字符。 |
| id          | 是    | String           | 安全组ID，UUID格式。                                                              |
| name        | 是    | String           | 安全组名称。 长度不超过255个字符。        |
| rules       | 是    | Array of objects | 安全组规则列表，请参见[表6]。       |
| tenant_id   | 是    | String           | 租户ID或项目ID。 长度不超过255个字符。    |
   
 表6security_group_rule对象 
| 参数              | 是否必选 | 参数类型    | 描述                                                                                                               |
|:---|:---|:---|:---|
| parent_group_id | 是    | String  | 相关联的安全组ID，UUID格式。                                                                                                |
| ip_protocol     | 是    | String  | 协议类型或直接指定IP协议号，取值可为icmp，tcp，udp或IP协议号。                                                                           |
| from_port       | 是    | Integer | 起始端口，范围1-65535，且不大于to_port(icmp时，表示type，范围是0-255)。                                                               |
| to_port         | 是    | Integer | 终止端口，范围1-65535，且不小于from_port(icmp时，表示code，范围是0-255，且如果from_port为-1，to_port为-1表示任意ICMP报文)。                        |
| ip_range        | 是    | Object  | 包含对端ip网段，cidr格式，参见[表7]。ip_range或者group参数的值为空。           |
| group           | 是    | Object  | 包括对端安全组的名称和对端安全组所属租户的租户ID，参见[表8]，ip_range或者group参数的值为空。 |
| id              | 是    | String  | 安全组规则ID，UUID格式。                                                                                                  |
   
 表7ip_range对象 
| 参数   | 是否必选 | 参数类型   | 描述                                                                                |
|:---|:---|:---|:---|
| cidr | 是    | String | 对端IP网段，cidr格式。 长度不超过255个字符。 |
   
 表8group对象 
| 参数        | 是否必选 | 参数类型   | 描述              |
|:---|:---|:---|:---|
| tenant_id | 是    | String | 对端安全组所属租户的租户ID。 |
| name      | 是    | String | 对端安全组的名称。       |
   
#### 请求示例
```
PUT https://{endpoint}/v2.1/bb1118612ba64af3a6ea63a1bdcaa5ae/os-security-groups/3d02312d-0764-49c9-8244-2368ddce0045
```
```
{
    "security_group": {
        "name": "test",
        "description": "description"
    }
}
```
#### 响应示例
```
{
  "security_group": {
    "rules": [
      {
        "from_port": null,
        "group": {
          "tenant_id": "bb1118612ba64af3a6ea63a1bdcaa5ae",
          "name": "test"
        },
        "ip_protocol": null,
        "to_port": null,
        "parent_group_id": "3d02312d-0764-49c9-8244-2368ddce0045",
        "ip_range": {},
        "id": "00dec0b6-8e96-4906-aadf-46cfe54cf5ef"
      }
    ],
    "tenant_id": "bb1118612ba64af3a6ea63a1bdcaa5ae",
    "id": "3d02312d-0764-49c9-8244-2368ddce0045",
    "name": "test",
    "description": "description"
  }
}
```
#### 返回值
请参考[通用请求返回值](https://support.huaweicloud.com/api-ecs/ecs_07_0001.html)。
