import { Latitudesh } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.firewalls.create({
data: {
type: "firewalls",
attributes: {
name: "my-firewall",
project: "heavy-duty-copper-watch",
rules: [
{
from: "192.168.42.73",
to: "192.168.43.51",
protocol: "TCP",
port: "80",
},
{
from: "192.168.1.16",
to: "192.168.1.30",
protocol: "TCP",
port: "80",
},
{
from: "192.168.1.10",
to: "192.168.1.20",
protocol: "UDP",
port: "3000-4000",
},
],
},
},
});
console.log(result);
}
run();{
"data": {
"id": "fw_w5AEmq7XDBkWX",
"type": "firewalls",
"attributes": {
"name": "my-firewall",
"project": {
"id": "proj_RLYV8DZ2D5QoE",
"name": "Heavy Duty Copper Watch",
"slug": "heavy-duty-copper-watch"
},
"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.16",
"to": "192.168.1.30",
"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 } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.firewalls.create({
data: {
type: "firewalls",
attributes: {
name: "my-firewall",
project: "heavy-duty-copper-watch",
rules: [
{
from: "192.168.42.73",
to: "192.168.43.51",
protocol: "TCP",
port: "80",
},
{
from: "192.168.1.16",
to: "192.168.1.30",
protocol: "TCP",
port: "80",
},
{
from: "192.168.1.10",
to: "192.168.1.20",
protocol: "UDP",
port: "3000-4000",
},
],
},
},
});
console.log(result);
}
run();{
"data": {
"id": "fw_w5AEmq7XDBkWX",
"type": "firewalls",
"attributes": {
"name": "my-firewall",
"project": {
"id": "proj_RLYV8DZ2D5QoE",
"name": "Heavy Duty Copper Watch",
"slug": "heavy-duty-copper-watch"
},
"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.16",
"to": "192.168.1.30",
"port": "80",
"protocol": "TCP",
"default": false
},
{
"from": "192.168.1.10",
"to": "192.168.1.20",
"port": "3000-4000",
"protocol": "UDP",
"default": false
}
]
}
}
}Was this page helpful?