Completed
Push — master ( d25167...dbe861 )
by Lukáš
09:30 queued 06:24
created

Execution::bulkEnable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Lookyman\Rundeck\Api\Endpoints\Job;
5
6
use GuzzleHttp\Promise\PromiseInterface;
7
use GuzzleHttp\Psr7\Request;
8
use Lookyman\Rundeck\Api\Client;
9
10
class Execution
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
	 * @param string $id
27
	 * @return PromiseInterface
28
	 */
29
	public function enable(string $id): PromiseInterface
30
	{
31
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
32
			new Request('POST', $this->client->getConfiguration()->getBaseUri() . sprintf('/job/%s/execution/enable', urlencode($id)))
33
		);
34
	}
35
36
	/**
37
	 * @param string $id
38
	 * @return PromiseInterface
39
	 */
40
	public function disable(string $id): PromiseInterface
41
	{
42
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
43
			new Request('POST', $this->client->getConfiguration()->getBaseUri() . sprintf('/job/%s/execution/disable', urlencode($id)))
44
		);
45
	}
46
47
	/**
48
	 * @param string[] $ids
49
	 * @return PromiseInterface
50
	 */
51
	public function bulkEnable(array $ids): PromiseInterface
52
	{
53
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
54
			new Request('POST', $this->client->getConfiguration()->getBaseUri() . '/jobs/execution/enable', [], $this->client->getConfiguration()->getFormat()->formatParams(['ids' => $ids]))
55
		);
56
	}
57
58
	/**
59
	 * @param string[] $ids
60
	 * @return PromiseInterface
61
	 */
62
	public function bulkDisable(array $ids): PromiseInterface
63
	{
64
		return $this->client->getConfiguration()->getGuzzle()->sendAsync(
65
			new Request('POST', $this->client->getConfiguration()->getBaseUri() . '/jobs/execution/disable', [], $this->client->getConfiguration()->getFormat()->formatParams(['ids' => $ids]))
66
		);
67
	}
68
}
69