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

 

功能介紹

查詢安全組列表。

調(diào)試

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

URI

GET /v1/{project_id}/security-groups

樣例:
GET https://{Endpoint}/v1/{project_id}/security-groups?
limit=10&marker=4779ab1c-7c1a-44b1-a02e-93dfc361b32d&vpc_id=3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85
參數(shù)說明請(qǐng)參見表1。
表1 參數(shù)說明

名稱

是否必選

參數(shù)類型

說明

project_id

String

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

marker

String

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

marker需要和limit配合使用:

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

limit

Integer

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

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

vpc_id

String

按照vpc_id過濾查詢

enterprise_project_id

String

  • 功能說明:企業(yè)項(xiàng)目ID??梢允褂迷撟侄芜^濾某個(gè)企業(yè)項(xiàng)目下的安全組。
  • 取值范圍:最大長(zhǎng)度36字節(jié),帶“-”連字符的UUID格式,或者是字符串“0”。“0”表示默認(rèn)企業(yè)項(xiàng)目。若需要查詢當(dāng)前用戶所有企業(yè)項(xiàng)目綁定的安全組,或者企業(yè)項(xiàng)目子帳號(hào)需要進(jìn)行安全組列表展示,請(qǐng)傳參all_granted_eps。
說明:

關(guān)于企業(yè)項(xiàng)目ID的獲取及企業(yè)項(xiàng)目特性的詳細(xì)信息,請(qǐng)參見《企業(yè)管理用戶指南》

remote_address_group_id

String

  • 功能說明:遠(yuǎn)端IP地址組ID。您可以登錄管理控制臺(tái),在IP地址組頁面查看該ID。
  • 約束:和remote_ip_prefix,remote_group_id互斥

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

請(qǐng)求示例

GET https://{Endpoint}/v1/{project_id}/security-groups

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

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

名稱

參數(shù)類型

說明

security_groups

Array of security_group objects

安全組列表對(duì)象,請(qǐng)參見表3。

表3 security_group字段說明

名稱

參數(shù)類型

說明

name

String

安全組名稱

description

String

安全組描述

id

String

安全組唯一標(biāo)識(shí)

vpc_id

String

安全組所在的vpc的資源標(biāo)識(shí)

說明:

該參數(shù)功能已廢棄,不建議繼續(xù)使用。

當(dāng)前該參數(shù)只作提示用,不約束安全組在此vpc下。

security_group_rules

Array of security_group_rule objects

默認(rèn)安全組規(guī)則列表,保證安全組內(nèi)互通。

enterprise_project_id

String

  • 功能說明:企業(yè)項(xiàng)目ID。創(chuàng)建安全組時(shí),給安全組綁定企業(yè)項(xiàng)目ID。
  • 取值范圍:最大長(zhǎng)度36字節(jié),帶“-”連字符的UUID格式,或者是字符串“0”。“0”表示默認(rèn)企業(yè)項(xiàng)目。
說明:

關(guān)于企業(yè)項(xiàng)目ID的獲取及企業(yè)項(xiàng)目特性的詳細(xì)信息,請(qǐng)參見《企業(yè)管理用戶指南》。

表4 security_group_rule對(duì)象

名稱

參數(shù)類型

說明

id

String

安全組規(guī)則標(biāo)識(shí)

description

String

  • 功能說明:安全組規(guī)則描述
  • 取值范圍:0-255個(gè)字符,支持?jǐn)?shù)字、字母、中文字符

security_group_id

String

安全組標(biāo)識(shí)

direction

String

  • 功能說明:出入控制方向
  • 取值范圍:
    • egress:出方向
    • ingress:入方向

ethertype

String

  • 功能說明:IP協(xié)議類型
  • 取值范圍:IPv4,IPv6

protocol

String

  • 功能說明:協(xié)議類型
  • 取值范圍:icmp、tcp、udp、icmpv6等
  • 約束:為空表示支持所有協(xié)議

port_range_min

Integer

port_range_max

Integer

remote_ip_prefix

String

  • 功能說明:遠(yuǎn)端IP地址,當(dāng)direction是egress時(shí)為虛擬機(jī)訪問端的地址,當(dāng)direction是ingress時(shí)為訪問虛擬機(jī)的地址
  • 取值范圍:IP地址,或者cidr格式
  • 約束:和remote_group_id,remote_address_group_id互斥

remote_group_id

String

  • 功能說明:對(duì)端安全組id
  • 約束:和remote_ip_prefix,remote_address_group_id互斥

remote_address_group_id

String

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

tenant_id

String

  • 功能說明:安全組規(guī)則所屬項(xiàng)目ID

響應(yīng)示例

{
    "security_groups": [
        {
            "id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", 
            "name": "qq", 
            "description": "qq", 
            "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85", 
            "enterprise_project_id": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2",
            "security_group_rules": [
                {
                    "direction": "egress", 
                    "ethertype": "IPv4", 
                    "id": "369e6499-b2cb-4126-972a-97e589692c62", 
                    "description": "",
                    "security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6",
                    "remote_address_group_id": null
                }, 
                {
                    "direction": "ingress", 
                    "ethertype": "IPv4", 
                    "id": "0222556c-6556-40ad-8aac-9fd5d3c06171", 
                    "description": "",
                    "remote_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", 
                    "security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6"
                }
            ]
        }, 
        {
            "id": "9c0f56be-a9ac-438c-8c57-fce62de19419", 
            "name": "default", 
            "description": "qq", 
            "vpc_id": "13551d6b-755d-4757-b956-536f674975c0", 
            "enterprise_project_id": "0",
            "security_group_rules": [
                {
                    "direction": "egress", 
                    "ethertype": "IPv4", 
                    "id": "95479e0a-e312-4844-b53d-a5e4541b783f", 
                    "description": "",
                    "security_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419"
                }, 
                {
                    "direction": "ingress", 
                    "ethertype": "IPv4", 
                    "id": "0c4a2336-b036-4fa2-bc3c-1a291ed4c431",
                    "description": "", 
                    "remote_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419", 
                    "security_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419"
                }
            ]
        }
    ]
}

狀態(tài)碼

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

錯(cuò)誤碼

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