華為云計(jì)算 云知識(shí) 查詢安全組規(guī)則列表NeutronListSecurityGroupRules
查詢安全組規(guī)則列表NeutronListSecurityGroupRules

 

功能介紹

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

調(diào)試

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

URI

GET /v2.0/security-group-rules

樣例:

GET https://{Endpoint}/v2.0/security-group-rules?security_group_id={security_group_id}&
remote_group_id={remote_group_id}&direction={direction}&
remote_ip_prefix={remote_ip_prefix}&protocol={protocol}&port_range_max={port_range_max}&
port_range_min={port_range_min}&ethertype={ethertype}&
tenant_id ={tenant_id}

分頁(yè)查詢樣例:

GET https://{Endpoint}/v2.0/networks?limit=2&marker=07adc044-3f21-4eeb-bd57-5e5eb6024b7f&page_reverse=False

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

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

名稱

是否必選

參數(shù)類型

說(shuō)明

id

String

按照安全組規(guī)則對(duì)應(yīng)的id過(guò)濾查詢結(jié)果

description

String

按照description過(guò)濾查詢結(jié)果

remote_group_id

String

按照與此安全組規(guī)則關(guān)聯(lián)的遠(yuǎn)端安全組ID過(guò)濾查詢結(jié)果

security_group_id

String

按照與此安全組規(guī)則所屬的安全組ID過(guò)濾查詢結(jié)果

direction

String

按照安全組規(guī)則的方向過(guò)濾查詢結(jié)果,支持ingress和egress進(jìn)行過(guò)濾

protocol

String

按照安全組規(guī)則的IP協(xié)議過(guò)濾查詢結(jié)果

remote_ip_prefix

String

按照與此安全組規(guī)則匹配的遠(yuǎn)端IP網(wǎng)段過(guò)濾查詢結(jié)果

ethertype

String

按照網(wǎng)絡(luò)類型過(guò)濾查詢結(jié)果

port_range_max

Integer

按照最大端口過(guò)濾查詢結(jié)果

port_range_min

Integer

按照最小端口過(guò)濾查詢結(jié)果

tenant_id

String

按照項(xiàng)目ID過(guò)濾查詢結(jié)果

marker

String

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

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)見marker的參數(shù)說(shuō)明。

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

無(wú)。

請(qǐng)求示例

GET https://{Endpoint}/v2.0/security-group-rules

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

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

參數(shù)名稱

類型

說(shuō)明

security_group_rules

Array of Security Group Rule objects

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

security_group_rules_links

Array of SecurityGroupRulesLink 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 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)參見獲取項(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 SecurityGroupRulesLink對(duì)象

參數(shù)名稱

類型

說(shuō)明

href

String

API鏈接

rel

String

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

響應(yīng)示例

{
    "security_group_rules": [
        {
            "remote_group_id": "1d8b19c7-7c56-48f7-a99b-4b40eb390967", 
            "direction": "ingress", 
            "remote_ip_prefix": null, 
            "protocol": null, 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "port_range_max": null, 
            "security_group_id": "1d8b19c7-7c56-48f7-a99b-4b40eb390967", 
            "port_range_min": null, 
            "ethertype": "IPv6", 
            "description": null, 
            "id": "07adc044-3f21-4eeb-bd57-5e5eb6024b7f",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "created_at": "2018-09-20T02:15:34",
            "updated_at": "2018-09-20T02:15:34",
            "remote_address_group_id": null
        }, 
        {
            "remote_group_id": null, 
            "direction": "egress", 
            "remote_ip_prefix": null, 
            "protocol": null, 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "port_range_max": null, 
            "security_group_id": "328fb454-a2ee-4a11-bdb1-ee19bbdfde43", 
            "port_range_min": null, 
            "ethertype": "IPv6", 
            "description": null, 
            "id": "09358f83-f4a5-4386-9563-a1e3c373d655",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "created_at": "2018-09-20T02:15:34",
            "updated_at": "2018-09-20T02:15:34",
            "remote_address_group_id": null
        }, 
        {
            "remote_group_id": "4c763030-366e-428c-be2b-d48f6baf5297", 
            "direction": "ingress", 
            "remote_ip_prefix": null, 
            "protocol": null, 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "port_range_max": null, 
            "security_group_id": "4c763030-366e-428c-be2b-d48f6baf5297", 
            "port_range_min": null, 
            "ethertype": "IPv6", 
            "description": null, 
            "id": "219a6f56-1069-458b-bec0-df9270e7a074",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "created_at": "2018-09-20T02:15:34",
            "updated_at": "2018-09-20T02:15:34",
            "remote_address_group_id": null
        }
    ],
    "security_group_rules_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/
security-group-rules?marker=07adc044-3f21-4eeb-bd57-5e5eb6024b7f&page_reverse=True"
        }
    ]
}

狀態(tài)碼

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

錯(cuò)誤碼

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