# Firewalls ## Create `gpu_droplets.firewalls.create(FirewallCreateParams**kwargs) -> FirewallCreateResponse` **post** `/v2/firewalls` To create a new firewall, send a POST request to `/v2/firewalls`. The request must contain at least one inbound or outbound access rule. ### Parameters - **body:** `Body` ### Returns - `class FirewallCreateResponse` - **firewall:** `Optional[Firewall]` ### Example ```python from gradient import Gradient client = Gradient() firewall = client.gpu_droplets.firewalls.create() print(firewall.firewall) ``` ## Retrieve `gpu_droplets.firewalls.retrieve(strfirewall_id) -> FirewallRetrieveResponse` **get** `/v2/firewalls/{firewall_id}` To show information about an existing firewall, send a GET request to `/v2/firewalls/$FIREWALL_ID`. ### Parameters - **firewall\_id:** `str` ### Returns - `class FirewallRetrieveResponse` - **firewall:** `Optional[Firewall]` ### Example ```python from gradient import Gradient client = Gradient() firewall = client.gpu_droplets.firewalls.retrieve( "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(firewall.firewall) ``` ## Update `gpu_droplets.firewalls.update(strfirewall_id, FirewallUpdateParams**kwargs) -> FirewallUpdateResponse` **put** `/v2/firewalls/{firewall_id}` To update the configuration of an existing firewall, send a PUT request to `/v2/firewalls/$FIREWALL_ID`. The request should contain a full representation of the firewall including existing attributes. **Note that any attributes that are not provided will be reset to their default values.**

You must have read access (e.g. `droplet:read`) to all resources attached to the firewall to successfully update the firewall. ### Parameters - **firewall\_id:** `str` - **firewall:** `FirewallParam` ### Returns - `class FirewallUpdateResponse` - **firewall:** `Optional[Firewall]` ### Example ```python from gradient import Gradient client = Gradient() firewall = client.gpu_droplets.firewalls.update( firewall_id="bb4b2611-3d72-467b-8602-280330ecd65c", firewall={ "name": "frontend-firewall" }, ) print(firewall.firewall) ``` ## List `gpu_droplets.firewalls.list(FirewallListParams**kwargs) -> FirewallListResponse` **get** `/v2/firewalls` To list all of the firewalls available on your account, send a GET request to `/v2/firewalls`. ### Parameters - **page:** `int` Which 'page' of paginated results to return. - **per\_page:** `int` Number of items returned per page ### Returns - `class FirewallListResponse` - **meta:** `MetaProperties` Information about the response itself. - **firewalls:** `Optional[List[Firewall]]` - **id:** `Optional[str]` A unique ID that can be used to identify and reference a firewall. - **created\_at:** `Optional[datetime]` A time value given in ISO8601 combined date and time format that represents when the firewall was created. - **droplet\_ids:** `Optional[List[int]]` An array containing the IDs of the Droplets assigned to the firewall.

Requires `droplet:read` scope. - **inbound\_rules:** `Optional[List[InboundRule]]` - **ports:** `str` 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:** `Literal["tcp", "udp", "icmp"]` The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`. - `"tcp"` - `"udp"` - `"icmp"` - **sources:** `FirewallRuleTarget` An object specifying locations from which inbound traffic will be accepted. - **name:** `Optional[str]` 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:** `Optional[List[OutboundRule]]` - **destinations:** `FirewallRuleTarget` An object specifying locations to which outbound traffic that will be allowed. - **ports:** `str` 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:** `Literal["tcp", "udp", "icmp"]` The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`. - `"tcp"` - `"udp"` - `"icmp"` - **pending\_changes:** `Optional[List[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:** `Optional[int]` - **removing:** `Optional[bool]` - **status:** `Optional[str]` - **status:** `Optional[Literal["waiting", "succeeded", "failed"]]` A status string indicating the current state of the firewall. This can be "waiting", "succeeded", or "failed". - `"waiting"` - `"succeeded"` - `"failed"` - **tags:** `Optional[List[str]]` 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. - **links:** `Optional[PageLinks]` ### Example ```python from gradient import Gradient client = Gradient() firewalls = client.gpu_droplets.firewalls.list() print(firewalls.meta) ``` ## Delete `gpu_droplets.firewalls.delete(strfirewall_id)` **delete** `/v2/firewalls/{firewall_id}` To delete a firewall send a DELETE request to `/v2/firewalls/$FIREWALL_ID`. No response body will be sent back, but the response code will indicate success. Specifically, the response code will be a 204, which means that the action was successful with no returned body data. ### Parameters - **firewall\_id:** `str` ### Example ```python from gradient import Gradient client = Gradient() client.gpu_droplets.firewalls.delete( "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) ``` ## Domain Types ### Firewall - `class Firewall` - **id:** `Optional[str]` A unique ID that can be used to identify and reference a firewall. - **created\_at:** `Optional[datetime]` A time value given in ISO8601 combined date and time format that represents when the firewall was created. - **droplet\_ids:** `Optional[List[int]]` An array containing the IDs of the Droplets assigned to the firewall.

Requires `droplet:read` scope. - **inbound\_rules:** `Optional[List[InboundRule]]` - **ports:** `str` 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:** `Literal["tcp", "udp", "icmp"]` The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`. - `"tcp"` - `"udp"` - `"icmp"` - **sources:** `FirewallRuleTarget` An object specifying locations from which inbound traffic will be accepted. - **name:** `Optional[str]` 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:** `Optional[List[OutboundRule]]` - **destinations:** `FirewallRuleTarget` An object specifying locations to which outbound traffic that will be allowed. - **ports:** `str` 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:** `Literal["tcp", "udp", "icmp"]` The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`. - `"tcp"` - `"udp"` - `"icmp"` - **pending\_changes:** `Optional[List[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:** `Optional[int]` - **removing:** `Optional[bool]` - **status:** `Optional[str]` - **status:** `Optional[Literal["waiting", "succeeded", "failed"]]` A status string indicating the current state of the firewall. This can be "waiting", "succeeded", or "failed". - `"waiting"` - `"succeeded"` - `"failed"` - **tags:** `Optional[List[str]]` 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.