Create a new firewall rule
curl --request POST \
--url https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cidr": "<string>",
"firewall_id": "<string>",
"port_range": "<string>",
"protocol": "<string>",
"description": "<string>",
"project_id": "<string>"
}
'import requests
url = "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule"
payload = {
"cidr": "<string>",
"firewall_id": "<string>",
"port_range": "<string>",
"protocol": "<string>",
"description": "<string>",
"project_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cidr: '<string>',
firewall_id: '<string>',
port_range: '<string>',
protocol: '<string>',
description: '<string>',
project_id: '<string>'
})
};
fetch('https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule",
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([
'cidr' => '<string>',
'firewall_id' => '<string>',
'port_range' => '<string>',
'protocol' => '<string>',
'description' => '<string>',
'project_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule"
payload := strings.NewReader("{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"cidr": "<string>",
"id": "fraz0q3vbrpa7pkg7zbmah9csn",
"port_range": "<string>",
"description": "<string>"
}{
"error": {
"code": 401,
"message": "There was an error logging in",
"type": "InvalidCredentials",
"details": {}
}
}Firewall Rule
Create a new firewall rule
POST
/
project
/
{project_id}
/
location
/
{location}
/
firewall
/
{firewall_reference}
/
firewall-rule
Create a new firewall rule
curl --request POST \
--url https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cidr": "<string>",
"firewall_id": "<string>",
"port_range": "<string>",
"protocol": "<string>",
"description": "<string>",
"project_id": "<string>"
}
'import requests
url = "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule"
payload = {
"cidr": "<string>",
"firewall_id": "<string>",
"port_range": "<string>",
"protocol": "<string>",
"description": "<string>",
"project_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cidr: '<string>',
firewall_id: '<string>',
port_range: '<string>',
protocol: '<string>',
description: '<string>',
project_id: '<string>'
})
};
fetch('https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule",
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([
'cidr' => '<string>',
'firewall_id' => '<string>',
'port_range' => '<string>',
'protocol' => '<string>',
'description' => '<string>',
'project_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule"
payload := strings.NewReader("{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ubicloud.com/project/{project_id}/location/{location}/firewall/{firewall_reference}/firewall-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cidr\": \"<string>\",\n \"firewall_id\": \"<string>\",\n \"port_range\": \"<string>\",\n \"protocol\": \"<string>\",\n \"description\": \"<string>\",\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"cidr": "<string>",
"id": "fraz0q3vbrpa7pkg7zbmah9csn",
"port_range": "<string>",
"description": "<string>"
}{
"error": {
"code": 401,
"message": "There was an error logging in",
"type": "InvalidCredentials",
"details": {}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Firewall ID or name Resource ID or name
Pattern:
^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$The Ubicloud location/region
Example:
"eu-central-h1"
ID of the project
Pattern:
^pj[0-9a-hj-km-np-tv-z]{24}$Example:
"pjkkmx0f2vke4h36nk9cm8v8q0"
Body
application/json
Response
A Firewall Rule or array of them
- object
- object[]
CIDR of the firewall rule
ID of the firewall rule
Pattern:
^fr[0-9a-hj-km-np-tv-z]{24}$Example:
"fraz0q3vbrpa7pkg7zbmah9csn"
Port range of the firewall rule
Protocol of the firewall rule (tcp or udp)
Available options:
tcp, udp Description of the firewall rule
⌘I