• Virtual Private Cloud

vpc
  1. Help Center
  2. Virtual Private Cloud
  3. API Reference
  4. APIs
  5. Security Group
  6. Querying Security Groups

Querying Security Groups

Function

This interface is used to query security groups using search criteria and to display the security groups in a list.

URI

GET /v1/{project_id}/security-groups

Example:
/v1/{project_id}/security-groups?limit=10&marker=4779ab1c-7c1a-44b1-
a02e-93dfc361b32d&vpc_id=3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85
Table 1 Parameter description

Name

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

marker

No

String

Specifies the start resource ID of pagination query. If the parameter is left blank, only resources on the first page are queried.

limit

No

int

  • Specifies the number of records returned on each page.
  • The value ranges from 0 to intmax.

vpc_id

No

String

Specifies that the VPC ID is used as the filtering condition.

Request Message

  • Request parameter

    None

  • Example request

    None

Response Message

  • Response parameter
    Table 2 Response parameter

    Name

    Type

    Description

    security_groups

    List data structure

    Specifies the security group list.

    Table 3 Description of security_group fields

    Name

    Type

    Description

    name

    String

    Specifies the security group name.

    description

    String

    Provides supplementary information about the security group.

    id

    String

    Specifies the security group ID, which uniquely identifies the security group.

    vpc_id

    String

    Specifies the resource ID of the VPC to which the security group belongs.

    security_group_rules

    List data structure

    Specifies the default security group rule, which ensures that resources in the security group can communicate with one another.

    Table 4 security_group_rules object

    Name

    Type

    Description

    id

    String

    Specifies the security group rule ID, which uniquely identifies the security group rule.

    description

    String

    • Provides supplementary information about the security group rule.
    • The value is a string of no more than 255 characters that can contain letters and digits.

    security_group_id

    String

    Specifies the security group rule ID, which uniquely identifies the security group rule.

    direction

    String

    • Specifies the direction of access control.
    • The value can be egress or ingress.

    ethertype

    String

    • Specifies the IP protocol version.
    • The value can be IPv4 or IPv6.

    protocol

    String

    • Specifies the protocol type.
    • The value can be icmp, tcp, or udp.
    • If the parameter is left blank, all protocols are supported.

    port_range_min

    int

    • Specifies the start port number.
    • The value ranges from 1 to 65535.
    • The value cannot be greater than the port_range_max value. An empty value indicates all ports. If the protocol is icmp, the value range is shown in ICMP-Port Range Relationship Table.

    port_range_max

    int

    • Specifies the end port number.
    • The value ranges from 1 to 65535.
    • If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports. If the protocol is icmp, the value range is shown in ICMP-Port Range Relationship Table.

    remote_ip_prefix

    String

    • Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address.
    • The value can be in the CIDR format or IP addresses.
    • The parameter is exclusive with parameter remote_group_id.

    remote_group_id

    String

    • Specifies the ID of the peer security group.
    • The value is exclusive with parameter remote_ip_prefix.
  • Example response
    {
        "security_groups": [
            {
                "id": "16b6e77a-08fa-42c7-aa8b-106c048884e6", 
                "name": "qq", 
                "description": "qq", 
                "vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85", 
               
                "security_group_rules": [
                    {
                        "direction": "egress", 
                        "ethertype": "IPv4", 
                        "id": "369e6499-b2cb-4126-972a-97e589692c62", 
                        "description": "",
                        "security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6"
                    }, 
                    {
                        "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", 
               
                "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"
                    }
                ]
            }
        ]
    }

Status Codes

For details, see section Status Codes.

Error Codes

For details, see section Error Codes.