
# 查询安全组
#### 功能介绍
查询安全组详情。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=VPC&version=v2&api=NeutronShowSecurityGroup)中调试该接口。
#### URI
GET /v2.0/security-groups/{security_group_id}
#### 请求参数
无。
#### 请求示例
```
GET https://{Endpoint}/v2.0/security-groups/0431c9c5-1660-42e0-8a00-134bec7f03e2
```
#### 响应参数
表1响应参数 
| 参数名称           | 类型                                                                        | 说明                                                                           |
|:---|:---|:---|
| security_group | [security_group]object | security group对象。请参见[表2]。 |
   
 表2Security Group对象 
| 参数名称                 | 类型                                                                                        | 说明                                                                                  |
|:---|:---|:---|
| id                   | String                                                                                    | 安全组的id 使用说明：查询安全组列表非必选               |
| tenant_id            | String                                                                                    | 项目ID                                                                                |
| name                 | String                                                                                    | 安全组名称                                                                               |
| description          | String                                                                                    | 安全组描述                                                                               |
| security_group_rules | Array of [Security Group Rule] objects | security_group_rule列表，参见[表3]     |
| 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 |
   
 表3Security 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": "0431c9c5-1660-42e0-8a00-134bec7f03e2",
        "name": "sg-ad3f",
        "description": "",
        "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "security_group_rules": [
            {
                "id": "d90e55ba-23bd-4d97-b722-8cb6fb485d69",
                "direction": "ingress",
                "protocol": null,
                "ethertype": "IPv4",
                "description": null,
                "remote_group_id": "0431c9c5-1660-42e0-8a00-134bec7f03e2",
                "remote_ip_prefix": null,
                "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
                "port_range_max": null,
                "port_range_min": null,
                "security_group_id": "0431c9c5-1660-42e0-8a00-134bec7f03e2",
                "remote_address_group_id": "0150a3a7-82ca-4569-865c-04e46e5e9249" 
            },
            {
                "id": "aecff4d4-9ce9-489c-86a3-803aedec65f7",
                "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": "0431c9c5-1660-42e0-8a00-134bec7f03e2",
                "remote_address_group_id": null
            }
        ],
        "created_at": "2018-09-12T08:24:14",
        "updated_at": "2018-09-12T08:24:14"
    }
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参考[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
