Skip to main content
POST
/
firewalls
Python (SDK)
import latitudesh_python_sdk
from latitudesh_python_sdk import Latitudesh
import os


with Latitudesh(
    bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:

    res = latitudesh.firewalls.create(data={
        "type": latitudesh_python_sdk.CreateFirewallFirewallsType.FIREWALLS,
        "attributes": {
            "name": "my-firewall",
            "project": "sleek-steel-shirt",
            "rules": [
                {
                    "from_": "192.168.42.72",
                    "to": "192.168.43.51",
                    "protocol": latitudesh_python_sdk.CreateFirewallProtocol.TCP,
                    "port": "80",
                },
                {
                    "from_": "192.168.1.16",
                    "to": "192.168.1.30",
                    "protocol": latitudesh_python_sdk.CreateFirewallProtocol.TCP,
                    "port": "80",
                },
                {
                    "from_": "192.168.1.10",
                    "to": "192.168.1.20",
                    "protocol": latitudesh_python_sdk.CreateFirewallProtocol.UDP,
                    "port": "3000-4000",
                },
            ],
        },
    })

    # Handle response
    print(res)
{
  "data": {
    "id": "fw_VLMmAD8EOwop2",
    "type": "firewalls",
    "attributes": {
      "name": "my-firewall",
      "project": {
        "id": "proj_6A05EdQ1dvKYQ",
        "name": "Awesome Granite Chair",
        "slug": "awesome-granite-chair"
      },
      "rules": [
        {
          "from": "ANY",
          "to": "ANY",
          "port": "22",
          "protocol": "TCP",
          "default": true
        },
        {
          "from": "192.168.42.73",
          "to": "192.168.43.51",
          "port": "80",
          "protocol": "TCP",
          "default": false
        },
        {
          "from": "192.168.1.0/24",
          "to": "ANY",
          "port": "80",
          "protocol": "TCP",
          "default": false
        },
        {
          "from": "192.168.1.10",
          "to": "192.168.1.20",
          "port": "3000-4000",
          "protocol": "UDP",
          "default": false
        }
      ]
    }
  }
}

Authorizations

Authorization
string
header
required

Body

data
object
required

Response

201 - application/vnd.api+json

Created

data
object
meta
object
I