Create Firewall
curl --request POST \
--url https://api.tenbytecloud.com/v1/network/firewalls \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"protocol": "tcp",
"direction": "inbound",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": [
"10.0.0.0/24"
]
}
]
}
'import requests
url = "https://api.tenbytecloud.com/v1/network/firewalls"
payload = {
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"protocol": "tcp",
"direction": "inbound",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": ["10.0.0.0/24"]
}
]
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
display_name: 'Database Firewall',
billing_account_id: 123,
rules: [
{
protocol: 'tcp',
direction: 'inbound',
port_start: 3306,
port_end: 3306,
endpoint_spec_type: 'ip_prefixes',
endpoint_spec: ['10.0.0.0/24']
}
]
})
};
fetch('https://api.tenbytecloud.com/v1/network/firewalls', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tenbytecloud.com/v1/network/firewalls"
payload := strings.NewReader("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.tenbytecloud.com/v1/network/firewalls")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://api.tenbytecloud.com/v1/network/firewalls")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.tenbytecloud.com/v1/network/firewalls");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("apikey", "<api-key>");
request.AddJsonBody("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tenbytecloud.com/v1/network/firewalls",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Database Firewall',
'billing_account_id' => 123,
'rules' => [
[
'protocol' => 'tcp',
'direction' => 'inbound',
'port_start' => 3306,
'port_end' => 3306,
'endpoint_spec_type' => 'ip_prefixes',
'endpoint_spec' => [
'10.0.0.0/24'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"uuid": "2a874f44-310f-4df8-9340-1dc274c2bd51",
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"uuid": "db9acadc-91e1-4225-b934-7f264f9f75a2",
"direction": "inbound",
"protocol": "tcp",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": [
"10.0.0.0/24"
]
}
],
"resources_assigned": []
}Firewall
Create Firewall
Creates a new firewall with a given set of rules. See Representation and validation for FirewallRule object structure. Location-specific endpoint.
POST
/
network
/
firewalls
Create Firewall
curl --request POST \
--url https://api.tenbytecloud.com/v1/network/firewalls \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"protocol": "tcp",
"direction": "inbound",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": [
"10.0.0.0/24"
]
}
]
}
'import requests
url = "https://api.tenbytecloud.com/v1/network/firewalls"
payload = {
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"protocol": "tcp",
"direction": "inbound",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": ["10.0.0.0/24"]
}
]
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
display_name: 'Database Firewall',
billing_account_id: 123,
rules: [
{
protocol: 'tcp',
direction: 'inbound',
port_start: 3306,
port_end: 3306,
endpoint_spec_type: 'ip_prefixes',
endpoint_spec: ['10.0.0.0/24']
}
]
})
};
fetch('https://api.tenbytecloud.com/v1/network/firewalls', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tenbytecloud.com/v1/network/firewalls"
payload := strings.NewReader("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.tenbytecloud.com/v1/network/firewalls")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://api.tenbytecloud.com/v1/network/firewalls")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.tenbytecloud.com/v1/network/firewalls");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("apikey", "<api-key>");
request.AddJsonBody("{\n \"display_name\": \"Database Firewall\",\n \"billing_account_id\": 123,\n \"rules\": [\n {\n \"protocol\": \"tcp\",\n \"direction\": \"inbound\",\n \"port_start\": 3306,\n \"port_end\": 3306,\n \"endpoint_spec_type\": \"ip_prefixes\",\n \"endpoint_spec\": [\n \"10.0.0.0/24\"\n ]\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tenbytecloud.com/v1/network/firewalls",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Database Firewall',
'billing_account_id' => 123,
'rules' => [
[
'protocol' => 'tcp',
'direction' => 'inbound',
'port_start' => 3306,
'port_end' => 3306,
'endpoint_spec_type' => 'ip_prefixes',
'endpoint_spec' => [
'10.0.0.0/24'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"uuid": "2a874f44-310f-4df8-9340-1dc274c2bd51",
"display_name": "Database Firewall",
"billing_account_id": 123,
"rules": [
{
"uuid": "db9acadc-91e1-4225-b934-7f264f9f75a2",
"direction": "inbound",
"protocol": "tcp",
"port_start": 3306,
"port_end": 3306,
"endpoint_spec_type": "ip_prefixes",
"endpoint_spec": [
"10.0.0.0/24"
]
}
],
"resources_assigned": []
}⌘I