创建安全组规则
功能介绍
创建安全组规则。默认创建允许策略,如需创建拒绝策略,请移步V3接口参考创建安全组规则的action参数说明。
调试
您可以在API Explorer中调试该接口。
URI
POST /v2.0/security-group-rules
请求参数
参数名称 | 类型 | 必选 | 说明 |
|---|---|---|---|
security_group_rule | security_group_rule object | 是 | security group rule对象。请参见表2。 |
参数名称 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
description | 否 | String | 安全组规则描述。 |
security_group_id | 是 | String | 所属安全组id。 |
remote_group_id | 否 | String |
|
direction | 是 | String |
|
remote_ip_prefix | 否 | String |
|
protocol | 否 | String |
|
port_range_max | 否 | Integer |
|
port_range_min | 否 | Integer |
|
ethertype | 否 | String |
|
remote_address_group_id | 否 | String |
|
请求示例
创建出方向安全组规则,所在安全组id为5cb9c1ee-00e0-4d0f-9623-55463cd26ff8,协议为tcp,对端ip为10.10.0.0/24。
POST https://{Endpoint}/v2.0/security-group-rules
{
"security_group_rule": {
"security_group_id": "5cb9c1ee-00e0-4d0f-9623-55463cd26ff8",
"direction": "egress",
"protocol": "tcp",
"remote_ip_prefix": "10.10.0.0/24"
}
} 响应参数
参数名称 | 类型 | 说明 |
|---|---|---|
security_group_rule | security_group_rule object | security group rule对象。请参见表4。 |
参数名称 | 类型 | 说明 |
|---|---|---|
id | String |
|
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 |
|
port_range_min | Integer |
|
ethertype | String |
|
tenant_id | String | 项目ID |
remote_address_group_id | String |
|
project_id | String | 项目ID,请参见获取项目ID。 |
created_at | String |
|
updated_at | String |
|
响应示例
{
"security_group_rule": {
"remote_group_id": null,
"direction": "egress",
"remote_ip_prefix": "10.10.0.0/24",
"protocol": "tcp",
"tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
"port_range_max": null,
"security_group_id": "5cb9c1ee-00e0-4d0f-9623-55463cd26ff8",
"port_range_min": null,
"ethertype": "IPv4",
"description": null,
"id": "7c336b04-1603-4911-a6f4-f2af1d9a0488",
"project_id": "6fbe9263116a4b68818cf1edce16bc4f",
"created_at": "2018-09-20T02:15:34",
"updated_at": "2018-09-20T02:15:34",
"remote_address_group_id": null
}
} 状态码
请参见状态码。
错误码
请参见错误码。

