GuestPower   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A standby() 0 4 1
A reboot() 0 4 1
A power() 0 2 1
A shutdown() 0 4 1
1
<?php
2
3
4
namespace FNDEV\vShpare\Api\VM\GuestPower;
5
6
7
use FNDEV\vShpare\Api\VM\Abstracts\InitClass;
8
use FNDEV\vShpare\Api\VM\Traits\MOID;
9
use FNDEV\vShpare\Api\VM\VmSource;
10
use FNDEV\vShpare\ApiResponse;
11
use GuzzleHttp\Client;
12
13
class GuestPower extends InitClass
14
{
15
    use MOID;
0 ignored issues
show
Bug introduced by
The trait FNDEV\vShpare\Api\VM\Traits\MOID requires the property $moid which is not provided by FNDEV\vShpare\Api\VM\GuestPower\GuestPower.
Loading history...
16
    /**
17
     * Returns information about the guest operating system power state.
18
     */
19
    public function power($moid=null){
20
        return ApiResponse::BodyResponse($this->HttpClient->get("vcenter/vm/{$this->getMoid($moid)}/guest/power"));
21
    }
22
    /**
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
     */
25
    public function shutdown($moid=null){
26
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/guest/power",[
27
            "query"=>[
28
                "action"=>"shutdown"
29
            ]
30
        ]));
31
    }
32
    /**
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
     */
35
    public function reboot($moid=null){
36
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/guest/power",[
37
            "query"=>[
38
                "action"=>"reboot"
39
            ]
40
        ]));
41
    }
42
    /**
43
     * Issues a request to the guest operating system asking it to perform a suspend operation.
44
     */
45
    public function standby($moid=null){
46
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/guest/power",[
47
            "query"=>[
48
                "action"=>"standby"
49
            ]
50
        ]));
51
    }
52
53
}