API

From SolusVM

Jump to: navigation, search


Contents

This API has been discontinued, please see http://wiki.solusvm.com/index.php/API:Admin

Overview

To create an API user in SolusVM click Configuration >> API Users from the top menu then select Create API User.

You will be presented with some fields like the image below:

File:Image-api.png

The ID & Key are auto generated and cannot be changed, all you need to add is the IP Address of the connecting user and set it to active.

Functions

Create Virtual Server

Function .............. : To create a virtual server
Action ................ : createvps
Variables ............. : node, type, ips, username, rootpassword, hostname, template, plan
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>
                          <vserverid>VPSID</vserverid>
                          <mainipaddress>MAINIPADDRESS</mainipaddress>
                          <consoleuser>CONSOLEUSER</consoleuser>

Failure Returns ....... : <error>MESSAGE</error>

Example :api.phpid=123456&key=123456&action=createvps&node=localhost&type=openvz&username=testclient&rootpassword=123456&hostname=hostname.com&plan=small&template=centos-5.3&ips=2

Create Client

Function .............. : To create a virtual server
Action ................ : createclient
Variables ............. : firstname, lastname, email, username, password
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=createclient&firstname=phill&lastname=smith&email=email@email.com&username=testuser&password=123456

Reboot Virtual Server

Function .............. : To reboot a virtual server
Action ................ : reboot
Variables ............. : vpsid
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=reboot&vpsid=70


Suspend Virtual Server

Function .............. : To suspend a virtual server
Action ................ : suspend
Variables ............. : vpsid
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=suspend&vpsid=70


Unsuspend Virtual Server

Function .............. : To unsuspend a virtual server
Action ................ : unsuspend
Variables ............. : vpsid
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=unsuspend&vpsid=70


Destroy Virtual Server

Function .............. : To destroy a virtual server
Action ................ : destroy
Variables ............. : vpsid
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=destroy&vpsid=70


Change Virtual Server Plan

Function .............. : To change the plan of a virtual server
Action ................ : changeplan
Variables ............. : plan, vpsid
Method ................ : GET or POST

Success Returns ....... : <success>MESSAGE</success>

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=changeplan&plan=planname&vpsid=70


List Virtual Servers

Function .............. : To list virtual servers in SolusVM
Action ................ : listvps
Method ................ : GET or POST

Success Returns ....... : <virtualserver>
                              <id>ID</id> 
                              <client>CLIENT</client> 
                              <hostname>HOSTNAME</hostname> 
                              <ipaddress>IPADDRESS</ipaddress> 
                              <type>TYPE</type> 
                              <os>OPERATING SYSTEM</os> 
                           </virtualserver>
                          
Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=listvps


List Nodes

Function .............. : To return a csv string of nodes
Action ................ : listnodes
Variables ............. : type
Method ................ : GET or POST

Success Returns ....... : node1,node2,node3,node4

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=listnodes&type=openvz


List Plans

Function .............. : To return a csv string of plans
Action ................ : listplans
Variables ............. : type
Method ................ : GET or POST

Success Returns ....... : plan1,plan2,plan3,plan4

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=listplans&type=openvz


List Templates

Function .............. : To return a csv string of templates
Action ................ : listtemplates
Variables ............. : type
Method ................ : GET or POST

Success Returns ....... : template1,template2,template3,template4

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=listtemplate&type=openvz


List Resellers

Function .............. : To return a csv string of resellers
Action ................ : listresellers
Method ................ : GET or POST

Success Returns ....... : reseller1,reseller2,reseller3,reseller4

Failure Returns ....... : <error>MESSAGE</error>

Example : api.php?id=123456&key=123456&action=listresellers


Connection Examples

Curl method using POST

<?php 
 
$apiurl = "https://ip.address:5656/api.php"; 
 
$postfields["id"] = "123456"; 
$postfields["key"] = "123456"; 
$postfields["action"] = "reboot"; 
$postfields["vpsid"] = "70"; 
 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $apiurl); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_TIMEOUT, 100); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); 
$data = curl_exec($ch); 
curl_close($ch); 
 
// parse any returned data here 
 
?>

PHP file_get_contents method using GET

<?php
 
$url = "https://ip.address:5353/api.php?id=123456&key=123456&action=destroy&vpsid=70";
 
$output = file_get_contents($url);
 
echo $output;
 
?>
Personal tools
Installation/Upgrading
Customization