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
}
]
}
}
}
Create a firewall
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
}
]
}
}
}
Show child attributes
Was this page helpful?