Create firewall
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
rules: [
{
priority: 123,
protocol: '<string>',
source: '<string>',
destination: '<string>',
ports: '<string>'
}
],
networkId: '<string>'
})
};
fetch('https://api.example.com/v1/regions/{region}/compute/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.example.com/v1/regions/{region}/compute/firewalls"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"priority\": 123,\n \"protocol\": \"<string>\",\n \"source\": \"<string>\",\n \"destination\": \"<string>\",\n \"ports\": \"<string>\"\n }\n ],\n \"networkId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}curl --request POST \
--url https://api.example.com/v1/regions/{region}/compute/firewalls \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": [
{
"priority": 123,
"protocol": "<string>",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"networkId": "<string>"
}
'import requests
url = "https://api.example.com/v1/regions/{region}/compute/firewalls"
payload = {
"name": "<string>",
"rules": [
{
"priority": 123,
"protocol": "<string>",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"networkId": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"id": "<string>",
"name": "<string>",
"rules": [
{
"priority": 123,
"direction": "ingress",
"action": "allow",
"protocol": "TCP",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"status": "active",
"networkId": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}Firewalls
Create firewall
Create a network firewall policy
POST
/
v1
/
regions
/
{region}
/
compute
/
firewalls
Create firewall
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
rules: [
{
priority: 123,
protocol: '<string>',
source: '<string>',
destination: '<string>',
ports: '<string>'
}
],
networkId: '<string>'
})
};
fetch('https://api.example.com/v1/regions/{region}/compute/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.example.com/v1/regions/{region}/compute/firewalls"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"priority\": 123,\n \"protocol\": \"<string>\",\n \"source\": \"<string>\",\n \"destination\": \"<string>\",\n \"ports\": \"<string>\"\n }\n ],\n \"networkId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}curl --request POST \
--url https://api.example.com/v1/regions/{region}/compute/firewalls \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rules": [
{
"priority": 123,
"protocol": "<string>",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"networkId": "<string>"
}
'import requests
url = "https://api.example.com/v1/regions/{region}/compute/firewalls"
payload = {
"name": "<string>",
"rules": [
{
"priority": 123,
"protocol": "<string>",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"networkId": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"id": "<string>",
"name": "<string>",
"rules": [
{
"priority": 123,
"direction": "ingress",
"action": "allow",
"protocol": "TCP",
"source": "<string>",
"destination": "<string>",
"ports": "<string>"
}
],
"status": "active",
"networkId": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}Path Parameters
Region identifier
Body
application/json
Was this page helpful?