Skip to content
  • Auto
  • Light
  • Dark

List Firewalls

List all Firewalls Applied to a Droplet
client.gpuDroplets.listFirewalls(numberdropletID, GPUDropletListFirewallsParams { page, per_page } query?, RequestOptionsoptions?): GPUDropletListFirewallsResponse { meta, firewalls, links }
get/v2/droplets/{droplet_id}/firewalls

To retrieve a list of all firewalls available to a Droplet, send a GET request to /v2/droplets/$DROPLET_ID/firewalls

The response will be a JSON object that has a key called firewalls. This will be set to an array of firewall objects, each of which contain the standard firewall attributes.

ParametersExpand Collapse
dropletID: number
query: GPUDropletListFirewallsParams { page, per_page }
page?: number

Which 'page' of paginated results to return.

minimum1
per_page?: number

Number of items returned per page

minimum1
maximum200
ReturnsExpand Collapse
GPUDropletListFirewallsResponse { meta, firewalls, links }
meta: MetaProperties { total }

Information about the response itself.

total?: number

Number of objects returned by the request.

firewalls?: Array<Firewall { id, created_at, droplet_ids, 6 more } >
id?: string

A unique ID that can be used to identify and reference a firewall.

created_at?: string

A time value given in ISO8601 combined date and time format that represents when the firewall was created.

formatdate-time
droplet_ids?: Array<number> | null

An array containing the IDs of the Droplets assigned to the firewall.

Requires droplet:read scope.

inbound_rules?: Array<InboundRule> | null
ports: string

The ports on which traffic will be allowed specified as a string containing a single port, a range (e.g. "8000-9000"), or "0" when all ports are open for a protocol. For ICMP rules this parameter will always return "0".

protocol: "tcp" | "udp" | "icmp"

The type of traffic to be allowed. This may be one of tcp, udp, or icmp.

Accepts one of the following:
"tcp"
"udp"
"icmp"
sources: FirewallRuleTarget { addresses, droplet_ids, kubernetes_ids, 2 more }

An object specifying locations from which inbound traffic will be accepted.

addresses?: Array<string>

An array of strings containing the IPv4 addresses, IPv6 addresses, IPv4 CIDRs, and/or IPv6 CIDRs to which the firewall will allow traffic.

droplet_ids?: Array<number>

An array containing the IDs of the Droplets to which the firewall will allow traffic.

kubernetes_ids?: Array<string>

An array containing the IDs of the Kubernetes clusters to which the firewall will allow traffic.

load_balancer_uids?: Array<string>

An array containing the IDs of the load balancers to which the firewall will allow traffic.

tags?: Array<string> | null

A flat array of tag names as strings to be applied to the resource. Tag names must exist in order to be referenced in a request.

Requires tag:create and tag:read scopes.

name?: string

A human-readable name for a firewall. The name must begin with an alphanumeric character. Subsequent characters must either be alphanumeric characters, a period (.), or a dash (-).

outbound_rules?: Array<OutboundRule> | null
destinations: FirewallRuleTarget { addresses, droplet_ids, kubernetes_ids, 2 more }

An object specifying locations to which outbound traffic that will be allowed.

addresses?: Array<string>

An array of strings containing the IPv4 addresses, IPv6 addresses, IPv4 CIDRs, and/or IPv6 CIDRs to which the firewall will allow traffic.

droplet_ids?: Array<number>

An array containing the IDs of the Droplets to which the firewall will allow traffic.

kubernetes_ids?: Array<string>

An array containing the IDs of the Kubernetes clusters to which the firewall will allow traffic.

load_balancer_uids?: Array<string>

An array containing the IDs of the load balancers to which the firewall will allow traffic.

tags?: Array<string> | null

A flat array of tag names as strings to be applied to the resource. Tag names must exist in order to be referenced in a request.

Requires tag:create and tag:read scopes.

ports: string

The ports on which traffic will be allowed specified as a string containing a single port, a range (e.g. "8000-9000"), or "0" when all ports are open for a protocol. For ICMP rules this parameter will always return "0".

protocol: "tcp" | "udp" | "icmp"

The type of traffic to be allowed. This may be one of tcp, udp, or icmp.

Accepts one of the following:
"tcp"
"udp"
"icmp"
pending_changes?: Array<PendingChange>

An array of objects each containing the fields "droplet_id", "removing", and "status". It is provided to detail exactly which Droplets are having their security policies updated. When empty, all changes have been successfully applied.

droplet_id?: number
removing?: boolean
status?: string
status?: "waiting" | "succeeded" | "failed"

A status string indicating the current state of the firewall. This can be "waiting", "succeeded", or "failed".

Accepts one of the following:
"waiting"
"succeeded"
"failed"
tags?: Array<string> | null

A flat array of tag names as strings to be applied to the resource. Tag names must exist in order to be referenced in a request.

Requires tag:create and tag:read scopes.

Accepts one of the following:

URI of the last page of the results.

URI of the next page of the results.

URI of the first page of the results.

URI of the previous page of the results.

List all Firewalls Applied to a Droplet
import Gradient from '@digitalocean/gradient';

const client = new Gradient();

const response = await client.gpuDroplets.listFirewalls(3164444);

console.log(response.meta);
{
  "meta": {
    "total": 1
  },
  "firewalls": [
    {
      "droplet_ids": [
        8043964
      ],
      "inbound_rules": [
        {
          "ports": "8000",
          "protocol": "tcp",
          "sources": {
            "addresses": [
              "1.2.3.4",
              "18.0.0.0/8"
            ],
            "droplet_ids": [
              8043964
            ],
            "kubernetes_ids": [
              "41b74c5d-9bd0-5555-5555-a57c495b81a3"
            ],
            "load_balancer_uids": [
              "4de7ac8b-495b-4884-9a69-1050c6793cd6"
            ],
            "tags": [
              "base-image",
              "prod"
            ]
          }
        }
      ],
      "name": "firewall",
      "outbound_rules": [
        {
          "destinations": {
            "addresses": [
              "1.2.3.4",
              "18.0.0.0/8"
            ],
            "droplet_ids": [
              8043964
            ],
            "kubernetes_ids": [
              "41b74c5d-9bd0-5555-5555-a57c495b81a3"
            ],
            "load_balancer_uids": [
              "4de7ac8b-495b-4884-9a69-1050c6793cd6"
            ],
            "tags": [
              "base-image",
              "prod"
            ]
          },
          "ports": "8000",
          "protocol": "tcp"
        }
      ],
      "tags": [
        "base-image",
        "prod"
      ]
    }
  ],
  "links": {
    "pages": {
      "last": "https://api.digitalocean.com/v2/images?page=2",
      "next": "https://api.digitalocean.com/v2/images?page=2"
    }
  }
}
Returns Examples
{
  "meta": {
    "total": 1
  },
  "firewalls": [
    {
      "droplet_ids": [
        8043964
      ],
      "inbound_rules": [
        {
          "ports": "8000",
          "protocol": "tcp",
          "sources": {
            "addresses": [
              "1.2.3.4",
              "18.0.0.0/8"
            ],
            "droplet_ids": [
              8043964
            ],
            "kubernetes_ids": [
              "41b74c5d-9bd0-5555-5555-a57c495b81a3"
            ],
            "load_balancer_uids": [
              "4de7ac8b-495b-4884-9a69-1050c6793cd6"
            ],
            "tags": [
              "base-image",
              "prod"
            ]
          }
        }
      ],
      "name": "firewall",
      "outbound_rules": [
        {
          "destinations": {
            "addresses": [
              "1.2.3.4",
              "18.0.0.0/8"
            ],
            "droplet_ids": [
              8043964
            ],
            "kubernetes_ids": [
              "41b74c5d-9bd0-5555-5555-a57c495b81a3"
            ],
            "load_balancer_uids": [
              "4de7ac8b-495b-4884-9a69-1050c6793cd6"
            ],
            "tags": [
              "base-image",
              "prod"
            ]
          },
          "ports": "8000",
          "protocol": "tcp"
        }
      ],
      "tags": [
        "base-image",
        "prod"
      ]
    }
  ],
  "links": {
    "pages": {
      "last": "https://api.digitalocean.com/v2/images?page=2",
      "next": "https://api.digitalocean.com/v2/images?page=2"
    }
  }
}