创建安全组规则
功能介绍
创建安全组规则。
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 | 所属安全组的对端id 使用说明:和remote_ip_prefix,remote_address_group_id参数互斥 |
| direction | 是 | String | 规则方向 取值范围:ingress(入方向)/egress(出方向) |
| remote_ip_prefix | 否 | String | 对端ip网段 使用说明:和remote_group_id,remote_address_group_id参数互斥 |
| protocol | 否 | String | 协议类型或直接指定IP协议号 取值范围:tcp/udp/icmp或IP协议号 |
| port_range_max | 否 | Integer | 最大端口,当协议类型为ICMP时,该值表示ICMP的code 取值范围:1-65535(当表示code时为0-255) |
| 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)。 取值范围:1-65535(当表示code时为0-255) |
| ethertype | 否 | String | 网络类型 取值范围:IPv4/IPv6 |
| 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 | 安全组规则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 |
|
| project_id | String | 项目ID,请参见获取项目ID。 |
| created_at | String | 资源创建时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss |
| updated_at | String | 资源更新时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss |
响应示例
{
"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
}
} 状态码
请参见状态码。
错误码
请参见错误码。