華為云計算 云知識 創(chuàng)建安全組NeutronCreateSecurityGroup
創(chuàng)建安全組NeutronCreateSecurityGroup

 

功能介紹

創(chuàng)建安全組。

調(diào)試

您可以在API Explorer中調(diào)試該接口。

URI

POST /v2.0/security-groups

請求參數(shù)

表1 請求參數(shù)

參數(shù)名稱

是否必選

類型

說明

security_group

security_group object

security group對象。請參見表2

表2 Security Group對象

屬性

是否必選

類型

說明

name

String

安全組名稱

description

String

安全組描述

請求示例

創(chuàng)建安全組,命名為sg-test。

POST https://{Endpoint}/v2.0/security-groups 

{
    "security_group": {
           "name": "sg-test"
    }
}

響應(yīng)參數(shù)

表3 響應(yīng)參數(shù)

參數(shù)名稱

類型

說明

security_group

security_group object

security group對象。請參見表4。

表4 Security Group對象

屬性

類型

說明

id

String

安全組的id

使用說明:查詢安全組列表非必選

tenant_id

String

項目ID

name

String

安全組名稱

description

String

安全組描述

security_group_rules

Array of Security Group Rule objects

security_group_rule列表,參見表5

project_id

String

項目ID,請參見獲取項目ID。

created_at

String

資源創(chuàng)建時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

updated_at

String

資源更新時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

表5 Security Group Rule對象

屬性

類型

說明

id

String

安全組規(guī)則id

使用說明:查詢安全組規(guī)則非必選

description

String

安全組規(guī)則描述

security_group_id

String

所屬安全組id

remote_group_id

String

所屬安全組的對端id

direction

String

規(guī)則方向

remote_ip_prefix

String

對端ip網(wǎng)段

protocol

String

協(xié)議類型或直接指定IP協(xié)議號

port_range_max

Integer

最大端口,當協(xié)議類型為ICMP時,該值表示ICMP的code

port_range_min

Integer

最小端口,當協(xié)議類型為ICMP時,該值表示ICMP的type。

protocol為tcp和udp時,port_range_max和port_range_min必須同時輸入,且port_range_max應(yīng)大于等于port_range_min。

protocol為icmp時,指定ICMP code(port_range_max)時,必須同時指定ICMP type(port_range_min)。

ethertype

String

網(wǎng)絡(luò)類型

支持IPv4,IPv6

tenant_id

String

項目ID

remote_address_group_id

String

  • 功能說明:遠端IP地址組ID
  • 約束:和remote_ip_prefix,remote_group_id互斥

project_id

String

項目ID,請參見獲取項目ID。

created_at

String

資源創(chuàng)建時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

updated_at

String

資源更新時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

響應(yīng)示例

{
    "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"
    }
}

狀態(tài)碼

請參見狀態(tài)碼。

錯誤碼

請參考錯誤碼。