forked from beluga-php/docker-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerList.php
More file actions
113 lines (101 loc) · 4.7 KB
/
Copy pathContainerList.php
File metadata and controls
113 lines (101 loc) · 4.7 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
<?php
declare(strict_types=1);
namespace Docker\API\Endpoint;
class ContainerList extends \Docker\API\Runtime\Client\BaseEndpoint implements \Docker\API\Runtime\Client\Endpoint
{
use \Docker\API\Runtime\Client\EndpointTrait;
/**
* Returns a list of containers. For details on the format, see the
* [inspect endpoint](#operation/ContainerInspect).
*
* Note that it uses a different, smaller representation of a container
* than inspecting a single container. For example, the list of linked
* containers is not propagated .
*
* @param array $queryParameters {
*
* @var bool $all Return all containers. By default, only running containers are shown.
* @var int $limit return this number of most recently created containers, including
* non-running ones
* @var bool $size return the size of container as fields `SizeRw` and `SizeRootFs`
* @var string $filters Filters to process on the container list, encoded as JSON (a
* `map[string][]string`). For example, `{"status": ["paused"]}` will
* only return paused containers.
*
* Available filters:
*
* - `ancestor`=(`<image-name>[:<tag>]`, `<image id>`, or `<image@digest>`)
* - `before`=(`<container id>` or `<container name>`)
* - `expose`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
* - `exited=<int>` containers with exit code of `<int>`
* - `health`=(`starting`|`healthy`|`unhealthy`|`none`)
* - `id=<ID>` a container's ID
* - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only)
* - `is-task=`(`true`|`false`)
* - `label=key` or `label="key=value"` of a container label
* - `name=<name>` a container's name
* - `network`=(`<network id>` or `<network name>`)
* - `publish`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`)
* - `since`=(`<container id>` or `<container name>`)
* - `status=`(`created`|`restarting`|`running`|`removing`|`paused`|`exited`|`dead`)
* - `volume`=(`<volume name>` or `<mount point destination>`)
*
* }
*/
public function __construct(array $queryParameters = [])
{
$this->queryParameters = $queryParameters;
}
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return '/containers/json';
}
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(['all', 'limit', 'size', 'filters']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults(['all' => false, 'size' => false]);
$optionsResolver->addAllowedTypes('all', ['bool']);
$optionsResolver->addAllowedTypes('limit', ['int']);
$optionsResolver->addAllowedTypes('size', ['bool']);
$optionsResolver->addAllowedTypes('filters', ['string']);
return $optionsResolver;
}
/**
* @throws \Docker\API\Exception\ContainerListBadRequestException
* @throws \Docker\API\Exception\ContainerListInternalServerErrorException
*
* @return \Docker\API\Model\ContainerSummary[]|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\\ContainerSummary[]', 'json');
}
if ((null === $contentType) === false && (400 === $status && false !== mb_strpos($contentType, 'application/json'))) {
throw new \Docker\API\Exception\ContainerListBadRequestException($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\ContainerListInternalServerErrorException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'), $response);
}
}
public function getAuthenticationScopes(): array
{
return [];
}
}