華為云計(jì)算 云知識(shí) 查詢安全組列表NeutronListSecurityGroups
查詢安全組列表NeutronListSecurityGroups

 

功能介紹

查詢提交請(qǐng)求的租戶有權(quán)限操作的所有安全組。單次查詢最多返回2000條數(shù)據(jù),超過(guò)2000后會(huì)返回分頁(yè)標(biāo)記。分頁(yè)查詢請(qǐng)參考分頁(yè)查詢

調(diào)試

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

URI

GET /v2.0/security-groups

分頁(yè)查詢樣例:

GET https://{Endpoint}/v2.0/security-groups?limit=2&marker=0431c9c5-1660-42e0-8a00-134bec7f03e2&page_reverse=False

參數(shù)說(shuō)明請(qǐng)參見(jiàn)表1。

表1 參數(shù)說(shuō)明

名稱

是否必選

參數(shù)類型

說(shuō)明

id

String

按照安全組對(duì)應(yīng)的ID過(guò)濾查詢

name

String

按照安全組的名稱過(guò)濾查詢

description

String

按照安全組的描述過(guò)濾查詢

tenant_id

String

按照安全組所屬的項(xiàng)目ID過(guò)濾查詢

marker

String

分頁(yè)查詢的起始資源ID,表示從指定資源的下一條記錄開(kāi)始查詢。

marker需要和limit配合使用:

  • 若不傳入marker和limit參數(shù),查詢結(jié)果返回第一頁(yè)全部資源記錄。
  • 若不傳入marker參數(shù),limit為10,查詢結(jié)果返回第1~10條資源記錄。
  • 若marker為第10條記錄的資源ID,limit為10,查詢結(jié)果返回第11~20條資源記錄。
  • 若marker為第10條記錄的資源ID,不傳入limit參數(shù),查詢結(jié)果返回第11條及之后的所有資源記錄。

limit

Integer

分頁(yè)查詢每頁(yè)返回的記錄個(gè)數(shù),取值范圍為0~intmax(2^31-1),默認(rèn)值2000。

limit需要和marker配合使用,詳細(xì)規(guī)則請(qǐng)見(jiàn)marker的參數(shù)說(shuō)明。

請(qǐng)求參數(shù)

無(wú)。

請(qǐng)求示例

GET https://{Endpoint}/v2.0/security-groups?limit=1

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

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

參數(shù)名稱

類型

說(shuō)明

security_groups

Array of Security Group objects

security group對(duì)象列表。請(qǐng)參見(jiàn)表3

security_groups_links

Array of SecurityGroupsLink objects

分頁(yè)信息。

只有在使用limit過(guò)濾,并且資源個(gè)數(shù)超過(guò)limit或者資源個(gè)數(shù)超過(guò)2000時(shí)(limit默認(rèn)值),該參數(shù)的rel和href取值才會(huì)顯示為next和其對(duì)應(yīng)的link。

表3 Security Group對(duì)象

屬性

類型

說(shuō)明

id

String

安全組的id

使用說(shuō)明:查詢安全組列表非必選

tenant_id

String

項(xiàng)目ID

name

String

安全組名稱

description

String

安全組描述

security_group_rules

Array of Security Group Rule objects

security_group_rule列表,參見(jiàn)表4

project_id

String

項(xiàng)目ID,請(qǐng)參見(jiàn)獲取項(xiàng)目ID。

created_at

String

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

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

updated_at

String

資源更新時(shí)間,UTC時(shí)間

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

表4 Security Group Rule對(duì)象

屬性

類型

說(shuō)明

id

String

安全組規(guī)則id

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

description

String

安全組規(guī)則描述

security_group_id

String

所屬安全組id

remote_group_id

String

所屬安全組的對(duì)端id

direction

String

規(guī)則方向

remote_ip_prefix

String

對(duì)端ip網(wǎng)段

protocol

String

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

port_range_max

Integer

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

port_range_min

Integer

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

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

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

ethertype

String

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

支持IPv4,IPv6

tenant_id

String

項(xiàng)目ID

remote_address_group_id

String

  • 功能說(shuō)明:遠(yuǎn)端IP地址組ID
  • 約束:和remote_ip_prefix,remote_group_id互斥

project_id

String

項(xiàng)目ID,請(qǐng)參見(jiàn)獲取項(xiàng)目ID。

created_at

String

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

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

updated_at

String

資源更新時(shí)間,UTC時(shí)間

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

表5 SecurityGroupsLink對(duì)象

參數(shù)名稱

類型

說(shuō)明

href

String

API鏈接

rel

String

API鏈接與該API版本的關(guān)系

響應(yīng)示例

{
    "security_groups": [
        {
            "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"
        }
    ],
    "security_groups_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/security-groups?limit=1&marker=0431c9c5-1660-42e0-8a00-134bec7f03e2"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/security-groups?limit=1&marker=0431c9c5-1660-42e0-8a00-134bec7f03e2&
page_reverse=True" } ] }

狀態(tài)碼

請(qǐng)參見(jiàn)狀態(tài)碼。

錯(cuò)誤碼

請(qǐng)參考錯(cuò)誤碼