1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Lookyman\Rundeck\Api; |
5
|
|
|
|
6
|
|
|
use GuzzleHttp\HandlerStack; |
7
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Execution\Execution; |
8
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Job\Job; |
9
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Project\Project; |
10
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Scheduler\Scheduler; |
11
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Storage\Storage; |
12
|
|
|
use Lookyman\Rundeck\Api\Endpoints\System\System; |
13
|
|
|
use Lookyman\Rundeck\Api\Endpoints\Token\Token; |
14
|
|
|
|
15
|
|
|
class Client |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var Configuration |
19
|
|
|
*/ |
20
|
|
|
private $configuration; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param Configuration $configuration |
24
|
|
|
*/ |
25
|
|
|
public function __construct(Configuration $configuration) |
26
|
|
|
{ |
27
|
|
|
$this->configuration = $configuration; |
28
|
|
|
|
29
|
|
|
/** @var HandlerStack $stack */ |
30
|
|
|
$stack = $this->configuration->getGuzzle()->getConfig('handler'); |
31
|
|
|
$stack->push([$this->configuration->getAuthentication(), 'authenticate'], 'authentication'); |
32
|
|
|
$stack->push([$this->configuration->getFormat(), 'setFormat'], 'format'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return Configuration |
37
|
|
|
*/ |
38
|
|
|
public function getConfiguration(): Configuration |
39
|
|
|
{ |
40
|
|
|
return $this->configuration; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return Token |
45
|
|
|
*/ |
46
|
|
|
public function token(): Token |
47
|
|
|
{ |
48
|
|
|
return new Token($this); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return System |
53
|
|
|
*/ |
54
|
|
|
public function system(): System |
55
|
|
|
{ |
56
|
|
|
return new System($this); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return Scheduler |
61
|
|
|
*/ |
62
|
|
|
public function scheduler(): Scheduler |
63
|
|
|
{ |
64
|
|
|
return new Scheduler($this); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Project |
69
|
|
|
*/ |
70
|
|
|
public function project(): Project |
71
|
|
|
{ |
72
|
|
|
return new Project($this); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return Job |
77
|
|
|
*/ |
78
|
|
|
public function job(): Job |
79
|
|
|
{ |
80
|
|
|
return new Job($this); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return Execution |
85
|
|
|
*/ |
86
|
|
|
public function execution(): Execution |
87
|
|
|
{ |
88
|
|
|
return new Execution($this); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return Storage |
93
|
|
|
*/ |
94
|
|
|
public function storage(): Storage |
95
|
|
|
{ |
96
|
|
|
return new Storage($this); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|