forked from beluga-php/docker-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkList.php
More file actions
96 lines (84 loc) · 3.53 KB
/
Copy pathNetworkList.php
File metadata and controls
96 lines (84 loc) · 3.53 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
<?php
declare(strict_types=1);
namespace Docker\API\Endpoint;
class NetworkList extends \Docker\API\Runtime\Client\BaseEndpoint implements \Docker\API\Runtime\Client\Endpoint
{
use \Docker\API\Runtime\Client\EndpointTrait;
/**
* Returns a list of networks. For details on the format, see the
* [network inspect endpoint](#operation/NetworkInspect).
*
* Note that it uses a different, smaller representation of a network than
* inspecting a single network. For example, the list of containers attached
* to the network is not propagated in API versions 1.28 and up.
*
* @param array $queryParameters {
*
* @var string $filters JSON encoded value of the filters (a `map[string][]string`) to process
* on the networks list.
*
* Available filters:
*
* - `dangling=<boolean>` When set to `true` (or `1`), returns all
* networks that are not in use by a container. When set to `false`
* (or `0`), only networks that are in use by one or more
* containers are returned.
* - `driver=<driver-name>` Matches a network's driver.
* - `id=<network-id>` Matches all or part of a network ID.
* - `label=<key>` or `label=<key>=<value>` of a network label.
* - `name=<network-name>` Matches all or part of a network name.
* - `scope=["swarm"|"global"|"local"]` Filters networks by scope (`swarm`, `global`, or `local`).
* - `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks.
*
* }
*/
public function __construct(array $queryParameters = [])
{
$this->queryParameters = $queryParameters;
}
public function getMethod(): string
{
return 'GET';
}
public function getUri(): string
{
return '/networks';
}
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(['filters']);
$optionsResolver->setRequired([]);
$optionsResolver->setDefaults([]);
$optionsResolver->addAllowedTypes('filters', ['string']);
return $optionsResolver;
}
/**
* @throws \Docker\API\Exception\NetworkListInternalServerErrorException
*
* @return \Docker\API\Model\Network[]|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\\Network[]', 'json');
}
if ((null === $contentType) === false && (500 === $status && false !== mb_strpos($contentType, 'application/json'))) {
throw new \Docker\API\Exception\NetworkListInternalServerErrorException($serializer->deserialize($body, 'Docker\\API\\Model\\ErrorResponse', 'json'), $response);
}
}
public function getAuthenticationScopes(): array
{
return [];
}
}