Add Rules

Adds Rules to a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesFirewallPolicy
# Language: Perl
#
# Description: this function adds rules to firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _addRulesFirewallPolicy
{
	my ($id, $content) = @_;
	my $_command = $url ."/firewall_policies/" .$id ."/rules";
	my $_method = 'POST';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Add additional parameters
	$request->content($content);

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my @_rules = [{"protocol" => "TCP", "port_from" => 22, "port_to" => 22},
			  {"protocol" => "TCP", "port_from" => 80, "port_to" => 80}];

my %_query = ("rules" => @_rules);
my $query = encode_json \%_query;

#Add rules to firewall policy
print _addRulesFirewallPolicy($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesFirewallPolicy
# Language: PHP
#
# Description: this function adds rules to firewall policy
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function addRulesFirewallPolicy($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/rules";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");

	//Add parameters
	curl_setopt($request, CURLOPT_POSTFIELDS, $data);
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20";
$rules = array(array("protocol"=>"TCP", "port_from"=>22, "port_to"=>22));

$data = array('rules'=>$rules);
$data = json_encode($data);

echo addRulesFirewallPolicy($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesFirewallPolicy
# Language: Python
#
# Description: this function adds rules to firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _addRulesFirewallPolicy(id, content):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/rules"
    _method = 'POST'
    request = Request(_command, data=content.encode(encoding='utf_8'), 
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
  
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rules = [{"protocol":"TCP", "port_from":22, 'port_to':22, 'source':'0.0.0.0'},
         {"protocol":"TCP", "port_from":8080, 'port_to':8080, 'source':'0.0.0.0'}]

data = json.dumps({'rules':rules})

#Add rules
print(_addRulesFirewallPolicy(id, data))

Add Servers

Adds Servers to a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersFirewallPolicy
# Language: Perl
#
# Description: this function adds servers to firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _addServersFirewallPolicy
{
	my ($id, $content) = @_;
	my $_command = $url ."/firewall_policies/" .$id ."/server_ips";
	my $_method = 'POST';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Add additional parameters
	$request->content($content);

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my @_server_ips = ["{YOUR_IP_ID}", "{YOUR_IP_ID}"]; # e.g.: ["5340033E7FBBC308BC329414A0DF3C20", "5340033E7FBBC308BC329414A0DF3C25"]

my %_query = ("server_ips" => @_server_ips);
my $query = encode_json \%_query;

#Add servers to firewall policy
print _addServersFirewallPolicy($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersFirewallPolicy
# Language: PHP
#
# Description: this function adds servers to firewall policy
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function addServersFirewallPolicy($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/server_ips";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");

	//Add parameters
	curl_setopt($request, CURLOPT_POSTFIELDS, $data);
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ips = array("{YOUR_SERVER_ID}"); # e.g.: array("5340033E7FBBC308BC329414A0DF3C20");

$data = array('server_ips' => $server_ips);
$data = json_encode($data);

echo addServersFirewallPolicy($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersFirewallPolicy
# Language: Python
#
# Description: this function adds servers to firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _addServersFirewallPolicy(id, content):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/server_ips"
    _method = 'POST'
    request = Request(_command, data=content.encode(encoding='utf_8'), 
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
  
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ips = ["{YOUR_FIREWALL_ID}"] # e.g.: ["5340033E7FBBC308BC329414A0DF3C20"]

data = json.dumps({'server_ips':server_ips})

#Add servers
print(_addServersFirewallPolicy(id, data))

Create

Creates a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createFirewallPolicy
# Language: Perl
#
# Description: this function creates a firewall
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _createFirewallPolicy
{
	my ($content) = @_;
	my $_command = $url ."/firewall_policies";
	my $_method = 'POST';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Add additional parameters
	$request->content($content);

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $name = "My firewall policy";
my $description = "My firewall policy description";
my @_rules = [{"protocol" => "TCP", "port_from" => 90, "port_to" => 90}];

my %_query = ("name" => $name, "description" => $description, "rules" => @_rules);
my $query = encode_json \%_query;

#Create firewall policy
print _createFirewallPolicy($query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createFirewallPolicy
# Language: PHP
#
# Description: this function creates a firewall
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function createFirewallPolicy($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");

	//Add parameters
	curl_setopt($request, CURLOPT_POSTFIELDS, $data);
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$name = "My firewall policy";
$description = "My firewall policy description";
$rules = array(array("protocol" => "TCP", "port_from" => 80, "port_to" => 80, "source" => "0.0.0.0"));

$data = array('name'=>$name, 'description'=>$description, 'rules'=>$rules);
$data = json_encode($data);

echo createFirewallPolicy($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createFirewallPolicy
# Language: Python
#
# Description: this function creates a firewall
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _createFirewallPolicy(content):
    #Configure the request
    _command = url + "/firewall_policies"
    _method = 'POST'
    request = Request(_command, data=content.encode(encoding='utf_8'), 
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
name = 'My firewall policy'
description = 'My firewall policy description'
rules = [{"protocol":"TCP", "port_from":80, 'port_to':80, 'source':'0.0.0.0'},
         {"protocol":"TCP", "port_from":443, 'port_to':443, 'source':'0.0.0.0'}]

data = json.dumps({'name':name, 'description':description, 'rules':rules})

#Create firewall policy
print(_createFirewallPolicy(data))

Delete

Deletes a Firewall Policy .

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallPolicy
# Language: Perl
#
# Description: removes requested firewall policy 
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _deleteFirewallPolicy
{	
	my ($id) = @_;
	my $_command = $url ."/firewall_policies/" .$id;
	my $_method = 'DELETE';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}	
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete firewall policy
print _deleteFirewallPolicy($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallPolicy
# Language: PHP
#
# Description: removes selected firewall policy 
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function deleteFirewallPolicy($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteFirewallPolicy($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallPolicy
# Language: Python
#
# Description: removes requested firewall policy 
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _deleteFirewallPolicy(id):
    #Configure the request
    _command = url + "/firewall_policies/" + id
    _method = 'DELETE'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Removes
print(_deleteFirewallPolicy(id))

Delete Rule

Deletes a Rule in a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleFirewallPolicy
# Language: Perl
#
# Description: this function removes rules from firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _deleteRuleFirewallPolicy
{
	my ($id, $rule_id) = @_;
	my $_command = $url ."/firewall_policies/$id/rules/$rule_id";
	my $_method = 'DELETE';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $rule_id = "{YOUR_FIREWALL_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info rules
print _deleteRuleFirewallPolicy($id, $rule_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleFirewallPolicies
# Language: PHP
#
# Description: this function removes rules
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function deleteRuleFirewallPolicy($id, $rule_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/rules/$rule_id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$rule_id = "{YOUR_FIREWALL_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteRuleFirewallPolicy($id, $rule_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleFirewallPolicies
# Language: Python
#
# Description: this function removes rules
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _deleteRuleFirewallPolicies(id, rule_id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/rules/" + rule_id 
    _method = 'DELETE'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rule_id = "{YOUR_FIREWALL_RULE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Remove rules
print(_deleteRuleFirewallPolicies(id, rule_id))

Remove Server

Removes a Server from a Firewall Policy. The Server itself it is not deleted..

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerFirewallPolicy
# Language: Perl
#
# Description: this function removes servers from firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _deleteServerFirewallPolicy
{
	my ($id, $server_ip_id) = @_;
	my $_command = $url ."/firewall_policies/$id/server_ips/$server_ip_id";
	my $_method = 'DELETE';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Remove server
print _deleteServerFirewallPolicy($id, $server_ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerFirewallPolicies
# Language: PHP
#
# Description: this function removes server
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function deleteServerFirewallPolicy($id, $server_ip_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/server_ips/$server_ip_id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteServerFirewallPolicy($id, $server_ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerFirewallPolicies
# Language: Python
#
# Description: this function removes server
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _deleteServerFirewallPolicies(id, server_ip_id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/server_ips/" + server_ip_id 
    _method = 'DELETE'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Remove servers
print(_deleteServerFirewallPolicies(id, server_ip_id))

Info

Returns the information of one Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallPolicy
# Language: Perl
#
# Description: this function returns information about specific firewall 
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _infoFirewallPolicy
{	
	my ($id) = @_;
	my $_command = $url ."/firewall_policies/" .$id;
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');	
	
	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}	
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about firewall policy
print _infoFirewallPolicy($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallPolicy
# Language: PHP
#
# Description: this function returns information about specific firewall 
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function infoFirewallPolicy($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoFirewallPolicy($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallPolicy
# Language: Python
#
# Description: this function returns information about specific firewall 
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _infoFirewallPolicy(id):
    #Configure the request
    _command = url + "/firewall_policies/" + id
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info firewall policy
print(_infoFirewallPolicy(id))

Info Rule

Returns the information of one Rule in a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleFirewallPolicy
# Language: Perl
#
# Description: this function returns information about a rule
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _infoRuleFirewallPolicy
{
	my ($id, $rule_id) = @_;
	my $_command = $url ."/firewall_policies/$id/rules/$rule_id";
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $rule_id = "{YOUR_FIREWALL_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info rules
print _infoRuleFirewallPolicy($id, $rule_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleFirewallPolicies
# Language: PHP
#
# Description: this function returns information about a rule
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function infoRuleFirewallPolicy($id, $rule_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/rules/$rule_id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$rule_id = "{YOUR_FIREWALL_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoRuleFirewallPolicy($id, $rule_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleFirewallPolicies
# Language: Python
#
# Description: this function returns information about a rule
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _infoRuleFirewallPolicies(id, rule_id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/rules/" + rule_id 
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rule_id = "{YOUR_FIREWALL_RULE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print(_infoRuleFirewallPolicies(id, rule_id))

Info Server

Returns the information of one Server in a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerFirewallPolicy
# Language: Perl
#
# Description: this function returns information about server
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _infoServerFirewallPolicy
{
	my ($id, $server_ip_id) = @_;
	my $_command = $url ."/firewall_policies/$id/server_ips/$server_ip_id";
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about server
print _infoServerFirewallPolicy($id, $server_ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerFirewallPolicies
# Language: PHP
#
# Description: this function returns information about server
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function infoServerFirewallPolicy($id, $server_ip_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/server_ips/$server_ip_id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoServerFirewallPolicy($id, $server_ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerFirewallPolicies
# Language: Python
#
# Description: this function returns information about server
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _infoServerFirewallPolicies(id, server_ip_id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/server_ips/" + server_ip_id 
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print(_infoServerFirewallPolicies(id, server_ip_id))

List

Returns a list of all Firewall Policies.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listFirewallPolicies
# Language: Perl
#
# Description: this function returns a list with your firewall policies
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _listFirewallPolicies
{	
	my $_command = $url ."/firewall_policies";
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->header('Content-Type' => 'application/json');	
	
	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}	
}

#List firewall policies
print _listFirewallPolicies;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listFirewallPolicies
# Language: PHP
#
# Description: this function returns a list with your firewall policies
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function listFirewallPolicies(){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS

echo listFirewallPolicies();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listFirewallPolicies
# Language: Python
#
# Description: this function returns a list with your firewall policies
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _listFirewallPolicies():
    #Configure the request
    _command = url + "/firewall_policies"
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS

#List firewall policies
print(_listFirewallPolicies())

List Rules

Returns a list of all Rules in a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesFirewallPolicy
# Language: Perl
#
# Description: this function returns a list with firewall policy's rules
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _listRulesFirewallPolicy
{
	my ($id) = @_;
	my $_command = $url ."/firewall_policies/" .$id ."/rules";
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List rules
print _listRulesFirewallPolicy($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesFirewallPolicies
# Language: PHP
#
# Description: this function returns a list with firewall policy rules
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function listRulesFirewallPolicies($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/rules";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo listRulesFirewallPolicies($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesFirewallPolicies
# Language: Python
#
# Description: this function returns a list with firewall policy's rules
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _listRulesFirewallPolicies(id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/rules"
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List rules
print(_listRulesFirewallPolicies(id))

List Servers

Returns a list of the Servers attached to a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersFirewallPolicy
# Language: Perl
#
# Description: this function returns a list with servers assigned to 
# firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _listServersFirewallPolicy
{
	my ($id) = @_;
	my $_command = $url ."/firewall_policies/" .$id ."/server_ips";
	my $_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List servers
print _listServersFirewallPolicy($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersFirewallPolicies
# Language: PHP
#
# Description: this function returns a list with servers assigned to 
# firewall policy
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function listServersFirewallPolicies($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id/server_ips";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-Type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "GET");
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo listServersFirewallPolicies($id);



?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersFirewallPolicies
# Language: Python
#
# Description: this function returns a list with servers assigned to 
# firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _listServerFirewallPolicies(id):
    #Configure the request
    _command = url + "/firewall_policies/" + id + "/server_ips"
    _method = 'GET'
    request = Request(_command,  
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List servers
print(_listServerFirewallPolicies(id))

Rename

Renames a Firewall Policy.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameFirewallPolicy
# Language: Perl
#
# Description: this function renames specified firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://api.cloudbuilder.es/v1";

sub _renameFirewallPolicy
{
	my ($id, $content) = @_;
	my $_command = $url ."/firewall_policies/" .$id;
	my $_method = 'PUT';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Add additional parameters
	$request->content($content);

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}			
}

#Parameters
my $id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My firewall policy";
my $description = "My firewall policy description";

my %_query = ("name" => $name, "description" => $description);
my $query = encode_json \%_query;

#Rename firewall policy
print _renameFirewallPolicy($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameFirewallPolicy
# Language: PHP
#
# Description: this function renames specified firewall policy
###########################################################################

#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://api.cloudbuilder.es/v1";

function renameFirewallPolicy($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/firewall_policies/$id";
	$request = curl_init();

	//Set options
	curl_setopt($request, CURLOPT_URL, $_command);
	curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($request, CURLOPT_HTTPHEADER, array("X-TOKEN:$TOKEN", "Content-type:application/json"));
	curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");

	//Add parameters
	curl_setopt($request, CURLOPT_POSTFIELDS, $data);
	
	//Try to get the response
	$response = curl_exec($request);
	if ($response == false){
		return( curl_error($request));
	}
	else{
		return( $response);
	}

	curl_close($request);
}

#PARAMETERS
$id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "My firewall policy";
$description = "My firewall policy description";

$data = array('name'=>$name, 'description'=>$description);
$data = json_encode($data);

echo renameFirewallPolicy($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameFirewallPolicy
# Language: Python
#
# Description: this function rename specified firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json

#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://api.cloudbuilder.es/v1"

def _renameFirewallPolicy(id, content):
    #Configure the request
    _command = url + "/firewall_policies/" + id
    _method = 'PUT'
    request = Request(_command, data=content.encode(encoding='utf_8'), 
                      headers={'X-TOKEN':TOKEN, 'content-type':'application/json'}, 
                      method=_method)
    
    #Try to get the response
    try:
        response = urlopen(request)
        content = response.read()
        return (content.decode())
    #Fetch error
    except urllib.error.URLError as e:
        return("Error " + str(e.code) + ":" + e.reason) 

#PARAMETERS
id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My firewall policy rename'
description = 'My firewall policy rename description'

data = json.dumps({'name':name, 'description':description})

#Rename firewall policy
print(_renameFirewallPolicy(id, data))