Skip to content

List Firewall Rules for VM ​

Retrieves existing firewall rules for a virtual machine.

HTTP Request ​

GET {API_URL}/virtual-machines/{id}/firewall-rules

Path parameters ​

ParametersRequirementsTypeDescription
idRequiredstringThe unique identifier of the virtual machine for which to retrieve details.

Query string parameters ​

ParametersRequirementsTypeDescription
limitOptionalintThe number of items to return
offsetOptionalintThe number of items to skip before starting to collect the result set
sortFieldOptionalstringThe field by which the data will be ordered
sortOrderOptionalstringSorting order: desc、asc

Reponse Attributes ​

status boolean ​

Indicates the result of the request to create virtual machine. true signifies success, while false indicates an error.

message string ​

A message confirming the status of the request to list firewall rules.

total int ​

Total records count

data object ​

An array of existing firewall rule for a virtual machine, each containing details about a firewall rule specifies.

Each firewall rule specifies the following properties:

  • direction: The direction of traffic that the firewall rule applies to. Possible values: one of inbound (incoming traffic) or outbound (outgoing traffic).
  • protocol: The network protocol associated with the rule. Possible values: one of tcp or udp or icmp
  • ethertype: The Ethernet type associated with the rule. Possible values: one of IPv4 or IPv6.
  • remote_ip_prefix: The IP address range that is allowed to access the specified port.
  • port_range_min: The minimum port number in the range of ports to be allowed by the firewall rule. Values 1-65535 are accepted.
  • port_range_max: The maximum port number in the range of ports to be allowed by the firewall rule. Values 1-65535 are accepted.
  • description: An optional description of the firewall rule.

Example ​

Request ​

curl -X GET '{API_URL}virtual-machines/{id}/firewall-rules' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'refresh-token: {REFRESH_TOKEN}' \
-H 'Content-Type: application/json'

Response ​

{
    "status": true,
    "message": "Getting firewall rules successful",
    "data": [
        {
            "id": "670897c9175a690012c8056f",
            "direction": "inbound",
            "ethertype": "IPv4",
            "protocol": "tcp",
            "port_range_min": 80,
            "port_range_max": 80,
            "remote_ip_prefix": "0.0.0.0/0",
            "created_at": 1728616393,
            "description": "HTTP"
        },
        {
            "id": "670896d4175a690012c804f9",
            "direction": "inbound",
            "ethertype": "IPv4",
            "protocol": "tcp",
            "port_range_min": 22,
            "port_range_max": 22,
            "remote_ip_prefix": "0.0.0.0/0",
            "created_at": 1728616133,
            "description": ""
        },
        {
            "id": "670896d4175a690012c804f7",
            "direction": "outbound",
            "ethertype": "IPv4",
            "protocol": "any",
            "port_range_min": 1,
            "port_range_max": 65535,
            "remote_ip_prefix": "0.0.0.0/0",
            "created_at": 1728616128,
            "description": ""
        },
        {
            "id": "670896d4175a690012c804fc",
            "direction": "outbound",
            "ethertype": "IPv6",
            "protocol": "any",
            "port_range_min": 1,
            "port_range_max": 65535,
            "remote_ip_prefix": "0.0.0.0/0",
            "created_at": 1728616128,
            "description": ""
        }
    ]
}