-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
185 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |