forked from beluga-php/docker-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemEvents.php
More file actions
122 lines (110 loc) · 4.99 KB
/
Copy pathSystemEvents.php
File metadata and controls
122 lines (110 loc) · 4.99 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
declare(strict_types=1);
namespace Docker\API\Endpoint;
class SystemEvents extends \Docker\API\Runtime\Client\BaseEndpoint implements \Docker\API\Runtime\Client\Endpoint
{
use \Docker\API\Runtime\Client\EndpointTrait;
/**
* Stream real-time events from the server.
*
* Various objects within Docker report events when something happens to them.
*
* Containers report these events: `attach`, `commit`, `copy`, `create`, `destroy`, `detach`, `die`, `exec_create`, `exec_detach`, `exec_start`, `exec_die`, `export`, `health_status`, `kill`, `oom`, `pause`, `rename`, `resize`, `restart`, `start`, `stop`, `top`, `unpause`, `update`, and `prune`
*
* Images report these events: `delete`, `import`, `load`, `pull`, `push`, `save`, `tag`, `untag`, and `prune`
*
* Volumes report these events: `create`, `mount`, `unmount`, `destroy`, and `prune`
*
* Networks report these events: `create`, `connect`, `disconnect`, `destroy`, `update`, `remove`, and `prune`
*
* The Docker daemon reports these events: `reload`
*
* Services report these events: `create`, `update`, and `remove`
*
* Nodes report these events: `create`, `update`, and `remove`
*
* Secrets report these events: `create`, `update`, and `remove`
*
* Configs report these events: `create`, `update`, and `remove`
*
* The Builder reports `prune` events
*
* @param array $queryParameters {
*
* @var string $since show events created since this timestamp then stream new events
* @var string $until show events created until this timestamp then stop streaming
* @var string $filters A JSON encoded value of filters (a `map[string][]string`) to process on the event list. Available filters:
*
* - `config=<string>` config name or ID
* - `container=<string>` container name or ID
* - `daemon=<string>` daemon name or ID
* - `event=<string>` event type
* - `image=<string>` image name or ID
* - `label=<string>` image or container label
* - `network=<string>` network name or ID
* - `node=<string>` node ID
* - `plugin`=<string> plugin name or ID
* - `scope`=<string> local or swarm
* - `secret=<string>` secret name or ID
* - `service=<string>` service name or ID
* - `type=<string>` object to filter by, one of `container`, `image`, `volume`, `network`, `daemon`, `plugin`, `node`, `service`, `secret` or `config`
* - `volume=<string>` volume name
*
* }
*/
public function __construct(array $queryParameters = [])
{
$this->queryParameters = $queryParameters;
}
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return '/events';
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null): array
{
return [[], null];
}
public function getExtraHeaders(): array
{
return ['Accept' => ['application/json']];
}
protected function getQueryOptionsResolver(): \Symfony\Component\OptionsResolver\OptionsResolver
{
$optionsResolver = parent::getQueryOptionsResolver();
$optionsResolver->setDefined(['since', 'until', 'filters']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('since', ['string']);
$optionsResolver->addAllowedTypes('until', ['string']);
$optionsResolver->addAllowedTypes('filters', ['string']);
return $optionsResolver;
}
/**
* @throws \Docker\API\Exception\SystemEventsBadRequestException
* @throws \Docker\API\Exception\SystemEventsInternalServerErrorException
*
* @return \Docker\API\Model\EventMessage|null
*/
protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
$status = $response->getStatusCode();
$body = (string) $response->getBody();
if ((null === $contentType) === false && (200 === $status && false !== mb_strpos($contentType, 'application/json'))) {
return $serializer->deserialize($body, 'Docker\\API\\Model\\EventMessage', 'json');
}
if ((null === $contentType) === false && (400 === $status && false !== mb_strpos($contentType, 'application/json'))) {
throw new \Docker\API\Exception\SystemEventsBadRequestException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'), $response);
}
if ((null === $contentType) === false && (500 === $status && false !== mb_strpos($contentType, 'application/json'))) {
throw new \Docker\API\Exception\SystemEventsInternalServerErrorException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'), $response);
}
}
public function getAuthenticationScopes(): array
{
return [];
}
}