Skip to content

Commit

Permalink
+ added virtual server api
Browse files Browse the repository at this point in the history
* some improvements on domain api
  • Loading branch information
JWaldecker committed Nov 8, 2017
1 parent 58889cc commit 1c674b0
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lumaserv/lumaserv-php-client",
"description": "A full-featured implementation of the LumaservSystem-JSON-API",
"type": "library",
"version": "1.6.5",
"version": "1.7",
"require": {
"php": ">=5.5",
"guzzlehttp/guzzle": ">=6.0"
Expand Down
2 changes: 1 addition & 1 deletion src/DomainHandleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function searchHandle($filter_handle = '', $filter_firstname = '', $filte
]);
}

public function create($type, $sex, $firstname, $lastname, $organisation, $street, $number, $postcode, $city, $region, $country, $phone, $fax, $email, $countryofbirth,
public function create($type, $sex, $firstname, $lastname, $organisation, $street, $number, $postcode, $city, $region, $country, $phone, $fax, $email, $countryofbirth = null,
$idcard = null, $idcardauthority = null, $idcardissuedate = null, $taxnr = null, $vatnr = null, $dateofbirth = null, $placeofbirth = null,
$regionofbirth = null, $registrationnumber = null)
{
Expand Down
15 changes: 15 additions & 0 deletions src/LUMASERV.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,19 @@ public function pxe_installations()

return $this->pxeInstallationHandler;
}


private $virtualServerHandler;

/**
* @return VirtualServerHandler
*/
public function virtual_servers()
{
if (!$this->virtualServerHandler) {
$this->virtualServerHandler = new VirtualServerHandler($this);
}

return $this->virtualServerHandler;
}
}
121 changes: 121 additions & 0 deletions src/VirtualServer/SingleVirtualServerHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* Created by PhpStorm.
* User: janwaldecker
* Date: 05.11.17
* Time: 19:49
*/

namespace LumaservSystems\VirtualServer;


use LumaservSystems\LUMASERV;

class SingleVirtualServerHandler
{
private $id;
private $lumaserv;

public function __construct($id, LUMASERV $lumaserv)
{
$this->id = $id;
$this->lumaserv = $lumaserv;
}

public function getDetails()
{
return $this->lumaserv->get('servers/virtual/'.$this->id);
}

public function getTasks()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/tasks');
}

public function getBackups()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/backups');
}

public function getAddresses()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/addresses');
}

public function getNetworks()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/networks');
}

public function start()
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/start');
}

public function shutdown()
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/shutdown');
}

public function stop()
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/stop');
}

public function restart()
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/restart');
}

public function createBackup($title, $mode = 'snapshot')
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/createBackup', [
'title' => $title,
'mode' => $mode
]);
}

public function reinstall($password, $template = 'DEBIAN_9', $support_ssh_key = false)
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/reinstall', [
'password' => $password,
'template' => $template,
'support_ssh_key' => $support_ssh_key,
]);
}

public function getScheduledTasks()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/scheduledTasks');
}

public function getNoVncConsole()
{
return $this->lumaserv->get('servers/virtual/'.$this->id.'/vnc');
}

public function restoreBackup($id)
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/backups/restore', [
'backup_id' => $id
]);
}

public function deleteBackup($id)
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/backups/delete', [
'backup_id' => $id
]);
}

public function reconfigure($cores, $memory, $disk, $addresses_v4, $backups)
{
return $this->lumaserv->post('servers/virtual/'.$this->id.'/reconfigure', [
'cores' => $cores,
'memory' => $memory,
'disk' => $disk,
'addresses_v4' => $addresses_v4,
'backups' => $backups
]);
}
}
47 changes: 47 additions & 0 deletions src/VirtualServerHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Created by PhpStorm.
* User: Jan Waldecker
* Date: 02.09.2016
* Time: 00:33.
*/
namespace LumaservSystems;

use LumaservSystems\VirtualServer\SingleVirtualServerHandler;

class VirtualServerHandler
{
private $lumaserv;

public function __construct(LUMASERV $lumaserv)
{
$this->lumaserv = $lumaserv;
}

/**
* @param null $start
* @param null $end
* @param null $interval
* @return array|string
*/
public function getAll()
{
return $this->lumaserv->get('servers/virtual');
}

public function orderServer($cores, $memory, $disk, $addresses_v4, $backups)
{
return $this->lumaserv->post('servers/virtual/order', [
'cores' => $cores,
'memory' => $memory,
'disk' => $disk,
'addresses_v4' => $addresses_v4,
'backups' => $backups
]);
}

public function single($id)
{
return new SingleVirtualServerHandler($id, $this->lumaserv);
}
}

0 comments on commit 1c674b0

Please sign in to comment.