Tag   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 16
c 2
b 0
f 1
dl 0
loc 46
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 1
A delete() 0 2 1
A all() 0 2 1
A __construct() 0 3 1
A get() 0 2 1
A revokePropagatingPermissions() 0 2 1
A addToUsedBy() 0 6 1
A removeUsedToBy() 0 6 1
A allTagsForCategory() 0 2 1
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
}