华为云计算 云知识 查询安全组列表NeutronListSecurityGroups
查询安全组列表NeutronListSecurityGroups

 

功能介绍

查询提交请求的租户有权限操作的所有安全组。单次查询最多返回2000条数据,超过2000后会返回分页标记。分页查询请参考分页查询

调试

您可以在API Explorer中调试该接口。

URI

GET /v2.0/security-groups

分页查询样例:

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

参数说明请参见表1。

表1 参数说明

名称

是否必选

参数类型

说明

id

String

按照安全组对应的ID过滤查询

name

String

按照安全组的名称过滤查询

description

String

按照安全组的描述过滤查询

tenant_id

String

按照安全组所属的项目ID过滤查询

marker

String

分页查询的起始资源ID,表示从指定资源的下一条记录开始查询。

marker需要和limit配合使用:

  • 若不传入marker和limit参数,查询结果返回第一页全部资源记录。
  • 若不传入marker参数,limit为10,查询结果返回第1~10条资源记录。
  • 若marker为第10条记录的资源ID,limit为10,查询结果返回第11~20条资源记录。
  • 若marker为第10条记录的资源ID,不传入limit参数,查询结果返回第11条及之后的所有资源记录。

limit

Integer

分页查询每页返回的记录个数,取值范围为0~intmax(2^31-1),默认值2000。

limit需要和marker配合使用,详细规则请见marker的参数说明。

请求参数

无。

请求示例

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

响应参数

表2 响应参数

参数名称

类型

说明

security_groups

Array of Security Group objects

security group对象列表。请参见表3

security_groups_links

Array of SecurityGroupsLink objects

分页信息。

只有在使用limit过滤,并且资源个数超过limit或者资源个数超过2000时(limit默认值),该参数的rel和href取值才会显示为next和其对应的link。

表3 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列表,参见表4

project_id

String

项目ID,请参见获取项目ID

created_at

String

资源创建时间,UTC时间

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

updated_at

String

资源更新时间,UTC时间

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

表4 Security Group Rule对象

属性

类型

说明

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

  • 功能说明:远端IP地址组ID
  • 约束:和remote_ip_prefix,remote_group_id互斥

project_id

String

项目ID,请参见获取项目ID

created_at

String

资源创建时间,UTC时间

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

updated_at

String

资源更新时间,UTC时间

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

表5 SecurityGroupsLink对象

参数名称

类型

说明

href

String

API链接

rel

String

API链接与该API版本的关系

响应示例

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

状态码

请参见状态码

错误码

请参考错误码

 

上一篇:云审计主要核心能力竞争分析 下一篇:好望APP扫码添加设备,遇到异常怎么办

虚拟私有云 VPC

虚拟私有云(Virtual Private Cloud)是用户在华为云上申请的隔离的、私密的虚拟网络环境。用户可以自由配置VPC内的IP地址段、子网、安全组等子服务,也可以申请弹性带宽和弹性IP搭建业务系统