Add Servers

Adds a Server to a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersPrivateNetwork
# Language: Perl
#
# Description: this function adds servers to private network
###########################################################################
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 _addServersPrivateNetwork
{
	my ($id, $content) = @_;
	my $_command = $url ."/private_networks/" .$id ."/servers";
	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)
	{
		print $response->headers()->as_string ."\n";
		return $response->content;
	}
	else
	{
		return "Http Error Code: ", $response->code, "\n";
	}			
}

#Parameters
my $id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $servers = ["{YOUR_SERVER_ID}"]; # e.g.: ["5340033E7FBBC308BC329414A0DF3C20"]

my %_query = ("servers" => $servers);
my $query = encode_json \%_query;

print _addServersPrivateNetwork($id, $query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersPrivateNetwork
# Language: Python
#
# Description: this function adds servers to private network
###########################################################################

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

function addServersPrivateNetwork($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks/" .$id ."/servers";
	$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_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$servers = array("{YOUR_SERVER_ID}"); # e.g.: array("5340033E7FBBC308BC329414A0DF3C20")

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

echo addServersPrivateNetwork($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersPrivateNetwork
# Language: Python
#
# Description: this function adds servers to private network
###########################################################################
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 _addServersPrivateNetwork(id, content):
    #Configure the request
    _command = url + "/private_networks/" + id + "/servers"
    _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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
servers = ["{YOUR_SERVER_ID}"] # e.g.: ["5340033E7FBBC308BC329414A0DF3C20"]

data = json.dumps({"servers":servers})

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

Create

Creates a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createPrivateNetwork
# Language: Perl
#
# Description: this function creates a new private network
###########################################################################
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 _createPrivateNetwork
{
	my $content = shift;
	my $_command = $url ."/private_networks";
	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)
	{
		print $response->headers()->as_string ."\n";
		return $response->content;
	}
	else
	{
		return "Http Error Code: ", $response->code, "\n";
	}			
}

#Parameters
my $name = "My private network";

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

print _createPrivateNetwork($query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createPrivateNetwork
# Language: PHP
#
# Description: this function creates a new private network
###########################################################################

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

function createPrivateNetwork($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks";
	$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 private network";

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

echo createPrivateNetwork($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createPrivateNetwork
# Language: Python
#
# Description: this function creates a new private network
###########################################################################
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 _createPrivateNetwork(content):
    #Configure the request
    _command = url + "/private_networks"
    _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 private network'
description = 'My private network description'

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

#Create private network
print(_createPrivateNetwork(data))

Delete

Deletes a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetwork
# Language: Perl
#
# Description: remove a private network specified by its ID
###########################################################################
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 _deletePrivateNetworks
{	
	my ($id) = @_;
	$_command = $url ."/private_networks/" .$id;
	$_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
$id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete private networks
print _deletePrivateNetworks($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetwork
# Language: PHP
#
# Description: remove a private network specified by its ID
###########################################################################

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

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

echo deletePrivateNetwork($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetwork
# Language: Python
#
# Description: remove a private network specified by its ID
###########################################################################
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 _deletePrivateNetwork(id):
    #Configure the request
    _command = url + "/private_networks/" + 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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Remove private network
print(_deletePrivateNetwork(id))

Remove Server

Removes a Server from a Private Network. The Server itself is not deleted..

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerPrivateNetwork
# Language: Perl
#
# Description: remove servers from private network
###########################################################################
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 _deleteServerPrivateNetworks
{	
	my ($id, $server_id) = @_;
	$_command = $url ."/private_networks/$id/servers/$server_id";
	$_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
$id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete server
print _deleteServerPrivateNetworks($id, $server_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerPrivateNetwork
# Language: Python
#
# Description: remove servers from private network
###########################################################################

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

function deleteServerPrivateNetwork($id, $server_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks/$id/servers/$server_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_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo deleteServerPrivateNetwork($id, $server_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServerPrivateNetwork
# Language: Python
#
# Description: remove servers from private network
###########################################################################
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 _deleteServerPrivateNetwork(id, server_id):
    #Configure the request
    _command = url + "/private_networks/" + id + "/servers/" + server_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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete servers
print(_deleteServerPrivateNetwork(id, server_id))

Info

Returns the information of one Image.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetwork
# Language: Perl
#
# Description: returns information about specific private network
###########################################################################
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 _infoPrivateNetworks
{	
	my ($id) = @_;
	$_command = $url ."/private_networks/" .$id;
	$_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
$id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info private networks
print _infoPrivateNetworks($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetwork
# Language: Python
#
# Description: returns information about specific private network
###########################################################################

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

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

echo infoPrivateNetwork($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetwork
# Language: Python
#
# Description: returns information about specific private network
###########################################################################
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 _infoPrivateNetwork(id):
    #Configure the request
    _command = url + "/private_networks/" + 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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about private network
print(_infoPrivateNetwork(id))

Info Server

Returns the information of one Server in a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerPrivateNetwork
# Language: Perl
#
# Description: returns information about servers assigned to private 
# network
###########################################################################
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 _infoServerPrivateNetworks
{	
	my ($id, $server_id) = @_;
	$_command = $url ."/private_networks/$id/servers/$server_id";
	$_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
$id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info server
print _infoServerPrivateNetworks($id, $server_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerPrivateNetwork
# Language: Python
#
# Description: returns information about servers assigned to private 
# network
###########################################################################

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

function infoServerPrivateNetwork($id, $server_id){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks/$id/servers/$server_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_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

echo infoServerPrivateNetwork($id, $server_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerPrivateNetwork
# Language: Python
#
# Description: returns information about servers assigned to private 
# network
###########################################################################
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 _infoServerPrivateNetwork(id, server_id):
    #Configure the request
    _command = url + "/private_networks/" + id + "/servers/" + server_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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about server
print(_infoServerPrivateNetwork(id, server_id))

List

Returns a list of all Private Networks.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworks
# Language: Perl
#
# Description: this function returns information about private networks
###########################################################################
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 _listPrivateNetworks
{	
	$_command = $url ."/private_networks";
	$_method = 'GET';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN, 'Content-Type' => 'application/json');
	$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 private networks
print _listPrivateNetworks;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworks
# Language: PHP
#
# Description: this function returns information about private networks
###########################################################################

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

function listPrivateNetworks(){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks";
	$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 listPrivateNetworks();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworks
# Language: Python
#
# Description: this function returns information about private networks
###########################################################################
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 _listPrivateNetworks():
    #Configure the request
    _command = url + "/private_networks"
    _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 private networks
print(_listPrivateNetworks())

List Servers

Returns a list of the Servers of a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersPrivateNetwork
# Language: Perl
#
# Description: returns servers asssigned to private network
###########################################################################
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 _listServersPrivateNetworks
{	
	my ($id) = @_;
	$_command = $url ."/private_networks/" .$id ."/servers";
	$_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
$id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info private networks
print _listServersPrivateNetworks($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersPrivateNetwork
# Language: Python
#
# Description: returns servers assigned to private network
###########################################################################

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

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

echo listServersPrivateNetwork($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersPrivateNetwork
# Language: Python
#
# Description: returns servers asssigned to private network
###########################################################################
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 _listServersPrivateNetwork(id):
    #Configure the request
    _command = url + "/private_networks/" + id + "/servers"
    _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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information about private network
print(_listServersPrivateNetwork(id))

Reconfigure

Reconfigures a Private Network.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigurePrivateNetwork
# Language: Perl
#
# Description: this function reconfigure a new private network
###########################################################################
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 _reconfigurePrivateNetwork
{
	my ($id, $content) = @_;
	my $_command = $url ."/private_networks/" .$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)
	{
		print $response->headers()->as_string ."\n";
		return $response->content;
	}
	else
	{
		return "Http Error Code: ", $response->code, "\n";
	}			
}

#Parameters
my $id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My private network";
my $description = "My private network description";
my $network_address = "192.168.1.0";
my $subnet_mask = "255.255.255.0";

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

print _reconfigurePrivateNetwork($id, $query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigurePrivateNetwork
# Language: Python
#
# Description: this function reconfigure a new private network
###########################################################################

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

function reconfigurePrivateNetwork($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/private_networks/" .$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_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "My private network";
$description = "My private network description";
$network_address = "192.168.1.0";
$subnet_mask = "255.255.255.0";

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

echo reconfigurePrivateNetwork($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigurePrivateNetwork
# Language: Python
#
# Description: this function reconfigure a new private network
###########################################################################
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 _reconfigurePrivateNetwork(id, content):
    #Configure the request
    _command = url + "/private_networks/" + 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_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My private network'
description = 'My private network description'
network_address = '192.168.1.0'
subnet_mask = '255.255.255.0'

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

#Reconfigure private network
print(_reconfigurePrivateNetwork(id, data))