Servers
Here you can find different examples of actions you can do with your servers
Add Load Balancer
Adds a Load Balancer to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addBalancerServer
# Language: Perl
#
# Description: adds balancer to an IP
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _addBalancerServer
{
my ($id, $ip_id, $content) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/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 $id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $balancer_id = "{YOUR_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my %_query = ("load_balancer_id" => $balancer_id);
my $query = encode_json \%_query;
#Add balancer
print _addBalancerServer($id, $ip_id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addBalancerServer
# Language: PHP
#
# Description: adds balancer to an IP
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function addBalancerServer($id, $ip_id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/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
$id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$balancer_id = "{YOUR_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$data = array('load_balancer_id'=>$balancer_id);
$data = json_encode($data);
echo addBalancerServer($id, $ip_id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addBalancerServer
# Language: Python
#
# Description: adds balancer to an IP
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _addBalancerServer(id, ip_id, content):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/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
id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
load_balancer_id = "{YOUR_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
data = json.dumps({'load_balancer_id':load_balancer_id})
#Add load balancer
print(_addBalancerServer(id, ip_id, data))
Add Firewall
Adds a Firewall Policy to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addFirewallServer
# Language: Perl
#
# Description: adds firewall policy to an IP
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _addFirewallServer
{
my ($id, $ip_id, $content) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/firewall_policy";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $firewall_id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my %_query = ("id" => $firewall_id);
my $query = encode_json \%_query;
#Add IPs
print _addFirewallServer($id, $ip_id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addFirewallServer
# Language: PHP
#
# Description: adds firewall policy to an IP
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function addFirewallServer($id, $ip_id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/firewall_policy";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20";
$firewall_id = "{YOUR_FIREWALL_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$data = array('id'=>$firewall_id);
$data = json_encode($data);
echo addFirewallServer($id, $ip_id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addFirewallServer
# Language: Python
#
# Description: adds firewall policy to an IP
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _addFirewallServer(id, ip_id, content):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/firewall_policy"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
firewall_policy_id = "{YOUR_FIREWALL_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
data = json.dumps({'id':firewall_policy_id})
#Add firewall policy
print(_addFirewallServer(id, ip_id, data))
Add SSD
Adds a SSD to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addHddsServer
# Language: Perl
#
# Description: add more disks to 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://cloudpanel-api.ionos.com/v1";
sub _addHddsServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/" .$id ."/hardware/hdds";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware resources
my $hdds = [{"size" => 60, "is_main" => JSON::false()}];
my %_query = ("hdds" => $hdds);
my $query = encode_json \%_query;
#Add HDDS
print _addHddsServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addHddsServer
# Language: PHP
#
# Description: add more disks to server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function addHddsServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware/hdds";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$hdds = array(array('size'=>20));
$data = array('hdds'=>$hdds);
$data = json_encode($data);
echo addHddsServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addHddsServer
# Language: Python
#
# Description: add more disks to server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _addHddsServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/hardware/hdds"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
hdds = [{'size':40}]
data = json.dumps({'hdds':hdds})
#Add disks
print(_addHddsServer(id, data))
Add Ips
Adds an IP to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addIpsServer
# Language: Perl
#
# Description: this function add a new IP to 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://cloudpanel-api.ionos.com/v1";
sub _addIpsServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/" .$id ."/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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $type = "IPV4";
my %_query = ("type" => $type);
my $query = encode_json \%_query;
#Add IPs
print _addIpsServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addIpsServer
# Language: PHP
#
# Description: this function add a new IP to server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function addIPServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$type = "IPV4";
$data = array('type'=>$type);
$data = json_encode($data);
echo addIPServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addIpsServer
# Language: Python
#
# Description: this function add a new IP to server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _addIpsServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
type = "IPV4"
data = json.dumps({'type':type})
#Add Ips server
print(_addIpsServer(id, data))
Add Private Network
Adds a Private Network to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addPrivateNetworkServer
# Language: Perl
#
# Description: adds server 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://cloudpanel-api.ionos.com/v1";
sub _addPrivateNetworkServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/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)
{
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my %_query = ("id" => $private_network_id);
my $query = encode_json \%_query;
#Add private networks
print _addPrivateNetworkServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addPrivateNetworkServer
# Language: PHP
#
# Description: adds server to private network
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function addPrivateNetworkServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/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
$id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$data = array('id'=>$private_network_id);
$data = json_encode($data);
echo addPrivateNetworkServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addPrivateNetworkServer
# Language: Python
#
# Description: adds server 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://cloudpanel-api.ionos.com/v1"
def _addPrivateNetworkServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/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
id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
private_network_id = "{YOUR_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
data = json.dumps({'id':private_network_id})
#Add private network
print(_addPrivateNetworkServer(id, data))
Clone
Clones a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: cloneServer
# Language: Perl
#
# Description: creates a server based on another server specified
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _cloneServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/clone";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My server";
my %_query = ("name" => $name);
my $query = encode_json \%_query;
#Clone server
print _cloneServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: cloneServer
# Language: PHP
#
# Description: creates a server based on another server specified
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function cloneServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/clone";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "My clone server test PHP";
$data = array('name' => $name);
$data = json_encode($data);
echo cloneServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: cloneServer
# Language: Python
#
# Description: creates a server based on another server specified
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _cloneServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/clone"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My server'
data = json.dumps({'name':name})
#Clone server
print(_cloneServer(id, data))
Create
Creates a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createServer
# Language: Perl
#
# Description: this function creates a new 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://cloudpanel-api.ionos.com/v1";
sub _createServer
{
my ($content) = @_;
my $_command = $url ."/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)
{
#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 server";
my $description = "My server description";
my $appliance_id = "{YOUR_APPLIANCE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware resources
my $vcore = 1;
my $cores_per_processor = 1;
my $ram = 1;
my $hdds = [{"size" => 40, "is_main" => JSON::true()}, {"size" => 20, "is_main" => JSON::false()}];
my $hardware = {"vcore" => $vcore,
"cores_per_processor" => $cores_per_processor,
"ram" => $ram,
"hdds" => $hdds};
my %_query = ("name" => $name, "description" => $description, "hardware" => $hardware, "appliance_id" => $appliance_id);
my $query = encode_json \%_query;
#Create server
print _createServer($query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createServer
# Language: PHP
#
# Description: this function creates a new server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function createServer($data){
global $url;
global $TOKEN;
$_command = $url . "/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
$name = "My server test PHP";
$description = "My server test PHP description";
$vcore = 1;
$cores_per_processor = 1;
$ram = 2;
$hdds = array(array('size'=>20, 'is_main'=>true));
$appliance_id = "07C170D67C8EC776933FCFF1C299C1C5";
$hardware = array('vcore'=>$vcore,
'cores_per_processor'=>$cores_per_processor,
'ram'=>$ram,
'hdds'=>$hdds);
$data = array('name'=>$name, 'description'=>$description, 'hardware'=>$hardware, 'appliance_id'=>$appliance_id);
$data = json_encode($data);
echo createServer($data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createServer
# Language: Python
#
# Description: this function creates a new server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _createServer(content):
#Configure the request
_command = url + "/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
name = 'My server'
description = 'My server description'
appliance_id = "{YOUR_APPLIANCE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware resources
vcore = 1
cores_per_processor = 1
ram = 2
hdds = [{'size':40, 'is_main':True},{'size':20, 'is_main':False}]
hardware = {'vcore':vcore, 'cores_per_processor':cores_per_processor, 'ram':ram, 'hdds':hdds}
data = json.dumps({'name':name, 'description':description, 'hardware':hardware, 'appliance_id':appliance_id})
#Create server
print(_createServer(data))
Create Snapshot
Creates a Snapshot from a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSnapshotServer
# Language: Perl
#
# Description: creates snapshot
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _createSnapshotServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/snapshots";
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');
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Create snapshots
print _createSnapshotServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSnapshotServer
# Language: PHP
#
# Description: creates snapshot
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function createSnapshotServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/snapshots";
$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");
//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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo createSnapshotServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: createSnapshotServer
# Language: Python
#
# Description: creates snapshot
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _createSnapshotServer(id):
#Configure the request
_command = url + "/servers/" + id + "/snapshots"
_method = 'POST'
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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Create snapshot
print(_createSnapshotServer(id))
Remove Load Balancer
Removes a Load Balancer from a Server. The Load balancer itself is not deleted..
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteBalancerServer
# Language: Perl
#
# Description: delete 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://cloudpanel-api.ionos.com/v1";
sub _deleteBalancerServer
{
my ($id, $ip_id, $load_balancer_id) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/load_balancers/$load_balancer_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $load_balancer_id = "{YOUR_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Removes firewall
print _deleteBalancerServer($id, $ip_id, $load_balancer_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteBalancerServer
# Language: PHP
#
# Description: delete balancers
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteBalancerServer($id, $ip_id, $load_balancer_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/load_balancers/$load_balancer_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$load_balancer_id = "{YOUR_BALANCER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteBalancerServer($id, $ip_id, $load_balancer_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteBalancerServer
# Language: Python
#
# Description: delete balancers
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteBalancerServer(id, ip_id, load_balancer_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/load_balancers/" + load_balancer_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
load_balancer_id = "{YOUR_BALANCER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete load balancer
print(_deleteBalancerServer(id, ip_id, load_balancer_id))
Remove Firewall
Removes a Firewall Policy from a Server. The Firewall Policy itself is not deleted..
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallServer
# Language: Perl
#
# Description: removes firewall policy
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
require Http::Request::Common;
#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://cloudpanel-api.ionos.com/v1";
sub _deleteFirewallServer
{
my ($id, $ip_id) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/firewall_policy";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Removes firewall
print _deleteFirewallServer($id, $ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallServer
# Language: PHP
#
# Description: removes firewall policy
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteFirewallServer($id, $ip_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/firewall_policy";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteFirewallServer($id, $ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteFirewallServer
# Language: Python
#
# Description: removes firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteFirewallServer(id, ip_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/firewall_policy"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete firewall policy
print(_deleteFirewallServer(id, ip_id))
Delete SSD
Deletes an SSD from a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteHddsServer
# Language: Perl
#
# Description: remove SSD
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _deleteHddsServer
{
my ($id, $hdds_id) = @_;
my $_command = $url ."/servers/$id/hardware/hdds/$hdds_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $hdds_id = "{YOUR_HDD_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Removes hdds
print _deleteHddsServer($id, $hdds_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteHddsServer
# Language: PHP
#
# Description: remove SSD
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteHddsServer($id, $hdds_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware/hdds/$hdds_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$hdds_id = "{YOUR_HDDS_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteHddsServer($id, $hdds_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteHddsServer
# Language: Python
#
# Description: remove SSD
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteHddsServer(id, hdds_id):
#Configure the request
_command = url + "/servers/" + id + "/hardware/hdds/" + hdds_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
hdds_id = "{YOUR_HDD_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Remove disk
print(_deleteHddsServer(id, hdds_id))
Delete IP
Deletes an IP from a Server .
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteIpServer
# Language: Perl
#
# Description: removes IP
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _deleteIpServer
{
my ($id, $ip_id) = @_;
my $_command = $url ."/servers/$id/ips/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete IP
print _deleteIpServer($id, $ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteIpServer
# Language: PHP
#
# Description: removes IP
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteIpServer($id, $ip_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteIpServer($id, $ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteIpServer
# Language: Python
#
# Description: removes IP
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteIpServer(id, ip_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + 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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Removes IP
print(_deleteIpServer(id, ip_id))
Remove Private Network
Removes a Private Network from a Server. The Private Network itself is not deleted.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetworkServer
# Language: Perl
#
# Description: remove server from private network
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _deletePrivateNetworkServer
{
my ($id, $private_network_id) = @_;
my $_command = $url ."/servers/$id/private_networks/$private_network_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Remove private networks
print _deletePrivateNetworkServer($id, $private_network_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetworkServer
# Language: PHP
#
# Description: remove server from private network
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deletePrivateNetworkServer($id, $private_network_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/private_networks/$private_network_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deletePrivateNetworkServer($id, $private_network_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deletePrivateNetworkServer
# Language: Python
#
# Description: remove server 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://cloudpanel-api.ionos.com/v1"
def _deletePrivateNetworkServer(id, private_network_id):
#Configure the request
_command = url + "/servers/" + id + "/private_networks/" + private_network_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
private_network_id = "{YOUR_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete Private networks
print(_deletePrivateNetworkServer(id, private_network_id))
Delete
Deletes a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServer
# Language: Perl
#
# Description: deletes servers
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _deleteServer
{
my ($id) = @_;
$_command = $url ."/servers/" .$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete server
print _deleteServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServer
# Language: PHP
#
# Description: removes server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteServer
# Language: Python
#
# Description: removes server
###########################################################################
from urllib.request import Request, urlopen
import urllib
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteServer(id):
#Configure the request
_command = url + "/servers/" + 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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete server
print(_deleteServer(id))
Delete Snapshot
Deletes a Snapshot from a Server. The Server does not change..
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSnapshotServer
# Language: Perl
#
# Description: delete snapshot
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _deleteSnapshotServer
{
my ($id, $snapshot_id) = @_;
my $_command = $url ."/servers/$id/snapshots/$snapshot_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $snapshot_id = "{YOUR_SNAPSHOT_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete snapshot
print _deleteSnapshotServer($id, $snapshot_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSnapshotServer
# Language: PHP
#
# Description: delete snapshot
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function deleteSnapshotServer($id, $snapshot_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/snapshots/$snapshot_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$snapshot_id = "{YOUR_SNAPSHOT_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo deleteSnapshotServer($id, $snapshot_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteSnapshotServer
# Language: Python
#
# Description: delete snapshot
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _deleteSnapshotServer(id, snapshot_id):
#Configure the request
_command = url + "/servers/" + id + "/snapshots/" + snapshot_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
snapshot_id = "{YOUR_SNAPSHOT_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete snapshots
print(_deleteSnapshotServer(id, snapshot_id))
Info Load Balancer
Returns the information of the Load Balancer attached to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoBalancerServer
#
# Description: this function returns information about load balancers
# assigned to an IP
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoBalancerServer
{
my ($id, $ip_id) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/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);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info balancers
print _infoBalancerServer($id, $ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoBalancerServer
# Language: PHP
#
# Description: information about balarcers assigned to IP
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoBalancerServer($id, $ip_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/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
$id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoBalancerServer($id, $ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoBalancerServer
# Language: Python
#
# Description: information about balarcers assigned to IP
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoBalancerServer(id, ip_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/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
id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info load balancer
print(_infoBalancerServer(id, ip_id))
Info DVD
Returns the information of the DVD loaded in the Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoDVDServer
#
# Description: returns information about the DVD inserted on virtual
# server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoDVDServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/dvd";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#DVD
print _infoDVDServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoDvdServer
# Language: PHP
#
# Description: image inserted in server's virtual DVD
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoDvdServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/dvd";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoDvdServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoDvdServer
# Language: Python
#
# Description: image inserted in server's virtual DVD
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoDvdServer(id):
#Configure the request
_command = url + "/servers/" + id + "/dvd"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info DVD
print(_infoDvdServer(id))
Info Firewall
Returns the information of the Firewall Policy attached to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallServer
#
# Description: this function returns information about firewall policy
# assigned to an IP
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoFirewallServer
{
my ($id, $ip_id) = @_;
my $_command = $url ."/servers/$id/ips/$ip_id/firewall_policy";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info firewall
print _infoFirewallServer($id, $ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallServer
# Language: PHP
#
# Description: information about server's firewall policy
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoFirewallServer($id, $ip_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$ip_id/firewall_policy";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoFirewallServer($id, $ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoFirewallServer
# Language: Python
#
# Description: information about server's firewall policy
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoFirewallServer(id, ip_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + ip_id + "/firewall_policy"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info firewall policy
print(_infoFirewallServer(id, ip_id))
Info Hardware
Returns the information of the Hardware (CPU, RAM, SSD) of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHardwareServer
#
# Description: this function returns information about server's hardware
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoHardwareServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/hardware";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware information
print _infoHardwareServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHardwareServer
# Language: PHP
#
# Description: this function returns hardware resources
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoHardwareServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoHardwareServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHardwareServer
# Language: Python
#
# Description: this function returns hardware resources
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoHardwareServer(id):
#Configure the request
_command = url + "/servers/" + id + "/hardware"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info hardware
print(_infoHardwareServer(id))
Info SSDs
Returns the information of the SSDs of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHddsServer
#
# Description: this function returns information about one disk
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoHddsServer
{
my ($id, $hdds_id) = @_;
my $_command = $url ."/servers/$id/hardware/hdds/$hdds_id";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $hdds_id = "{YOUR_HDD_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information about servers
print _infoHddsServer($id, $hdds_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHddsServer
# Language: PHP
#
# Description: returns information about one SSD
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoHddsServer($id, $hdds_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware/hdds/$hdds_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$hdds_id = "{YOUR_HDD_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoHddsServer($id, $hdds_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoHddsServer
# Language: Python
#
# Description: returns information about one SSD
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoHddsServer(id, hdds_id):
#Configure the request
_command = url + "/servers/" + id + "/hardware/hdds/" + hdds_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
hdds_id = "{YOUR_HDD_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info HDDS
print(_infoHddsServer(id, hdds_id))
Info Image
Returns the information of the Image of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoImageServer
#
# Description: this function returns information about the server's image
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoImageServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/image";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Server's image
print _infoImageServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoImageServer
# Language: PHP
#
# Description: returns information about the image installed on server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoImageServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/image";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoImageServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoImageServer
# Language: Python
#
# Description: returns information about the image installed on server
###########################################################################
from urllib.request import Request, urlopen
import urllib
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoImageSever(id):
#Configure the request
_command = url + "/servers/" + id + "/image"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info server
print(_infoImageSever(id))
Info IP
Returns the information of the IPs attached to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoIpServer
#
# Description: this function returns information about one server's IPs
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoIpServer
{
my ($id, $ip_id) = @_;
my $_command = $url ."/servers/$id/ips/$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);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info IP
print _infoIpServer($id, $ip_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoIpServer
# Language: PHP
#
# Description: information about IP
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoIpServer($id, $ip_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/ips/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$ip_id = "{YOUR_IP_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoIpServer($id, $ip_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoIpServer
# Language: Python
#
# Description: information about IP
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoIpServer(id, ip_id):
#Configure the request
_command = url + "/servers/" + id + "/ips/" + 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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
ip_id = "{YOUR_IP_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info IP
print(_infoIpServer(id, ip_id))
Info Private Network
Returns the information of the Private Networks attached to a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetworkServer
#
# Description: returns information about the networks the server is
# is assigned
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoPrivateNetworkServer
{
my ($id, $private_network_id) = @_;
my $_command = $url ."/servers/$id/private_networks/$private_network_id";
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information about private networks
print _infoPrivateNetworkServer($id, $private_network_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetworkServer
# Language: PHP
#
# Description: returns the IPs of the server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoPrivateNetworkServer($id, $private_network_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/private_networks/$private_network_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$private_network_id = "{YOUR_PRIVATE_NETWORK_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoPrivateNetworkServer($id, $private_network_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoPrivateNetworkServer
# Language: Python
#
# Description: returns the IPs of the server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoPrivateNetworkServer(id, private_network_id):
#Configure the request
_command = url + "/servers/" + id + "/private_networks/" + private_network_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
private_network_id = "{YOUR_PRIVATE_NETWORK_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info Private networks
print(_infoPrivateNetworkServer(id, private_network_id))
Info
Returns the information of one Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServer
#
# Description: this function returns all information about one server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id;
my $_method = 'GET';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information about servers
print _infoServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServer
# Language: PHP
#
# Description: returns information about required server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo infoServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoServer
# Language: Python
#
# Description: returns information about required server
###########################################################################
from urllib.request import Request, urlopen
import urllib
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoServer(id):
#Configure the request
_command = url + "/servers/" + 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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info server
print(_infoServer(id))
Info Snapshot
Returns the information of the Snapshot of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: infoSnapshotServer
# Language: Perl
#
# Description: information about current snapshots
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _infoSnapshotServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/snapshots";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info snapshots
print _infoSnapshotServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: getSnapshotServer
# Language: PHP
#
# Description: information about current snapshots
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function infoSnapshotServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/snapshots";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo getSnapshotServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: getSnapshotServer
# Language: Python
#
# Description: information about current snapshots
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _infoSnapshotServer(id):
#Configure the request
_command = url + "/servers/" + id + "/snapshots"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info snapshots
print(_getSnapshotServer(id))
List SSDs
Returns a list of the SSDs of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listHddsServer
# Language: Perl
#
# Description: returns information about the SSD of the server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _listHddsServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/hardware/hdds";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information
print _listHddsServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listHddsServer
# Language: PHP
#
# Description: returns information about the SSD of the server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function listHddsServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware/hdds";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo listHddsServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listHddsServer
# Language: Python
#
# Description: returns information about the SSD of the server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _listHddsServer(id):
#Configure the request
_command = url + "/servers/" + id + "/hardware/hdds"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info hardware
print(_listHddsServer(id))
List IPs
Returns a list of the IPs of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listIpsServer
# Language: Perl
#
# Description: returns the IPs of the server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _listIpsServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Lists server's IPs
print _listIpsServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listIpsServer
# Language: PHP
#
# Description: returns the IPs of the server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function listIpsServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo listIpsServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listIpsServer
# Language: Python
#
# Description: returns the IPs of the server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _listIpsServer(id):
#Configure the request
_command = url + "/servers/" + id + "/ips"
_method = 'GET'
request = Request(_command,
headers={'X-TOKEN':TOKEN, 'content-type':'application/json'},
method=_method)
#Try to get the response
try:
response = urlopen(request)
content = response.read()
return (content.decode())
#Fetch error
except urllib.error.URLError as e:
return("Error " + str(e.code) + ":" + e.reason)
#PARAMETERS
id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#List Ips
print(_listIpsServer(id))
List Private Networks
Returns a list of the Private Networks of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworksServer
# Language: Perl
#
# Description: returns the IPs of the server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _listPrivateNetworkServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/private_networks";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information about private networks
print _listPrivateNetworkServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworksServer
# Language: PHP
#
# Description: returns the IPs of the server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function listPrivateNetworksServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/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
$id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo listPrivateNetworksServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listPrivateNetworksServer
# Language: Python
#
# Description: returns the IPs of the server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _listPrivateNetworkServer(id):
#Configure the request
_command = url + "/servers/" + id + "/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
id = "{YOUR_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#List Private networks
print(_listPrivateNetworkServer(id))
List
Returns a list of all Servers.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServers
# Language: Perl
#
# Description: returns a list with servers of Cloud Panel
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _listServers
{
my $_command = $url ."/servers";
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 servers
print _listServers;
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServers
# Language: PHP
#
# Description: returns a list with servers of Cloud Panel
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function listServers(){
global $url;
global $TOKEN;
$_command = $url . "/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
echo listServers();
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listServers
# Language: Python
#
# Description: returns a list with servers of Cloud Panel
###########################################################################
from urllib.request import Request, urlopen
import urllib
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _listServers():
#Configure the request
_command = url + "/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
#List servers
print(_listServers())
Load DVD
Loads a DVD into a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addDvdServer
# Language: Perl
#
# Description: introduce image into virtual DVD unit
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _loadDVDServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/dvd";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $dvd_id = "{YOUR_ISO_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my %_query = ("id" => $dvd_id);
my $query = encode_json \%_query;
#Add DVD image
print _loadDVDServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addDvdServer
# Language: PHP
#
# Description: introduce image into virtual DVD unit
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function loadDvdServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/dvd";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$iso_id = "{YOUR_ISO_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$data = array('id'=>$iso_id);
$data = json_encode($data);
echo loadDvdServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: addDvdServer
# Language: Python
#
# Description: introduce image into virtual DVD unit
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _loadDvdServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/dvd"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
image_id = "{YOUR_IMAGE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
data = json.dumps({'id':image_id})
#Put image
print(_loadDvdServer(id, data))
Reinstall Image
Reinstalls an image on a server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reinstallImageServer
# Language: Perl
#
# Description: this function changes RAM and CPU resources
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _reinstallImageServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/image";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $image_id = "{YOUR_IMAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my %_query = ("id" => $image_id);
my $query = encode_json \%_query;
#Reinstall image
print _reinstallImageServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reinstallImageServer
# Language: PHP
#
# Description: this function changes RAM and CPU resources
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function reinstallImageServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/image";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$image_id = "{YOUR_IMAGE_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$data = array('id'=>$image_id);
$data = json_encode($data);
echo reinstallImageServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: reinstallImageServer
# Language: Python
#
# Description: this function changes RAM and CPU resources
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _reinstallImageServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/image"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
appliance_id = "{YOUR_APPLIANCE_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
data = json.dumps({'id':appliance_id})
#Reinstall image
print(_reinstallImageServer(id, data))
Remove DVD
Removes a DVD from a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: removeDVDServer
#
# Description: this function removes DVD inserted on server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _removeDVDServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/dvd";
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');
#Ignore the certificate
$ua->ssl_opts(verify_hostname => 0);
$ua->ssl_opts(SSL_verify_mode => 0x00);
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Removes DVD
print _removeDVDServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteDvdServer
# Language: PHP
#
# Description: removes image form server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function removeDvdServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/dvd";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo removeDvdServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: deleteDvdServer
# Language: Python
#
# Description: removes image form server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _removeDvdServer(id):
#Configure the request
_command = url + "/servers/" + id + "/dvd"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Delete image
print(_removeDvdServer(id))
Rename
Renames a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameServer
# Language: Perl
#
# Description: renames specified 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://cloudpanel-api.ionos.com/v1";
sub _renameServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/" .$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $name = "My server";
my $description = "My server description";
my %_query = ("name" => $name, "description" => $description);
my $query = encode_json \%_query;
#Rename server
print _renameServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameServer
# Language: PHP
#
# Description: renames specified server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function renameServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$name = "AA My server test rename PHP";
$description = "AA My server test PHP rename description";
$data = array('name'=>$name, 'description'=>$description);
$data = json_encode($data);
echo renameServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: renameServer
# Language: Python
#
# Description: renames specified server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _renameServer(id, content):
#Configure the request
_command = url + "/servers/" + 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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
name = 'My server'
description = 'My server description'
data = json.dumps({'name':name, 'description':description})
#Rename server
print(_renameServer(id, data))
Resize SSD
Resizes the SSD of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeServer
# Language: Perl
#
# Description: this function changes RAM and CPU resources
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _resizeHddsServer
{
my ($id, $hdds_id, $content) = @_;
my $_command = $url ."/servers/$id/hardware/hdds/$hdds_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $hdds_id = "{YOUR_HDD_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware resources
my $size = 40;
my %_query = ("size" => $size);
my $query = encode_json \%_query;
#Edit HDDS
print _resizeHddsServer($id, $hdds_id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeHddsServer
# Language: PHP
#
# Description: increase disk size
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function resizeHddsServer($id, $hdds_id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware/hdds/$hdds_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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$hdds_id = "{YOUR_HDD_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$size = 20;
$data = array('size'=>$size);
$data = json_encode($data);
echo resizeHddsServer($id, $hdds_id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeHddsServer
# Language: Python
#
# Description: increase disk size
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _resizeHddsServer(id, hdds_id, content):
#Configure the request
_command = url + "/servers/" + id + "/hardware/hdds/" + hdds_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
hdds_id = "{YOUR_HDD_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
size = 40
data = json.dumps({'size': size})
#Resize disk
print(_resizeHddsServer(id, hdds_id, data))
Resize
Resizes (CPU, RAM) a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeServer
#
# Description: this function reconfigure hardware features of a 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://cloudpanel-api.ionos.com/v1";
sub _resizeServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/hardware";
my $_method = 'PUT';
#Create the request
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($_method => $_command);
$request->header('X-TOKEN' => $TOKEN);
#Add additional parameters
$request->content_type('application/json');
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Hardware resources
my $vcore = 2;
my $cores_per_processor = 1;
my $ram = 2.5;
my %_query = ("vcore" => $vcore, "cores_per_processor" => $cores_per_processor, "ram" => $ram);
my $query = encode_json \%_query;
#Reconfigure server
print _resizeServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeServer
# Language: PHP
#
# Description: this function changes RAM and CPU resources
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function resizeServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/hardware";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$vcore = 1;
$cores_per_processor = 1;
$ram = 2.5;
$data = array('vcore'=>$vcore, 'cores_per_processor'=>$cores_per_processor, 'ram'=>$ram);
$data = json_encode($data);
echo resizeServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: resizeServer
# Language: Python
#
# Description: this function changes RAM and CPU resources
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _resizeServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/hardware"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
vcore = 2
cores_per_processor = 1
ram = 3
data = json.dumps({'vcore':vcore, 'cores_per_processor':cores_per_processor, 'ram':ram})
#Create server
print(_resizeServer(id, data))
Restore Snapshot
Restores an snapshot on a server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: restoreSnapshotServer
# Language: Perl
#
# Description: restore snapshot
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _restoreSnapshotServer
{
my ($id, $snapshot_id) = @_;
my $_command = $url ."/servers/$id/snapshots/$snapshot_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');
#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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $snapshot_id = "{YOUR_SNAPSHOT_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Restore snapshot
print _restoreSnapshotServer($id, $snapshot_id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: restoreSnapshotServer
# Language: PHP
#
# Description: restore snapshot
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function restoreSnapshotServer($id, $snapshot_id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/snapshots/$snapshot_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");
//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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$snapshot_id = "{YOUR_SNAPSHOT_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo restoreSnapshotServer($id, $snapshot_id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: restoreSnapshotServer
# Language: Python
#
# Description: restore snapshot
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _restoreSnapshotServer(id, snapshot_id):
#Configure the request
_command = url + "/servers/" + id + "/snapshots/" + snapshot_id
_method = 'PUT'
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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
snapshot_id = "{YOUR_SNAPSHOT_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Restore snapshots
print(_restoreSnapshotServer(id, snapshot_id))
Set State
Returns a set of the State of a State Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setStatusServer
# Language: Perl
#
# Description: allows to power on, power off and reboot 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://cloudpanel-api.ionos.com/v1";
sub _setStateServer
{
my ($id, $content) = @_;
my $_command = $url ."/servers/$id/status/action";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
my $action = "POWER_OFF";
my $method = "SOFTWARE";
my %_query = ("action" => $action, "method" => $method);
my $query = encode_json \%_query;
#Set state
print _setStateServer($id, $query);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setStatusServer
# Language: PHP
#
# Description: allows to power on, power off and reboot server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function setStatusServer($id, $data){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/status/action";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
$action = "REBOOT";
$method = "SOFTWARE";
$data = array('action'=>$action, 'method'=>$method);
$data = json_encode($data);
echo setStatusServer($id, $data);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setStatusServer
# Language: Python
#
# Description: allows to power on, power off and reboot server
###########################################################################
from urllib.request import Request, urlopen
import urllib
import json
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _setStatusServer(id, content):
#Configure the request
_command = url + "/servers/" + id + "/status/action"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
action = "POWER_OFF"
method = "SOFTWARE"
data = json.dumps({'action':action, 'method':method})
#Power off server
print(_setStatusServer(id, data))
Status
Returns the status of a Server.
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: statusServer
# Language: Perl
#
# Description: state of the server
###########################################################################
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://cloudpanel-api.ionos.com/v1";
sub _statusServer
{
my ($id) = @_;
my $_command = $url ."/servers/" .$id ."/status";
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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Information about servers
print _statusServer($id);
<?php
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: statusServer
# Language: PHP
#
# Description: state of the server
###########################################################################
#ID access to API
$TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
$url = "https://cloudpanel-api.ionos.com/v1";
function statusServer($id){
global $url;
global $TOKEN;
$_command = $url . "/servers/$id/status";
$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_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
echo statusServer($id);
?>
###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: statusServer
# Language: Python
#
# Description: state of the server
###########################################################################
from urllib.request import Request, urlopen
import urllib
#ID access to API
TOKEN = "{YOUR_API_TOKEN}" # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
url = "https://cloudpanel-api.ionos.com/v1"
def _statusServer(id):
#Configure the request
_command = url + "/servers/" + id + "/status"
_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_SERVER_ID}" # e.g.: "5340033E7FBBC308BC329414A0DF3C20"
#Info server
print(_statusServer(id))