1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Lookyman\Rundeck\Api\Endpoints\System; |
5
|
|
|
|
6
|
|
|
use GuzzleHttp\Promise\PromiseInterface; |
7
|
|
|
use Lookyman\Rundeck\Api\Client; |
8
|
|
|
use GuzzleHttp\Psr7\Request; |
9
|
|
|
|
10
|
|
|
class Acl |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Client |
14
|
|
|
*/ |
15
|
|
|
private $client; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param Client $client |
19
|
|
|
*/ |
20
|
|
|
public function __construct(Client $client) |
21
|
|
|
{ |
22
|
|
|
$this->client = $client; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return PromiseInterface |
27
|
|
|
*/ |
28
|
|
|
public function list(): PromiseInterface |
29
|
|
|
{ |
30
|
|
|
return $this->client->getConfiguration()->getGuzzle()->sendAsync( |
31
|
|
|
new Request('GET', $this->client->getConfiguration()->getBaseUri() . '/system/acl') |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return PromiseInterface |
37
|
|
|
*/ |
38
|
|
|
public function get(): PromiseInterface |
39
|
|
|
{ |
40
|
|
|
return $this->client->getConfiguration()->getGuzzle()->sendAsync( |
41
|
|
|
new Request('GET', $this->client->getConfiguration()->getBaseUri() . '/system/acl/name.aclpolicy') |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param array $params |
47
|
|
|
* @return PromiseInterface |
48
|
|
|
*/ |
49
|
|
|
public function create(array $params = []): PromiseInterface |
50
|
|
|
{ |
51
|
|
|
return $this->client->getConfiguration()->getGuzzle()->sendAsync( |
52
|
|
|
new Request('POST', $this->client->getConfiguration()->getBaseUri() . '/system/acl/name.aclpolicy', [], $this->client->getConfiguration()->getFormat()->formatParams($params)) |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param array $params |
58
|
|
|
* @return PromiseInterface |
59
|
|
|
*/ |
60
|
|
|
public function update(array $params = []): PromiseInterface |
61
|
|
|
{ |
62
|
|
|
return $this->client->getConfiguration()->getGuzzle()->sendAsync( |
63
|
|
|
new Request('PUT', $this->client->getConfiguration()->getBaseUri() . '/system/acl/name.aclpolicy', [], $this->client->getConfiguration()->getFormat()->formatParams($params)) |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return PromiseInterface |
69
|
|
|
*/ |
70
|
|
|
public function delete(): PromiseInterface |
71
|
|
|
{ |
72
|
|
|
return $this->client->getConfiguration()->getGuzzle()->sendAsync( |
73
|
|
|
new Request('DELETE', $this->client->getConfiguration()->getBaseUri() . '/system/acl/name.aclpolicy') |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|