Cloud Tony

getClouder API Documentation

CloudTony Client API v1.0

Welcome to the CloudTony Client API v1.0 Documentation!

Third parties are the easy way to use and build automated procedures (applications). For this purpose, the CloudTony Client API is primarily developed with the CloudTony Services. Thanks to this API you can create, destroy or any other aspect of managing a Cloud with CloudTony.

The CloudTony Client API is designed in a way to be easily understood. Requests are sent via HTTP POST, GET, PUT OR DELETE method and responses are in JSON format.

In case of any problems related to the CloudTony Client API, please post a technical support ticket via the CloudTony support section

Authentication

Authenticate as an existing client is required to use the CloudTony client API. For this purpose, you need an unique API_KEY. Such a key can be obtained from the CloudTony User Area under the API section. Click on the Generate Key button and a new unique key for your account will be generated.

In case of API_KEY lost, you can always regenerate a new one under the API section of the CloudTony User Area.

You have to authenticate for each request to the API service by providing the key within the JSON request object.

Statuses

Each of the API responses is a JSON object that contains an error value. This values indicates whether the request to the API service was successfully executed or not. The request could fail either due to a problem with the system or due to wrongly provided structure/parameters:

error value Description
true Failed to execute the request. Please make sure you send your request with the correct action, params and request structure.
false The request has been successfully executed

General Errors

In case of request fail, the API will respond with error true and a message identifying the mistake. The following error codes represents some problems in the API request structure:

Error code Description
404 In case of url error or url missing a param
500 Invalid JSON in request! There is a synthetical error in the JSON request.

Locations

Each Cloud has a location ID as a parameter in its details - location. This location ID is also required when creating a new Cloud instance. Based on the provided location ID the Cloud will be created in the respective location. Currently available locations are:

Response

location ID Location
2 Switzerland - Lausanne
3 Bulgaria
4 France - Sophia Antipolis

Example

<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/locations';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
											
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://www.cloudtony.com/api/v1/locations'

Response Example


  {
    "error": false,
    "locations": [
      {
        "id": 2,
        "name": "Suisse - Meyrin",
        "code": "CH"
      },
      {
        "id": 3,
        "name": "Bulgarie - Sofia",
        "code": "BG"
      },
      {
        "id": 4,
        "name": "France - Aix en provence",
        "code": "FR"
      }
    ]
  }
                      

Get user Clouds

To execute this action you have to send a GET request.

This API action will list all Clouds in your account. The response will be a JSON array named clouds. This array will contain objects representing each Cloud instance.

Each element of this array contains a JSON array with cloud attributes.

Response

Name Type Description
id integer Unique identifier of the Cloud that was automatically generated at creation
status integer The status of the Cloud.
host string This is an internal name of the Cloud. Please note this is not the actual hostname of the Cloud.
image integer The ID of the image the Cloud instance was provisioned with
ip string The public IP address of the Cloud
location integer Datacenter identifier

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/clouds';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
							
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://cloudtony.com/api/v1/clouds'

Response Example


								{
									"error": false,
									"clouds": 
									[
										{
											"id": 53316,
											"image_id": 10,
											"host": "mja-new-centos",
											"ip": "10.10.10.10",
											"location": "CH",
											"date_create": "2017-01-24 11:52:36",
											"status": "running"
										}
									]
								}
							

Get Clouds by Status

To execute this action you have to send a POST request specifying the status.

This API action will list all Clouds in your account having the specified status. The response will be a JSON array named clouds. This array will contain objects representing each Cloud instance.

Request

Name Type Description Required
status string Clouds' status (runnig, stopped or all). Yes

Response

Name Type Description
id integer Unique identifier of the Cloud that was automatically generated at creation
status integer The status of the Cloud.
host string This is an internal name of the Cloud. Please note this is not the actual hostname of the Cloud.
image integer The ID of the image the Cloud instance was provisioned with
ip string The public IP address of the Cloud
location integer Location identifier

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/clouds';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'status=status';
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
					
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X POST 'https://cloudtony.com/api/v1/clouds'
  -d {'status':'stopped'}

Response Example


						{
							"error": false,
							"clouds": 
							[
								{
									"id": 53316,
									"image_id": 10,
									"host": "mja-new-centos",
									"ip": "10.10.10.10",
									"location": "CH",
									"date_create": "2017-01-24 11:52:36",
									"status": "running"
								}
							]
						}
					

Get Cloud Details

To execute this action you have to send a GET request.

Request

This action will provide a detailed information for the specified Cloud in the request. The unique id of the Cloud is required:

Name Type Description Required
cloud_id integer Unique id of the Cloud instance that was generated at creation Yes

Response

The response will be an JSON object, which is an array of attributes/objects of the specified in the request Cloud instance:

Name Type Description
id integer Unique identifier of the Cloud that was automatically generated at creation
status integer The status of the Cloud.
host string This is an internal name of the Cloud. Please note this is not the actual hostname of the Cloud.
image integer The ID of the image the Cloud instance was provisioned with
ip string The public IP address of the Cloud
location integer Location identifier

Errors

In case of failure the API will respond with a JSON array that contains parameter error with value true and a message that can be:

Message Description
Access restricted. Your API KEY is not valid API_KEY is wrong.
Cloud does not exist Cloud with this ID doesn’t exist.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/cloud/cloud_id';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
					
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://cloudtony.com/api/v1/cloud/cloud_id'

Response Example


						{
							"error": false,
							"id": 53316,
							"image_id": 10,
							"host": "mja-new-centos",
							"ip": "10.10.10.10",
							"location": "CH",
							"date_create": "2017-01-24 11:52:36",
							"status": "running"
						}
					

Create a New Cloud

This action allows you to create a new Cloud. You need to send a POST request and action name: create

Request

To succeed the creation of the new Cloud instance, you must provide all required attributes in the JSON data object. Note, that the password parameter must be encrypted.

Name Type Discription Required
hostname string A human-readable name you want to create the Cloud with. Yes
password string The root user password for the Cloud. Yes
image_id string The image OS id of the image you wich to provision the Cloud with. You can find the available images by using the Get Available OS Images API action. NB: offer 'type' must be the same of image 'type'. Yes
offer_id string The offer id of the image you wich to provision the Cloud with. You can find the available offers by using the Get Offers API action. NB: offer 'type' must be the same of image 'type'. Yes
location integer Geographic location the Cloud to be create at. You can get it in Locations section, the parameter 'cod' of the response. Yes
backup integer An int (0 or 1) to activate the backup or not. Yes

Response

The response of this action provides a JSON object. In case of fail, it contains an error parameter with true value and a message specifiying the type of error. Otherwise, it contains the following parameters:

Name Type Discription
error boolean a boolean value indicating if an error occured when creating Cloud.
cloud_id integer Unique id of the Cloud instance that was generated at creation.
status integer a boolean value indicating if an error occured when creating Cloud.
result String a string message specifiing the status of creation.

Errors

This API action can fail with one of the following errors:

Error message Description
Invalid hostname format The format of hostname is not in the good format.
Incorrect image_id image_id does not match a valid image.
Incorrect offer_id offer_id does not match a valid offer
Invalid backup value backup value should be 0 or 1.
cloud create failed The cloud couldn't be created.
Number of authorized clouds is reached. The number of clouds authorized for your account is reached.
Account not allowed to create a new cloud. Suspended account or insufficient credit.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/cloud/create';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'hostname=hostname&password=password&image_id=image_id&offer_id=offer_id&location=location&backup=backup';
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
									
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X POST 'https://cloudtony.com/api/v1/cloud/create'
  -d {'hostname':'hostname','password':'pwd','image_id':'image_id','offer_id':'offer_id','location':'location','backup':'backup'}

Response Example


										{
											{
											    "error": false,
											    "cloud_id": 10101,
											    "status": 100,
											    "result": "Cloud creation ready"
											}
										}
									

Destroy a Cloud

This action will physically destroy a particular Cloud. Please note that once destroyed the Cloud cannot be restored. To execute this task you have to send a DELETE request.

Request

This action requires a cloud_id parameter to be supplied over the request. You can retrieve all unique ids of your Clouds using the Get Active Clouds action.

Parameter Type Description Required
cloud_id integer Cloud's ID to destroy. Yes

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of wrongly built request or failure of the API service to execute the requested action, the API will provide one of the following erros.

Error message Description
Cloud does not exist No Cloud found with this cloud_id
Can not process action 'destroy'. Cloud must be stopped first Cloud should be stopped before being destroyed
Action cloud failed. Action failed for other reasons.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/cloud';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'cloud_id=cloud_id';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
								
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X DELETE 'https://cloudtony.com/api/v1/cloud'
  -d {'cloud_id':'cloud_id'}

Response Example


									{
										"error": false,
										"exitstatus": "OK"
									}
								

Start and Stop Cloud

This action allows to instantly stop or start a previously stopped Cloud instance. In order to do so you have to send a POST request with the respective action name:

stop - stops the Cloud
start - starts the Cloud

Request

This action requires a cloud_id parameter to be supplied over the JSON request. You can retrieve all unique ids of your Clouds using the Get Active Clouds action.

Parameter Type Description Required
cloud_id integer Cloud's ID. Yes
action_name String Action to do (start, stop, shutdown). Yes

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of wrongly built JSON request or failure of the API service to execute the requested action, the API will output one of the following errors:

Error message Error Description
Unacceptable action (can be only : start, stop, shutdown). The action_name is different than start, stop, shutdown.
Cloud does not exist No Cloud found with the specified identifier.
Can not process action "action_name". Cloud must be stopped first. The Cloud must be stopped before executing the specified action.
Can not process action "action_name". Cloud must be started first. The Cloud must be started before executing the specified action.
Action cloud failed. Action failed for other reasons.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/cloud/status';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'cloud_id=cloud_id&action=action_name';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
								
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X POST 'https://cloudtony.com/api/v1/cloud/status'
  -d {'cloud_id':'cloud_id','action':'action_name'}'

Response Example


									{
										"error": false,
										"exitstatus": "OK"
									}
								

Update Cloud Hostname

This action allows you to instantly change the resources of a particular Cloud. To execute this action you have to send a PUT request with parameters: cloud_id and hostname

Request

The data object of the JSON request for this action must include a cloud_id and a hostname.

Parameter Type Description Required
cloud_id string Cloud's Id. Yes
hostname string Cloud's hostname to edit. Yes

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of API service failure or wrongly built JSON request the API will provide one of the following errors:

Error message Error Description
Invalid hostname format The format of hostname is not in the good format.
Cloud does not exist No Cloud found with the specified identifier.
Can not 'update' cloud. It must be stopped first. Cloud must be stopped before updating its hostname.
Cloud hostname update failed. Action failed for other reasons.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/cloud/hostname';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$fields = array (
'cloud_id' => 'cloud_id';
'hostname' => 'hostname';
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($fields));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
								
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://cloudtony.com/api/v1/cloud/hostname'
  -d {'hostname':'hostname','cloud_id':'cloud_id'}

Response Example


								{
									"error": false,
									"exitstatus": "OK"
								}
							

Get available OS images

This action will provide a list of all available Cloud images. An image is a pre-defined and configured setup a new Cloud can be provisioned with. To retrieve this list you have to send a GET request.

Request

Category of images is required in the request. It should be "os", "app" or "all".

Response

The response will be a JSON object with key images. It will contain a separate object for each image available and the key for each object will be a human-readable id of the image. Each image object will contain the following parameters describing the image details:

Parameter Type Description
id Integer Image id. This parameter should be used when creating new Cloud
name String Image name.
provider string The provider of the image.
version String Image version
category string Image category
type string Image type.

Please note that if an image gets updated the updates will not apply on already provisioned Clouds. For more information on how to provision a new Cloud with a specific image, please refer to Create a New Cloud.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/images/category';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
				
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://cloudtony.com/api/v1/images/category'

Response Example


								{
									"error": false,
									"images": 
									[
										{
											"id": 8,
											"name": "Centos",
											"provider": "Red Hat Enterprise Linux",
											"version": "6.6-x64",
											"category": "distribution",
											"type": "lxc"
									    },
									    {
											"id": 10,
											"name": "Centos",
											"provider": "Red Hat Enterprise Linux",
											"version": "7-x64",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 4,
											"name": "Ubuntu",
											"provider": "Ubuntu",
											"version": "15.04x64",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 20062,
											"name": "Ubuntu",
											"provider": "Ubuntu",
											"version": "14.04x86_64",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 6,
											"name": "Debian",
											"provider": "Software in the Public",
											"version": "8x64",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 7,
											"name": "Fedora",
											"provider": "Red Hat Enterprise Linux",
											"version": "21x64",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 10008,
											"name": "Suse",
											"provider": "SUSE Linux Enterprise",
											"version": "13.1x86",
											"category": "distribution",
											"type": "lxc"
										},
										{
											"id": 20067,
											"name": "Windows-Server",
											"provider": "Microsoft",
											"version": "2012-R2-Standard",
											"category": "distribution",
											"type": "vm"
										},
										{
											"id": 20068,
											"name": "Windows-Server",
											"provider": "Microsoft",
											"version": "2012-R2-Standard-Apps",
											"category": "distribution",
											"type": "vm"
										},
										{
											"id": 20071,
											"name": "Windows-Server",
											"provider": "Microsoft",
											"version": "2016-Standard",
											"category": "distribution",
											"type": "vm"
										},
										{
											"id": 20064,
											"name": "Ubuntu",
											"provider": "Ubuntu",
											"version": "16.04.1-LTS",
											"category": "distribution",
											"type": "lxc"
										}
									]
								}

Get offers

This action will provide a list of all offers available at CloudTony. To retrieve this list you have to send a GET request.

Request

This action does not require any additional parameters to be supplied over the request.

Response

The response will be a JSON object with key offers. It will contain a separate object for each offer available and the key for each object will be a human-readable id of the offer. Each offer object will contain the following parameters describing the offer details:

Parameter Type Description
id Integer The identifier of the Offer.
name String Offer name.
resources string This is a JSON object that contains memory(mem), cpu and disk.
hour_price String The price of a hour consumption
type string Offer type: It can be "vm" for Virtual machines or "lxc" for others images.

For more information on how to provision a new Cloud with a specific offer, please refer to Create a New Cloud.

Example

<?php
 
$curl_opt_url = 'https://cloudtony.com/api/v1/offers';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
				
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://cloudtony.com/api/v1/offers'

Response Example


							{
								"error": false,
								"offers": 
								[
									{
										"id": 18,
										"name": "optimal.ssd.s",
										"resources": {
											"mem": 1048,
											"cpu": 1,
											"disk": 20
										},
										"hour_price": 0.0067,
										"type": "lxc"
									},
									{
										"id": 19,
										"name": "optimal.ssd.m",
										"resources": {
											"mem": 1048,
											"cpu": 1,
											"disk": 30
										},
										"hour_price": 0.012,
										"type": "lxc"
									},
									{
										"id": 20,
										"name": "optimal.ssd.l.1",
										"resources": {
											"mem": 2096,
											"cpu": 2,
											"disk": 40
										},
										"hour_price": 0.02,
										"type": "lxc"
									},
									{
										"id": 22,
										"name": "optimal.ssd.xl.1",
										"resources": {
											"mem": 8384,
											"cpu": 4,
											"disk": 80
										},
										"hour_price": 0.1,
										"type": "lxc"
									},
									{
										"id": 23,
										"name": "optimal.ssd.xl.2",
										"resources": {
											"mem": 16768,
											"cpu": 8,
											"disk": 160
										},
										"hour_price": 0.212,
										"type": "lxc"
									},
									{
										"id": 24,
										"name": "optimal.ssd.xl.3",
										"resources": {
											"mem": 33536,
											"cpu": 12,
											"disk": 320
										},
										"hour_price": 0.4254,
										"type": "lxc"
									},
									{
										"id": 25,
										"name": "optimal.ssd.2xxl",
										"resources": {
											"mem": 67072,
											"cpu": 16,
											"disk": 480
										},
										"hour_price": 0.6387,
										"type": "lxc"
									},
									{
										"id": 26,
										"name": "optimal.ssd.3xxl",
										"resources": {
											"mem": 134144,
											"cpu": 20,
											"disk": 640
										},
										"hour_price": 0.852,
										"type": "lxc"
									},
									{
										"id": 28,
										"name": "optimal.ssd.s",
										"resources": {
											"mem": 1048,
											"cpu": 1,
											"disk": 20
										},
										"hour_price": 0.0067,
										"type": "vm"
									},
									{
										"id": 29,
										"name": "optimal.ssd.m",
										"resources": {
											"mem": 1048,
											"cpu": 1,
											"disk": 30
										},
										"hour_price": 0.012,
										"type": "vm"
									},
									{
										"id": 30,
										"name": "optimal.ssd.l.1",
										"resources": {
											"mem": 2096,
											"cpu": 2,
											"disk": 40
										},
										"hour_price": 0.02,
										"type": "vm"
									}
								]
							}

Create Snapshot

In order to save data instantly, you can create a Snapshot. To do this, you have to send a POST request.

Request

Name Type Description Required
cloud_id integer Unique id of the Cloud instance that was generated at creation. Yes
name string Name of Snapshot: It must contain at least 2 characters, only letters and digits and must start with a letter. Yes
description string a short description of the snapshot. No

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of API service failure or wrongly built JSON request the API will provide one of the following errors:

Error message Error Description
Invalid name format The format of name is not in the good format.
Cloud does not exist No Cloud found with the specified identifier.
Can not take snapshot. Cloud must be running or stopped. Cloud must be running or stopped before creating snapshot.
snapshot failed. Action failed for other reasons.
<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/cloud/snapshot';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'cloud_id=cloud_id&name=snapshot_name&description=snapshot_description';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
						
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X POST 'https://www.cloudtony.com/api/v1/cloud/snapshot'
  -d {'cloud_id':'cloud_id','name':'snapshot_name','description':'snapshot_description'}'

Response Example


						{
							"error": false,
							"exitstatus": "OK"
						}
					

List Snapshots

To execute this action you have to send a GET request.

This API action will list all Client Snapshots. The response will be a JSON array named snapshots. This array will contain objects representing each Snapshot instance.

Each element of this array contains a JSON array with snapshot attributes.

Response

Name Type Description
id integer Unique id of the Snapshot instance that was generated at creation.
cloud_id integer Unique id of the Cloud instance that was generated at creation.
name string Name of Snapshot.
description string description of the snapshot.
date date date creation of the snapshot.

Example

<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/snapshots';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
				
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://www.cloudtony.com/api/v1/snapshots'

Response Example


							{
								"error": false,
								"snapshots": 
								[
									{
										"id": 143,
										"cloud_id": 53350,
										"name": "test_snap",
										"description": "snap description",
										"date": "2017-02-13 09:17:36"
									}
								]
							}
				

Get cloud Snapshots

To execute this action you have to send a GET request.

This API action will list all cloud Snapshots. The cloud_id must be specified in the url. The response will be a JSON array named snapshots. This array will contain objects representing each Snapshot instance.

Each element of this array contains a JSON array with snapshot attributes.

Response

Name Type Description
id integer Unique id of the Snapshot instance that was generated at creation.
cloud_id integer Unique id of the Cloud instance that was generated at creation.
name string Name of Snapshot.
description string description of the snapshot.
date date date creation of the snapshot.

Example

<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/cloud/cloud_id/snapshots';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
				
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X GET 'https://www.cloudtony.com/api/v1/cloud/cloud_id/snapshots'

Response Example


							{
								"error": false,
								"snapshots": 
								[
									{
										"id": 142,
										"name": "test_snap",
										"description": "snap description",
										"date": "2017-02-09 15:05:35"
									},
									{
										"id": 138,
										"name": "sa",
										"description": "this value is not required",
										"date": "2017-02-08 17:06:14"
									},
									{
										"id": 137,
										"name": "sa1rrB",
										"description": "this value is not required",
										"date": "2017-02-08 16:56:54"
									}
								]
							}
		

Delete a snapshot

This action will physically delete a particular Snapshot. Please note that once deleted, the snapshot cannot be restored. To execute this task you have to send a DELETE request.

Request

This action requires a snapshot_id parameter to be supplied over the request. You can retrieve all unique ids of your snapshots using the List Snapshots action or Get cloud Snapshots action.

Parameter Type Description Required
snapshot_id integer Snapshot's ID to delete. Yes

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of wrongly built request or failure of the API service to execute the requested action, the API will provide one of the following erros.

Error message Description
Incorrect snapshot_id value. No Snapshot found with this snapshot_id
Delete snapshot failed. Action failed for other reasons.

Example

<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/snapshot';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'snapshot_id=snapshot_id';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
					
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X DELETE 'https://www.cloudtony.com/api/v1/snapshot'
  -d {'snapshot_id':'snapshot_id'}

Response Example


							{
								"error": false,
								"exitstatus": "OK"
							}
					

Rollback a snapshot

This action will physically rollback a particular Snapshot.

Request

This action requires a snapshot_id parameter to be supplied over the request. You can retrieve all unique ids of your snapshots using the List Snapshots action or Get cloud Snapshots action.

Parameter Type Description Required
snapshot_id integer Snapshot's ID to rollback. Yes

Response

Parameter Type Description
error Boolean Take value false means that request has successfully executed
exitstatus String OK | ERROR

Errors

In case of wrongly built request or failure of the API service to execute the requested action, the API will provide one of the following erros.

Error message Description
Incorrect snapshot_id value. No Snapshot found with this snapshot_id
Rollback snapshot failed. Action failed for other reasons.

Example

<?php
 
$curl_opt_url = 'https://www.cloudtony.com/api/v1/snapshot/rollback';
$headers[] = 'Authorization: API_KEY';
$headers[] = 'Accept: application/json';
$data = 'snapshot_id=snapshot_id';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $curl_opt_url.'?'.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($curl);
?>
					
curl -v \
  https://cloudtony.com/api/v1
  -H "Authorization: API_KEY" \
  -H "Content-Type: application/json" \
  -X POST 'https://www.cloudtony.com/api/v1/snapshot/rollback'
  -d {'snapshot_id':'snapshot_id'}

Response Example


							{
								"error": false,
								"exitstatus": "OK"
							}