Power::reset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
4
namespace FNDEV\vShpare\Api\VM\Power;
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 Power 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\Power\Power.
Loading history...
16
    /**
17
     * Returns the power state information of a virtual machine
18
     */
19
    public function power($moid=null){
20
        return ApiResponse::BodyResponse($this->HttpClient->get("vcenter/vm/{$this->getMoid($moid)}/power"));
21
    }
22
    /**
23
     * Returns the power state information of a virtual machine
24
     */
25
    public function powerOff($moid=null){
26
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/stop"));
27
    }
28
    /**
29
     * Powers on a powered-off or suspended virtual machine
30
     */
31
    public function powerOn($moid=null){
32
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/start"));
33
    }
34
    /**
35
     * Resets a powered-on virtual machine
36
     */
37
    public function reset($moid=null){
38
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/reset"));
39
    }
40
    /**
41
     * Returns the power state information of a virtual machine
42
     */
43
    public function suspend($moid=null){
44
        return !ApiResponse::HasError($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/power/suspend"));
45
    }
46
}