| @@ 18-28 (lines=11) @@ | ||
| 15 | $this->client = $client; |
|
| 16 | } |
|
| 17 | ||
| 18 | public function getServers() { |
|
| 19 | try { |
|
| 20 | $this->client->setResource('servers') |
|
| 21 | ->setMethod('GET'); |
|
| 22 | $response = $this->client->call(); |
|
| 23 | } catch (\Exception $e) { |
|
| 24 | throw new GeneralException('GetServers call failed', 0, $e); |
|
| 25 | } |
|
| 26 | ||
| 27 | return json_decode($response); |
|
| 28 | } |
|
| 29 | ||
| 30 | public function getServer($serverId) { |
|
| 31 | try { |
|
| @@ 30-40 (lines=11) @@ | ||
| 27 | return json_decode($response); |
|
| 28 | } |
|
| 29 | ||
| 30 | public function getServer($serverId) { |
|
| 31 | try { |
|
| 32 | $this->client->setResource("servers/{$serverId}") |
|
| 33 | ->setMethod('GET'); |
|
| 34 | $response = $this->client->call(); |
|
| 35 | } catch (\Exception $e) { |
|
| 36 | throw new GeneralException('GetServer call failed', 0, $e); |
|
| 37 | } |
|
| 38 | ||
| 39 | return json_decode($response); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function createServer($name, $organizationId, $imageId, $commercialType) { |
|
| 43 | try { |
|
| @@ 62-72 (lines=11) @@ | ||
| 59 | return json_decode($response); |
|
| 60 | } |
|
| 61 | ||
| 62 | public function deleteServer($serverId) { |
|
| 63 | try { |
|
| 64 | $this->client->setResource("servers/{$serverId}") |
|
| 65 | ->setMethod('DELETE'); |
|
| 66 | $response = $this->client->call(); |
|
| 67 | } catch (\Exception $e) { |
|
| 68 | throw new GeneralException('DeleteServer call failed', 0, $e); |
|
| 69 | } |
|
| 70 | ||
| 71 | return json_decode($response); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function setAction($serverId, $action) { |
|
| 75 | try { |
|
| @@ 74-89 (lines=16) @@ | ||
| 71 | return json_decode($response); |
|
| 72 | } |
|
| 73 | ||
| 74 | public function setAction($serverId, $action) { |
|
| 75 | try { |
|
| 76 | $this->client->setResource("servers/{$serverId}/action") |
|
| 77 | ->setMethod('POST') |
|
| 78 | ->setParameters( |
|
| 79 | [ |
|
| 80 | 'action' => $action |
|
| 81 | ] |
|
| 82 | ); |
|
| 83 | $response = $this->client->call(); |
|
| 84 | } catch (\Exception $e) { |
|
| 85 | throw new GeneralException('SetAction call failed', 0, $e); |
|
| 86 | } |
|
| 87 | ||
| 88 | return json_decode($response); |
|
| 89 | } |
|
| 90 | ||
| 91 | public function getUserData($serverId, $key) { |
|
| 92 | try { |
|
| @@ 91-101 (lines=11) @@ | ||
| 88 | return json_decode($response); |
|
| 89 | } |
|
| 90 | ||
| 91 | public function getUserData($serverId, $key) { |
|
| 92 | try { |
|
| 93 | $this->client->setResource("servers/{$serverId}/user_data/{$key}") |
|
| 94 | ->setMethod('GET'); |
|
| 95 | $response = $this->client->call(); |
|
| 96 | } catch (\Exception $e) { |
|
| 97 | throw new GeneralException('GetUserData call failed', 0, $e); |
|
| 98 | } |
|
| 99 | ||
| 100 | return $response; |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||