功能介绍
创建安全组。
调试
您可以在API Explorer中调试该接口。
URI
POST /v2.0/security-groups
请求参数
请求示例
创建安全组,命名为sg-test。
POST https://{Endpoint}/v2.0/security-groups
{
"security_group": {
"name": "sg-test"
}
}
响应参数
属性 |
类型 |
说明 |
---|---|---|
id |
String |
安全组的id 使用说明:查询安全组列表非必选 |
tenant_id |
String |
项目ID |
name |
String |
安全组名称 |
description |
String |
安全组描述 |
security_group_rules |
||
project_id |
String |
项目ID,请参见获取项目ID。 |
created_at |
String |
资源创建时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss |
updated_at |
String |
资源更新时间,UTC时间 格式:yyyy-MM-ddTHH:mm:ss |
属性 |
类型 |
说明 |
---|---|---|
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": {
"id": "d29ae17d-f355-4992-8747-1fb66cc9afd2",
"name": "sg-test",
"description": "",
"tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
"project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
"security_group_rules": [
{
"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
},
{
"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": null
}
],
"created_at": "2018-09-20T02:15:34",
"updated_at": "2018-09-20T02:15:34"
}
}
状态码
请参见状态码。
错误码
请参考错误码。