@@ -9,9 +9,9 @@ |
||
9 | 9 | |
10 | 10 | class GuzzleClient extends Client |
11 | 11 | { |
12 | - public function __construct(VmwareApiClient $client,array $config = []) |
|
12 | + public function __construct(VmwareApiClient $client, array $config=[]) |
|
13 | 13 | { |
14 | - $guzzleConfig = array_merge([ |
|
14 | + $guzzleConfig=array_merge([ |
|
15 | 15 | 'base_uri' => $client->getBaseUrl(), |
16 | 16 | "verify"=>$client->ssl, |
17 | 17 | 'headers' => [ |
@@ -10,10 +10,10 @@ |
||
10 | 10 | class ApiResponse |
11 | 11 | { |
12 | 12 | const OK=200; |
13 | - public static function BodyResponse(ResponseInterface $response){ |
|
13 | + public static function BodyResponse(ResponseInterface $response) { |
|
14 | 14 | return json_decode($response->getBody()); |
15 | 15 | } |
16 | - public static function HasError(ResponseInterface $response){ |
|
17 | - return !($response->getStatusCode()>=200 and $response->getStatusCode() <300); |
|
16 | + public static function HasError(ResponseInterface $response) { |
|
17 | + return !($response->getStatusCode()>=200 and $response->getStatusCode()<300); |
|
18 | 18 | } |
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -12,8 +12,8 @@ |
||
12 | 12 | class ConsoleTickets extends InitClass |
13 | 13 | { |
14 | 14 | use MOID; |
15 | - public function createConsoleTickets(array $body,$moid=null){ |
|
16 | - return ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/console/tickets",[ |
|
15 | + public function createConsoleTickets(array $body, $moid=null) { |
|
16 | + return ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/console/tickets", [ |
|
17 | 17 | RequestOptions::JSON=>$body |
18 | 18 | ])); |
19 | 19 | } |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Get the properties of VMware Tools. |
20 | 20 | */ |
21 | - public function tools($moid=null){ |
|
21 | + public function tools($moid=null) { |
|
22 | 22 | return ApiResponse::BodyResponse($this->HttpClient->get("vm/{$this->getMoid($moid)}/tools")); |
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Update the properties of VMware Tools. |
27 | 27 | */ |
28 | - public function updateTools(array $body,$moid=null){ |
|
29 | - return !ApiResponse::HasError($this->HttpClient->patch("vm/{$this->getMoid($moid)}/tools",[ |
|
28 | + public function updateTools(array $body, $moid=null) { |
|
29 | + return !ApiResponse::HasError($this->HttpClient->patch("vm/{$this->getMoid($moid)}/tools", [ |
|
30 | 30 | RequestOptions::JSON=>$body |
31 | 31 | ])); |
32 | 32 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * Begins the Tools upgrade process. To monitor the status of the Tools upgrade, clients should check the Tools status by calling Tools.get and examining Tools.Info.version-status and Tools.Info.run-state. |
36 | 36 | */ |
37 | - public function upgradeTools($body, $moid=null){ |
|
38 | - return !ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/tools",[ |
|
37 | + public function upgradeTools($body, $moid=null) { |
|
38 | + return !ApiResponse::BodyResponse($this->HttpClient->post("vm/{$this->getMoid($moid)}/tools", [ |
|
39 | 39 | "query"=>[ |
40 | 40 | "action"=>"upgrade" |
41 | 41 | ], |
@@ -5,22 +5,22 @@ |
||
5 | 5 | use FNDEV\vShpare\Api\VM\Traits\IterableObject; |
6 | 6 | use GuzzleHttp\Psr7\Response; |
7 | 7 | |
8 | - class ManageVms implements \Iterator,\Countable { |
|
9 | - use IterableObject,CountAbleObject; |
|
8 | + class ManageVms implements \Iterator, \Countable { |
|
9 | + use IterableObject, CountAbleObject; |
|
10 | 10 | |
11 | - private array $items = []; |
|
12 | - private int $position = 0; |
|
13 | - public function __construct($vms,$HttpClient) |
|
11 | + private array $items=[]; |
|
12 | + private int $position=0; |
|
13 | + public function __construct($vms, $HttpClient) |
|
14 | 14 | { |
15 | - $this->parseObjects($vms,$HttpClient); |
|
15 | + $this->parseObjects($vms, $HttpClient); |
|
16 | 16 | } |
17 | - public function parseObjects($vms,$HttpClient){ |
|
18 | - foreach ($vms->value as $VmProperties){ |
|
19 | - array_push($this->items,new VmSource($HttpClient,$VmProperties,$VmProperties->vm)); |
|
17 | + public function parseObjects($vms, $HttpClient) { |
|
18 | + foreach ($vms->value as $VmProperties) { |
|
19 | + array_push($this->items, new VmSource($HttpClient, $VmProperties, $VmProperties->vm)); |
|
20 | 20 | } |
21 | 21 | } |
22 | - public function first(){ |
|
23 | - return (count($this->items) >= 1) ? $this->items[0] : null ; |
|
22 | + public function first() { |
|
23 | + return (count($this->items)>=1) ? $this->items[0] : null; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 |
@@ -20,11 +20,11 @@ |
||
20 | 20 | } |
21 | 21 | public function valid() |
22 | 22 | { |
23 | - return array_key_exists($this->position,$this->items); |
|
23 | + return array_key_exists($this->position, $this->items); |
|
24 | 24 | } |
25 | 25 | public function rewind() |
26 | 26 | { |
27 | - $this->position = 0; |
|
27 | + $this->position=0; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | trait MOID |
8 | 8 | { |
9 | - public function getMoid($moid=null){ |
|
10 | - if($moid) |
|
9 | + public function getMoid($moid=null) { |
|
10 | + if ($moid) |
|
11 | 11 | return $moid; |
12 | - if($this->vmSource && isset($this->vmSource->moid)) |
|
12 | + if ($this->vmSource && isset($this->vmSource->moid)) |
|
13 | 13 | return $this->vmSource->moid; |
14 | 14 | throw new \InvalidArgumentException("provide moid or pass vmSource object"); |
15 | 15 | } |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * Returns information about the guest operating system power state. |
18 | 18 | */ |
19 | - public function power($moid=null){ |
|
19 | + public function power($moid=null) { |
|
20 | 20 | return ApiResponse::BodyResponse($this->HttpClient->get("vm/{$this->getMoid($moid)}/guest/power")); |
21 | 21 | } |
22 | 22 | /** |
23 | 23 | * Issues a request to the guest operating system asking it to perform a clean shutdown of all services. This request returns immediately and does not wait for the guest operating system to complete the operation. |
24 | 24 | */ |
25 | - public function shutdown($moid=null){ |
|
26 | - return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[ |
|
25 | + public function shutdown($moid=null) { |
|
26 | + return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [ |
|
27 | 27 | "query"=>[ |
28 | 28 | "action"=>"shutdown" |
29 | 29 | ] |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Issues a request to the guest operating system asking it to perform a reboot. This request returns immediately and does not wait for the guest operating system to complete the operation |
34 | 34 | */ |
35 | - public function reboot($moid=null){ |
|
36 | - return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[ |
|
35 | + public function reboot($moid=null) { |
|
36 | + return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [ |
|
37 | 37 | "query"=>[ |
38 | 38 | "action"=>"reboot" |
39 | 39 | ] |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Issues a request to the guest operating system asking it to perform a suspend operation. |
44 | 44 | */ |
45 | - public function standby($moid=null){ |
|
46 | - return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power",[ |
|
45 | + public function standby($moid=null) { |
|
46 | + return !ApiResponse::HasError($this->HttpClient->post("vm/{$this->getMoid($moid)}/guest/power", [ |
|
47 | 47 | "query"=>[ |
48 | 48 | "action"=>"standby" |
49 | 49 | ] |
@@ -16,31 +16,31 @@ |
||
16 | 16 | { |
17 | 17 | $this->HttpClient=$client; |
18 | 18 | } |
19 | - public function power(){ |
|
19 | + public function power() { |
|
20 | 20 | return new Power($this->HttpClient); |
21 | 21 | } |
22 | - public function guestPower(){ |
|
22 | + public function guestPower() { |
|
23 | 23 | return new GuestPower($this->HttpClient); |
24 | 24 | } |
25 | - public function tools(){ |
|
25 | + public function tools() { |
|
26 | 26 | return new Tools($this->HttpClient); |
27 | 27 | } |
28 | - public function consoleTicket(){ |
|
28 | + public function consoleTicket() { |
|
29 | 29 | return new ConsoleTickets($this->HttpClient); |
30 | 30 | } |
31 | - public function hardWare(){ |
|
31 | + public function hardWare() { |
|
32 | 32 | return new Hardware($this->HttpClient); |
33 | 33 | } |
34 | - public function all(array $query=null){ |
|
35 | - $response=$this->HttpClient->get("vm",[ |
|
34 | + public function all(array $query=null) { |
|
35 | + $response=$this->HttpClient->get("vm", [ |
|
36 | 36 | "query"=>$query |
37 | 37 | ]); |
38 | - return new ManageVms(json_decode($response->getBody()),$this->HttpClient); |
|
38 | + return new ManageVms(json_decode($response->getBody()), $this->HttpClient); |
|
39 | 39 | } |
40 | - public function byMoId($moid, array $query=[]){ |
|
41 | - $response=$this->HttpClient->get("vm/$moid",[ |
|
40 | + public function byMoId($moid, array $query=[]) { |
|
41 | + $response=$this->HttpClient->get("vm/$moid", [ |
|
42 | 42 | "query"=>$query |
43 | 43 | ]); |
44 | - return new VmSource($this->HttpClient,json_decode($response->getBody()),$moid); |
|
44 | + return new VmSource($this->HttpClient, json_decode($response->getBody()), $moid); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file |