Add Servers

Adds a Server to a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersSharedStorage
# Language: Perl
#
# Description: this function adds servers to shared storage
###########################################################################
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 _addServersSharedStorage
{
	my ($id, $content) = @_;
	my $_command = $url ."/shared_storages/$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_type('application/json');
	$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_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $servers = [{'id' => "{YOUR_SERVER_ID}", 'rights' => 'R'}]; # e.g.: "[{'id' => "5340033E7FBBC308BC329414A0DF3C20", 'rights' => 'R'}]"

#Create a JSON with all parameters
my %_query = ('servers' => $servers);
my $query = encode_json \%_query;

print _addServersSharedStorage($id, $query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersSharedStorage
# Language: PHP
#
# Description: this function adds servers to shared storage
###########################################################################

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

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

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

echo addServersSharedStorage($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addServersSharedStorage
# Language: Python
#
# Description: this function adds servers to shared storage
###########################################################################
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 _addServersSharedStorage(id, content):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
servers = [{'id':"{YOUR_SERVER_ID}", 'rights':'R'}] # e.g.: [{'id':"5340033E7FBBC308BC329414A0DF3C20", 'rights':'R'}]

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

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

Create

Creates a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSharedStorage
# Language: Perl
#
# Description: this function creates a new shared storage
###########################################################################
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 _createSharedStorage
{
	my ($content) = @_;
	my $_command = $url ."/shared_storages";
	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_type('application/json');
	$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 shared storage";
my $description = "My shared storage description";
my $size = 50;

#Create a JSON with all parameters
my %_query = ("name" => $name, "description" => $description, "size" => $size);
my $query = encode_json \%_query;

print _createSharedStorage($query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSharedStorage
# Language: PHP
#
# Description: this function creates a new shared storage
###########################################################################

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

function createSharedStorage($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/shared_storages";
	$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 shared storage";
$description = "My shared storage description";
$size = 50;

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

echo createSharedStorage($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSharedStorage
# Language: Python
#
# Description: this function creates a new shared storage
###########################################################################
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 _createSharedStorage(content):
    #Configure the request
    _command = url + "/shared_storages"
    _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 shared storage'
description = 'My shared storage description'
size = 200

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

#Create shared storage
print(_createSharedStorage(data))

Remove Server

Removes a Server from a Shared Storage. The Server itself is not deleted..

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServersSharedStorage
# Language: Perl
#
# Description: deletes servers form shared storage
###########################################################################
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 _deleteServerSharedStorage
{	
	my ($id, $server_id) = @_;
	$_command = $url ."/shared_storages/$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
my $id = "{YOUR_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print _deleteServerSharedStorage($id, $server_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServersSharedStorage
# Language: Python
#
# Description: deletes servers form shared storage
###########################################################################

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

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

echo deleteServerSharedStorage($id, $server_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServersSharedStorage
# Language: Python
#
# Description: deletes servers form shared storage
###########################################################################
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 _deleteServerSharedStorage(id, server_id):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print(_deleteServerSharedStorage(id, server_id))

Delete

Deletes a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSharedStorage
# Language: Perl
#
# Description: deletes shared storage
###########################################################################
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 _deleteSharedStorage
{	
	my ($id) = @_;
	$_command = $url ."/shared_storages/" .$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
my $id = "{YOUR_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete shared storages
print _deleteSharedStorage($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSharedStorage
# Language: PHP
#
# Description: deletes shared storage
###########################################################################

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

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

echo deleteSharedStorage($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSharedStorage
# Language: Python
#
# Description: deletes shared storage
###########################################################################
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 _deleteSharedStorage(id):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Delete shared storage
print(_deleteSharedStorage(id))

Get Access

Returns the access information to the Shared Storages.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: getAccessSharedStorage
# Language: Perl
#
# Description: returns credentials for accessing to shared storage
###########################################################################
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 _getAccessSharedStorages
{	
	$_command = $url ."/shared_storages/access";
	$_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;
	}	
}

print _getAccessSharedStorages;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: getAccessSharedStorage
# Language: PHP
#
# Description: returns credentials for accessing to shared storage
###########################################################################

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

function getAccessSharedStorage(){
	global $url;
	global $TOKEN;
	$_command = $url . "/shared_storages/access";
	$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 getAccessSharedStorage();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: getAccessSharedStorage
# Language: Python
#
# Description: returns credentials for accessing to shared storage
###########################################################################
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 _getAccessSharedStorage():
    #Configure the request
    _command = url + "/shared_storages/access"
    _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(_getAccessSharedStorage())

Info Server

.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServerSharedStorage
# Language: Perl
#
# Description: information about servers assigned to shared storage
###########################################################################
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 _infoServerSharedStorage
{	
	my ($id, $server_id) = @_;
	$_command = $url ."/shared_storages/$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
my $id = "{YOUR_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $server_id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print _infoServerSharedStorage($id, $server_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServersSharedStorage
# Language: PHP
#
# Description: information about servers assigned to shared storage
###########################################################################

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

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

echo infoServerSharedStorage($id, $server_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServersSharedStorage
# Language: Python
#
# Description: information about servers assigned to shared storage
###########################################################################
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 _infoServersSharedStorage(id, server_id):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
server_id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info servers
print(_infoServersSharedStorage(id, server_id))

Info

Returns the information of one Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoSharedStorage
# Language: Perl
#
# Description: this function returns information about shared storage
###########################################################################
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 _infoSharedStorage
{	
	my ($id) = @_;
	$_command = $url ."/shared_storages/" .$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
my $id = "{YOUR_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Info shared storages
print _infoSharedStorage($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoSharedStorage
# Language: PHP
#
# Description: this function returns information about shared storage
###########################################################################

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

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

echo infoSharedStorage($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoSharedStorage
# Language: Python
#
# Description: this function returns information about shared storage
###########################################################################
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 _infoSharedStorage(id):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List private networks
print(_infoSharedStorage(id))

List Servers

Returns a list of the Servers of a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersSharedStorage
# Language: Perl
#
# Description: lists servers assigned to shared storage
###########################################################################
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 _listServersSharedStorage
{	
	my ($id) = @_;
	$_command = $url ."/shared_storages/$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
my $id = "{YOUR_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List servers
print _listServersSharedStorage($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersSharedStorage
# Language: PHP
#
# Description: lists servers assigned to shared storage
###########################################################################

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

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

echo listServersSharedStorage($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServersSharedStorage
# Language: Python
#
# Description: lists servers assigned to shared storage
###########################################################################
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 _listServersSharedStorage(id):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#List servers
print(_listServersSharedStorage(id))

List

Returns a list of all Shared Storages.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listSharedStorages
# Language: Perl
#
# Description: this function returns a list of shared storages
###########################################################################
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 _listSharedStorages
{	
	$_command = $url ."/shared_storages";
	$_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 shared storages
print _listSharedStorages;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listSharedStorages
# Language: PHP
#
# Description: this function returns a list of shared storages
###########################################################################

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

function listSharedStorages($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/shared_storages";
	$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 listSharedStorages();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listSharedStorages
# Language: Python
#
# Description: this function returns a list of shared storages
###########################################################################
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 _listSharedStorages():
    #Configure the request
    _command = url + "/shared_storages"
    _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(_listSharedStorages())

Reconfigure

Reconfigures a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureSharedStorage
# Language: Perl
#
# Description: this function allows to change name, description 
# or size of shared storage
###########################################################################
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 _reconfigureSharedStorage
{
	my ($id, $content) = @_;
	my $_command = $url ."/shared_storages/$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_type('application/json');
	$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_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My shared storage";
my $description = "My shared storage description";
my $size = 200;

#Create a JSON with all parameters
my %_query = ('name' => $name, 'description' => $description, 'size' => $size);
my $query = encode_json \%_query;

print _reconfigureSharedStorage($id, $query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureSharedStorage
# Language: PHP
#
# Description: this function allows to change name, description 
# or size of shared storage
###########################################################################

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

function reconfigureSharedStorage($id, $data){
	global $url;
	global $TOKEN;
	$_command = $url . "/shared_storages/$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_SHARED_STORAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "AA My shared storage";
$description = "My shared storage description";
$size = 150;

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

echo reconfigureSharedStorage($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reconfigureSharedStorage
# Language: Python
#
# Description: this function allows to change name, description 
# or size of shared storage
###########################################################################
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 _reconfigureSharedStorage(id, content):
    #Configure the request
    _command = url + "/shared_storages/" + 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_SHARED_STORAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My shared storage'
description = 'My shared storage description'
size = 250

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

#Create shared storage
print(_reconfigureSharedStorage(id, data))

Set Access

Returns a set of the Access of a Shared Storage.

###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setAccessSharedStorage
# Language: Perl
#
# Description: this functions configure the password for accessing to
# shared storages from servers
###########################################################################
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 _setAccessSharedStorages
{
	my ($content) = @_;
	my $_command = $url ."/shared_storages/access";
	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_type('application/json');
	$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 $password = "password";

#Create a JSON with all parameters
my %_query = ("password" => $password);
my $query = encode_json \%_query;

print _setAccessSharedStorages($query); 
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setAccessSharedStorage
# Language: PHP
#
# Description: this functions configure the password for accessing to
# shared storages from servers
###########################################################################

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

function setAccessSharedStorage($data){
	global $url;
	global $TOKEN;
	$_command = $url . "/shared_storages/access";
	$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
$password = "Test2015";

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

echo setAccessSharedStorage($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setAccessSharedStorage
# Language: Python
#
# Description: this functions configure the password for accessing to
# shared storages from servers
###########################################################################
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 _setAccessSharedStorage(content):
    #Configure the request
    _command = url + "/shared_storages/access"
    _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
password = "password"

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

#Set access
print(_setAccessSharedStorage(data))