Tools::upgradeTools()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
4
namespace FNDEV\vShpare\Api\VM\Tools;
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
use GuzzleHttp\RequestOptions;
13
14
class Tools extends InitClass
15
{
16
    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\Tools\Tools.
Loading history...
17
18
    /**
19
     * Get the properties of VMware Tools.
20
     */
21
    public function tools($moid=null){
22
        return ApiResponse::BodyResponse($this->HttpClient->get("vcenter/vm/{$this->getMoid($moid)}/tools"));
23
    }
24
25
    /**
26
     * Update the properties of VMware Tools.
27
     */
28
    public function updateTools(array $body,$moid=null){
29
        return !ApiResponse::HasError($this->HttpClient->patch("vcenter/vm/{$this->getMoid($moid)}/tools",[
30
            RequestOptions::JSON=>$body
31
        ]));
32
    }
33
34
    /**
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
     */
37
    public function upgradeTools($body, $moid=null){
38
        return !ApiResponse::BodyResponse($this->HttpClient->post("vcenter/vm/{$this->getMoid($moid)}/tools",[
39
            "query"=>[
40
              "action"=>"upgrade"
41
            ],
42
            RequestOptions::JSON=>$body
43
        ]));
44
    }
45
}