Add Rules

Adds Rules to a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesLoadBalancer
# Language: Perl
#
# Description: this function adds rules to load balancer
###########################################################################
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 _addRulesLoadBalancer
{
	my ($id, $content) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my @_rules = [{"protocol" => "TCP", "port_balancer" => 22, "port_server" => 22},
			  {"protocol" => "TCP", "port_balancer" => 80, "port_server" => 80}];

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

#Add rules to load balancer
print _addRulesLoadBalancer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesLoadBalancer
# Language: Python
#
# Description: this function adds rules to load balancer
###########################################################################

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

function addRulesLoadBalancer($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$rules = array(array("protocol"=>"TCP", "port_server"=>22, "port_balancer"=>22),
		       array("protocol"=>"TCP", "port_server"=>443, "port_balancer"=>443));

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

echo addRulesLoadBalancer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addRulesLoadBalancer
# Language: Python
#
# Description: this function adds rules to load balancer
###########################################################################
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 _addRulesLoadBalancer(id, content):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rules = [{"protocol":"TCP", "port_balancer":443, 'port_server':22, 'source':'0.0.0.0'}]

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

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

Add Servers

Adds Servers to a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersLoadBalancer
# Language: Perl
#
# Description: this function adds servers to load balancer
###########################################################################
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 _addServersLoadBalancer
{
	my ($id, $content) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my @_server_ips = ["{YOUR_IP_ID}", "{YOUR_IP_ID}"]; # e.g.: ["5340033E7FBBC308BC329414A0DF3C20", "5340033E7FBBC308BC329414A0DF3C22"]

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

#Add servers to load balancer
print _addServersLoadBalancer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersLoadBalancer
# Language: PHP
#
# Description: this function adds servers to load balancer
###########################################################################

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

function addServersLoadBalancer($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ips = array("{YOUR_IP_ID}"); # e.g.: array("5340033E7FBBC308BC329414A0DF3C20")

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

echo addServersLoadBalancer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersLoadBalancer
# Language: Python
#
# Description: this function adds servers to load balancer
###########################################################################
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 _addServersLoadBalancer(id, content):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ips = ["{YOUR_BALANCER_ID}"] # e.g.: ["5340033E7FBBC308BC329414A0DF3C20"]

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

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

Create

Creates a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createLoadBalancer
# Language: Perl
#
# Description: this function creates a load balancer
###########################################################################
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 _createLoadBalancer
{
	my ($content) = @_;
	my $_command = $url ."/load_balancers";
	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 load balancer";
my $description = "My load balancer description";
my $health_check_test = "TCP";
my $health_check_interval = 30;
my $persistence = "true";
my $persistence_time = 1200;
my $method = "ROUND_ROBIN";
my @_rules = [{"protocol" => "TCP", "port_balancer" => 90, "port_server" => 90}];

my %_query = ("name" => $name, 
              "description" => $description, 
              "health_check_test" => $health_check_test, 
              "health_check_interval" => $health_check_interval,
              "persistence" => $persistence,
              "persistence_time" => $persistence_time,
              "method" => $method,
              "rules" => @_rules);
              
my $query = encode_json \%_query;

#Create load balancer
print _createLoadBalancer($query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createLoadBalancer
# Language: PHP
#
# Description: this function creates a load balancer
###########################################################################

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

function createLoadBalancer($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers";
	$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 load balancer";
$description = "My load balancer description";
$health_check_test = "TCP";
$health_check_interval = 40;
$persistence = true;
$persistence_time = 1200;
$method = "LEAST_CONNECTIONS";
$rules = array(array("protocol"=>"TCP", "port_server"=>80, "port_balancer"=>80));

$data = array('name'=>$name, 'description'=>$description, 
              'health_check_test'=>$health_check_test,
			  'health_check_interval'=>$health_check_interval,
			  'persistence'=>$persistence, 
			  'persistence_time'=>$persistence_time,
			  'method'=>$method,
			  'rules'=>$rules);
			  
$data = json_encode($data);

echo createLoadBalancer($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createLoadBalancer
# Language: Python
#
# Description: this function creates a load balancer
###########################################################################
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 _createLoadBalancer(content):
    #Configure the request
    _command = url + "/load_balancers"
    _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 load balancer api test'
description = 'My load balancer api test description'
health_check_test = 'TCP'
health_check_interval = 40
persistence = True
persistence_time = 1200
method = 'ROUND_ROBIN'
rules = [{"protocol":"TCP", "port_balancer":22, 'port_server':22, 'source':'0.0.0.0'},
         {"protocol":"TCP", "port_balancer":8080, 'port_server':8080, 'source':'0.0.0.0'}]

data = json.dumps({'name':name, 'description':description, 
                   'health_check_test': health_check_test,
                   'health_check_interval':health_check_interval,
                   'persistence':persistence,
                   'persistence_time':persistence_time,
                   'method':method,
                   'rules':rules})

#Create load balancer
print(_createLoadBalancer(data))

Delete

Deletes a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteLoadBalancer
# Language: Perl
#
# Description: removes requested load balancer
###########################################################################
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 _deleteLoadBalancer
{	
	my ($id) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete load balancer
print _deleteLoadBalancer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteLoadBalancer
# Language: PHP
#
# Description: removes requested load balancer
###########################################################################

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

function deleteLoadBalancer($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteLoadBalancer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteLoadBalancer
# Language: Python
#
# Description: removes requested load balancer
###########################################################################
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 _deleteLoadBalancer(id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Removes
print(_deleteLoadBalancer(id))

Delete Rule

Deletes a Rule in a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleLoadBalancer
# Language: Perl
#
# Description: this function removes 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 _deleteRuleLoadBalancer
{
	my ($id, $rule_id) = @_;
	my $_command = $url ."/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $rule_id = "{YOUR_BALANCER_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info rules
print _deleteRuleLoadBalancer($id, $rule_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleLoadBalancer
# 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 deleteRuleLoadBalancer($id, $rule_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$rule_id = "{YOUR_BALANCER_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteRuleLoadBalancer($id, $rule_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteRuleLoadBalancer
# 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 _deleteRuleLoadBalancer(id, rule_id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rule_id = "{YOUR_BALANCER_RULE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

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

Remove Server

Removes a Server from a Load Balancer. The server itself is not deleted.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerLoadBalancer
# Language: Perl
#
# Description: this function removes 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 _deleteServerLoadBalancer
{
	my ($id, $server_ip_id) = @_;
	my $_command = $url ."/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Remove server
print _deleteServerLoadBalancer($id, $server_ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerLoadBalancer
# 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 deleteServerLoadBalancer($id, $server_ip_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteServerLoadBalancer($id, $server_ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerLoadBalancer
# 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 _deleteServerLoadBalancer(id, server_ip_id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

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

Info

Returns the information of one Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoLoadBalancers
# Language: Perl
#
# Description: this function retrieves information about required balancer
###########################################################################
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 _infoLoadBalancer
{	
	my ($id) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about load balancer
print _infoLoadBalancer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoLoadBalancers
# Language: PHP
#
# Description: this function retrieves information about required balancer
###########################################################################

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

function infoLoadBalancer($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoLoadBalancer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoLoadBalancers
# Language: Python
#
# Description: this function retrieves information about required balancer
###########################################################################
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 _infoLoadBalancer(id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info firewall policy
print(_infoLoadBalancer(id))

Info Rule

Returns the information of one Rule in a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleLoadBalancer
# 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 _infoRuleLoadBalancer
{
	my ($id, $rule_id) = @_;
	my $_command = $url ."/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $rule_id = "{YOUR_BALANCER_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info rules
print _infoRuleLoadBalancer($id, $rule_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleLoadBalancer
# 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 infoRuleLoadBalancer($id, $rule_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$rule_id = "{YOUR_BALANCER_RULE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoRuleLoadBalancer($id, $rule_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoRuleLoadBalancer
# 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 _infoRuleLoadBalancer(id, rule_id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
rule_id = "{YOUR_BALANCER_RULE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

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

Info Server

Returns the information of one Server in a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerLoadBalancer
# 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 _infoServerLoadBalancer
{
	my ($id, $server_ip_id) = @_;
	my $_command = $url ."/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about server
print _infoServerLoadBalancer($id, $server_ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoLoadBalancers
# Language: PHP
#
# Description: this function retrieves information about required balancer
###########################################################################

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

function infoServerLoadBalancer($id, $server_ip_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_ip_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoServerLoadBalancer($id, $server_ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerLoadBalancer
# 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 _infoServerLoadBalancer(id, server_ip_id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

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

List

Returns a list of all Load Balancers.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listLoadBalancers
# Language: Perl
#
# Description: this function returns a list with your load balancers
###########################################################################
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 _listLoadBalancers
{	
	my $_command = $url ."/load_balancers";
	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;
	}	
}

#List load balancers
print _listLoadBalancers;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listLoadBalancers
# Language: PHP
#
# Description: this function returns a list with your load balancers
###########################################################################

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

function listLoadBalancers(){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers";
	$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 listLoadBalancers();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listLoadBalancers
# Language: Python
#
# Description: this function returns a list with your load balancers
###########################################################################
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 _listLoadBalancers():
    #Configure the request
    _command = url + "/load_balancers"
    _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 load balancers
print(_listLoadBalancers())

List Rules

Returns a list of the Rules of a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesLoadBalancer
# Language: Perl
#
# Description: this function returns a list with load balancer'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 _listRulesLoadBalancer
{
	my ($id) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List rules
print _listRulesLoadBalancer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesLoadBalancer
# Language: PHP
#
# Description: this function returns a list with load balancer's rules
###########################################################################

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

function listRulesLoadBalancer($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo listRulesLoadBalancer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listRulesLoadBalancer
# Language: Python
#
# Description: this function returns a list with load balancer'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 _listRulesLoadBalancer(id):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List rules
print(_listRulesLoadBalancer(id))

List Servers

Returns a list of the Servers of a Load Balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersLoadBalancers
# Language: Perl
#
# Description: this function returns a list with servers assigned to 
# load balancer
###########################################################################
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 _listServersLoadBalancer
{
	my ($id) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List servers
print _listServersLoadBalancer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersLoadBalancer
# Language: PHP
#
# Description: this function returns a list with servers assigned to 
# load balancer
###########################################################################

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

function listServersLoadBalancer($id){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo listServersLoadBalancer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersLoadBalancers
# Language: Python
#
# Description: this function returns a list with servers assigned to 
# load balancer
###########################################################################
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 _listServerLoadBalancer(id):
    #Configure the request
    _command = url + "/load_balancers/" + 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 = "77D9725B097F8731DD8B8D855E6F0BC3"

#List servers
print(_listServerLoadBalancer(id))

Reconfigure

Reconfigures a load balancer.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureLoadBalancer
# Language: Perl
#
# Description: this function changes the features of load balancers
###########################################################################
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 _reconfigureLoadBalancer
{
	my ($id, $content) = @_;
	my $_command = $url ."/load_balancers/" .$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My load balancer";
my $description = "My load balancer description";
my $health_check_test = "NONE";
my $health_check_interval = 30;
my $persistence = "false";
my $persistence_time = 1200;
my $method = "LEAST_CONNECTIONS";

my %_query = ("name" => $name, 
              "description" => $description, 
              "health_check_test" => $health_check_test, 
              "health_check_interval" => $health_check_interval,
              "persistence" => $persistence,
              "persistence_time" => $persistence_time,
              "method" => $method);
              
my $query = encode_json \%_query;

#Reconfigure load balancer
print _reconfigureLoadBalancer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureLoadBalancer
# Language: PHP
#
# Description: this function changes the features of load balancers
###########################################################################

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

function reconfigureLoadBalancer($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/load_balancers/$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_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "My load balancer";
$description = "My load balancer description";
$health_check_test = "TCP";
$health_check_interval = 42;
$persistence = false;
$persistence_time = 1200;
$method = "ROUND_ROBIN";

$data = array('name'=>$name, 'description'=>$description, 
			  'health_check_test'=>$health_check_test,
			  'health_check_interval'=>$health_check_interval,
			  'persistence'=>$persistence,
			  'persistence_time'=>$persistence_time,
			  'method'=>$method);
			  
$data = json_encode($data);

echo reconfigureLoadBalancer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureLoadBalancer
# Language: Python
#
# Description: this function changes the features of load balancers
###########################################################################
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 _reconfigureLoadBalancer(id, content):
    #Configure the request
    _command = url + "/load_balancers/" + 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_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My load balancer api rename'
description = 'My load balancer api rename description'
health_check_test = 'TCP'
health_check_interval = 20
persistence = False
persistence_time = 1000
method = 'LEAST_CONNECTIONS'

data = json.dumps({'name':name, 'description':description, 
                   'health_check_test': health_check_test,
                   'health_check_interval':health_check_interval,
                   'persistence':persistence,
                   'persistence_time':persistence_time,
                   'method':method})


#Rename load balancer
print(_reconfigureLoadBalancer(id, data))