-
Notifications
You must be signed in to change notification settings - Fork 59
/
Session.php
73 lines (57 loc) · 1.89 KB
/
Session.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Consul\Services;
use Consul\Client;
use Consul\ClientInterface;
use Consul\ConsulResponse;
use Consul\OptionsResolver;
final class Session
{
private ClientInterface $client;
public function __construct(?ClientInterface $client = null)
{
$this->client = $client ?: new Client();
}
public function create(array $session = [], array $options = []): ConsulResponse
{
$params = [
'json' => $session,
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->put('/v1/session/create', $params);
}
public function destroy(string $sessionId, array $options = []): ConsulResponse
{
$params = [
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->put('/v1/session/destroy/'.$sessionId, $params);
}
public function info(string $sessionId, array $options = []): ConsulResponse
{
$params = [
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->get('/v1/session/info/'.$sessionId, $params);
}
public function node(string $node, array $options = []): ConsulResponse
{
$params = [
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->get('/v1/session/node/'.$node, $params);
}
public function all(array $options = []): ConsulResponse
{
$params = [
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->get('/v1/session/list', $params);
}
public function renew(string $sessionId, array $options = []): ConsulResponse
{
$params = [
'query' => OptionsResolver::resolve($options, ['dc']),
];
return $this->client->put('/v1/session/renew/'.$sessionId, $params);
}
}