Completed
Push — master ( 39b80f...b11f31 )
by Lukáš
25:18 queued 19:03
created

Acl   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 67
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A list() 0 6 1
A get() 0 6 1
A create() 0 6 1
A update() 0 6 1
A delete() 0 6 1
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