|
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?~action=list-tags-for-category", |
|
31
|
|
|
[ |
|
32
|
|
|
"json"=> |
|
33
|
|
|
[ |
|
34
|
|
|
"category_id"=>$category_id |
|
35
|
|
|
] |
|
36
|
|
|
] |
|
37
|
|
|
)); |
|
38
|
|
|
} |
|
39
|
|
|
public function addToUsedBy($tag_id,$entity){ |
|
40
|
|
|
return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=add-to-used-by", |
|
41
|
|
|
[ |
|
42
|
|
|
"json"=> |
|
43
|
|
|
[ |
|
44
|
|
|
"used_by_entity"=>$entity |
|
45
|
|
|
] |
|
46
|
|
|
] |
|
47
|
|
|
)); |
|
48
|
|
|
} |
|
49
|
|
|
public function removeUsedToBy($tag_id,$entity){ |
|
50
|
|
|
return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=remove-from-used-by", |
|
51
|
|
|
[ |
|
52
|
|
|
"json"=> |
|
53
|
|
|
[ |
|
54
|
|
|
"used_by_entity"=>$entity |
|
55
|
|
|
] |
|
56
|
|
|
] |
|
57
|
|
|
)); |
|
58
|
|
|
} |
|
59
|
|
|
public function revokePropagatingPermissions($tag_id){ |
|
60
|
|
|
return ApiResponse::BodyResponse($this->HttpClient->post("com/vmware/cis/tagging/tag/id:$tag_id?~action=revoke-propagating-permissions")); |
|
61
|
|
|
} |
|
62
|
|
|
} |