@@ -16,8 +16,8 @@ |
||
16 | 16 | * @param integer $port The port to use |
17 | 17 | */ |
18 | 18 | public function __construct($host, $username, $password, $port = 22) { |
19 | - $config = new Configuration($host,$port); |
|
19 | + $config = new Configuration($host, $port); |
|
20 | 20 | $auth = new Password($username, $password); |
21 | - $this->session = new Session($config,$auth); |
|
21 | + $this->session = new Session($config, $auth); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * Gets the SSH session executor |
17 | 17 | * @return \Ssh\Exec |
18 | 18 | */ |
19 | - public function getExec(){ |
|
19 | + public function getExec() { |
|
20 | 20 | return $this->session->getExec(); |
21 | 21 | } |
22 | 22 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * Throws an Exception because you cannot boot a powered down machine from ssh |
25 | 25 | * @return void |
26 | 26 | */ |
27 | - public function boot(){ |
|
27 | + public function boot() { |
|
28 | 28 | throw new MethodNotAllowedException("You cannot use SSH to boot a powered down server."); |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * Executes a Reboot command |
33 | 33 | * @return void |
34 | 34 | */ |
35 | - public function reboot(){ |
|
35 | + public function reboot() { |
|
36 | 36 | $exec = $this->getExec(); |
37 | 37 | $exec->run('reboot'); |
38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * Executes a Shutdown command |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function shutdown(){ |
|
44 | + public function shutdown() { |
|
45 | 45 | $exec = $this->getExec(); |
46 | 46 | $exec->run('shutdown -P now'); |
47 | 47 | } |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * @param string $host The api host |
19 | 19 | * @param Client $client The guzzle client to use |
20 | 20 | */ |
21 | - public function __construct($token, $server_id, $host = "api.linode.com", Client $client = null){ |
|
21 | + public function __construct($token, $server_id, $host = "api.linode.com", Client $client = null) { |
|
22 | 22 | |
23 | - if(!$client instanceof Client){ |
|
23 | + if (!$client instanceof Client) { |
|
24 | 24 | $client = new Client(); |
25 | 25 | } |
26 | 26 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Executes a Boot command |
35 | 35 | * @return \Psr\Http\Message\ResponseInterface |
36 | 36 | */ |
37 | - public function boot(){ |
|
37 | + public function boot() { |
|
38 | 38 | return $this->exec("linode.boot"); |
39 | 39 | } |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * Executes a Reboot command |
43 | 43 | * @return \Psr\Http\Message\ResponseInterface |
44 | 44 | */ |
45 | - public function reboot(){ |
|
45 | + public function reboot() { |
|
46 | 46 | return $this->exec("linode.reboot"); |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Executes a Shutdown command |
51 | 51 | * @return \Psr\Http\Message\ResponseInterface |
52 | 52 | */ |
53 | - public function shutdown(){ |
|
53 | + public function shutdown() { |
|
54 | 54 | return $this->exec("linode.shutdown"); |
55 | 55 | } |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $action The Linode API action |
60 | 60 | * @return string |
61 | 61 | */ |
62 | - protected function buildRequestUrl($action){ |
|
62 | + protected function buildRequestUrl($action) { |
|
63 | 63 | return "https://{$this->host}/?api_key={$this->token}&api_action={$action}&LinodeID={$this->server_id}"; |
64 | 64 | } |
65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $action |
69 | 69 | * @return \Psr\Http\Message\ResponseInterface |
70 | 70 | */ |
71 | - protected function exec($action){ |
|
71 | + protected function exec($action) { |
|
72 | 72 | $url = $this->buildRequestUrl($action); |
73 | 73 | return $this->client->request('GET', $url); |
74 | 74 | } |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * @param string $host The api host |
19 | 19 | * @param Client $client The guzzle client to use |
20 | 20 | */ |
21 | - public function __construct($token, $server_id, $host = "api.digitalocean.com", Client $client = null){ |
|
21 | + public function __construct($token, $server_id, $host = "api.digitalocean.com", Client $client = null) { |
|
22 | 22 | |
23 | - if(!$client instanceof Client){ |
|
23 | + if (!$client instanceof Client) { |
|
24 | 24 | $client = new Client(); |
25 | 25 | } |
26 | 26 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Executes a Boot command |
35 | 35 | * @return \Psr\Http\Message\ResponseInterface |
36 | 36 | */ |
37 | - public function boot(){ |
|
37 | + public function boot() { |
|
38 | 38 | return $this->exec("power_on"); |
39 | 39 | } |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * Executes a Reboot command |
43 | 43 | * @return \Psr\Http\Message\ResponseInterface |
44 | 44 | */ |
45 | - public function reboot(){ |
|
45 | + public function reboot() { |
|
46 | 46 | return $this->exec("reboot"); |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Executes a Shutdown command |
51 | 51 | * @return \Psr\Http\Message\ResponseInterface |
52 | 52 | */ |
53 | - public function shutdown(){ |
|
53 | + public function shutdown() { |
|
54 | 54 | return $this->exec("power_off"); |
55 | 55 | } |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $action The DigitalOcean API action |
60 | 60 | * @return string |
61 | 61 | */ |
62 | - protected function buildRequestUrl($action){ |
|
62 | + protected function buildRequestUrl($action) { |
|
63 | 63 | return "https://{$this->host}/v2/droplets/{$this->server_id}/actions"; |
64 | 64 | } |
65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $action The DigitalOcean API action |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - protected function buildRequestData($action){ |
|
71 | + protected function buildRequestData($action) { |
|
72 | 72 | return ["type"=>$action]; |
73 | 73 | } |
74 | 74 | |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param string $action |
78 | 78 | * @return \Psr\Http\Message\ResponseInterface |
79 | 79 | */ |
80 | - protected function exec($action){ |
|
80 | + protected function exec($action) { |
|
81 | 81 | $url = $this->buildRequestUrl($action); |
82 | 82 | $data = $this->buildRequestData($action); |
83 | 83 | return $this->client->request('POST', $url, [ |
84 | - 'auth' => [$this->token,""], |
|
84 | + 'auth' => [$this->token, ""], |
|
85 | 85 | 'form_params' => $data, |
86 | 86 | ]); |
87 | 87 | } |