Tag::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace FNDEV\vShpare\Api\Tagging\Tag;
4
5
use FNDEV\vShpare\ApiResponse;
6
use GuzzleHttp\Client;
7
8
class Tag
9
{
10
    public Client $HttpClient;
11
    public function __construct(Client $HttpClient)
12
    {
13
        $this->HttpClient=$HttpClient;
14
    }
15
    public function all(){
16
        return ApiResponse::BodyResponse($this->HttpClient->get("com/vmware/cis/tagging/tag"));
17
    }
18
    public function get($tag_id){
19
        return ApiResponse::BodyResponse($this->HttpClient->get("com/vmware/cis/tagging/tag/id:$tag_id"));
20
    }
21
    public function delete($tag_id){
22
        return ApiResponse::BodyResponse($this->HttpClient->delete("com/vmware/cis/tagging/tag/id:$tag_id"));
23
    }
24
    public function update($tag_id,array $config){
25
        return ApiResponse::BodyResponse($this->HttpClient->patch("com/vmware/cis/tagging/tag/id:$tag_id",[
26
            "json"=>$config
27
        ]));
28
    }
29
    public function allTagsForCategory($category_id){
30
        return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$category_id?~action=list-tags-for-category"));
31
    }
32
    public function addToUsedBy($tag_id,$entity){
33
        return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=add-to-used-by",
34
            [
35
                "json"=>
36
                    [
37
                        "used_by_entity"=>$entity
38
                    ]
39
            ]
40
        ));
41
    }
42
    public function removeUsedToBy($tag_id,$entity){
43
        return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=remove-from-used-by",
44
            [
45
                "json"=>
46
                    [
47
                        "used_by_entity"=>$entity
48
                    ]
49
            ]
50
        ));
51
    }
52
    public function revokePropagatingPermissions($tag_id){
53
        return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=revoke-propagating-permissions"));
54
    }
55
}