|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Docker\API\Resource; |
|
4
|
|
|
|
|
5
|
|
|
use Joli\Jane\Swagger\Client\QueryParam; |
|
6
|
|
|
use Joli\Jane\Swagger\Client\Resource; |
|
7
|
|
|
|
|
8
|
|
|
class ContainerResource extends Resource |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* List containers. |
|
12
|
|
|
* |
|
13
|
|
|
* @param array $parameters List of parameters |
|
14
|
|
|
* |
|
15
|
|
|
* (bool)all: Show all containers. Only running containers are shown by default (i.e., this defaults to false) |
|
16
|
|
|
* (int)limit: Show <limit> last created containers, include non-running ones. |
|
17
|
|
|
* (string)since: Show only containers created since Id, include non-running ones. |
|
18
|
|
|
* (string)before: Show only containers created before Id, include non-running ones. |
|
19
|
|
|
* (bool)size: 1/True/true or 0/False/false, Show the containers sizes. |
|
20
|
|
|
* (array)filters: A JSON encoded value of the filters (a map[string][]string) to process on the containers list |
|
21
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
22
|
|
|
* |
|
23
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerConfig[] |
|
24
|
|
|
*/ |
|
25
|
|
|
public function findAll($parameters = [], $fetch = self::FETCH_OBJECT) |
|
26
|
|
|
{ |
|
27
|
|
|
$queryParam = new QueryParam(); |
|
28
|
|
|
$queryParam->setDefault('all', false); |
|
29
|
|
|
$queryParam->setDefault('limit', null); |
|
30
|
|
|
$queryParam->setDefault('since', null); |
|
31
|
|
|
$queryParam->setDefault('before', null); |
|
32
|
|
|
$queryParam->setDefault('size', null); |
|
33
|
|
|
$queryParam->setDefault('filters', null); |
|
34
|
|
|
$url = '/containers/json'; |
|
35
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
36
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
37
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
38
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
39
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
40
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
41
|
|
|
if ('200' == $response->getStatusCode()) { |
|
42
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerConfig[]', 'json'); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return $response; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Create a container. |
|
51
|
|
|
* |
|
52
|
|
|
* @param \Docker\API\Model\ContainerConfig $container Container to create |
|
53
|
|
|
* @param array $parameters List of parameters |
|
54
|
|
|
* |
|
55
|
|
|
* (string)name: Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+. |
|
56
|
|
|
* (string)Content-Type: Content Type of input |
|
57
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
58
|
|
|
* |
|
59
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerCreateResult |
|
60
|
|
|
*/ |
|
61
|
|
|
public function create(\Docker\API\Model\ContainerConfig $container, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
62
|
|
|
{ |
|
63
|
|
|
$queryParam = new QueryParam(); |
|
64
|
|
|
$queryParam->setDefault('name', null); |
|
65
|
|
|
$queryParam->setDefault('Content-Type', 'application/json'); |
|
66
|
|
|
$queryParam->setHeaderParameters(['Content-Type']); |
|
67
|
|
|
$url = '/containers/create'; |
|
68
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
69
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
70
|
|
|
$body = $this->serializer->serialize($container, 'json'); |
|
71
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
72
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
73
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
74
|
|
|
if ('201' == $response->getStatusCode()) { |
|
75
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerCreateResult', 'json'); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $response; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Return low-level information on the container id. |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $id The container id or name |
|
86
|
|
|
* @param array $parameters List of parameters |
|
87
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
88
|
|
|
* |
|
89
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\Container |
|
90
|
|
|
*/ |
|
91
|
|
|
public function find($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
92
|
|
|
{ |
|
93
|
|
|
$queryParam = new QueryParam(); |
|
94
|
|
|
$url = '/containers/{id}/json'; |
|
95
|
|
|
$url = str_replace('{id}', $id, $url); |
|
96
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
97
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
98
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
99
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
100
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
101
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
102
|
|
|
if ('200' == $response->getStatusCode()) { |
|
103
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\Container', 'json'); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
return $response; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* List processes running inside the container id. |
|
112
|
|
|
* |
|
113
|
|
|
* @param string $id The container id or name |
|
114
|
|
|
* @param array $parameters List of parameters |
|
115
|
|
|
* |
|
116
|
|
|
* (string)ps_args: ps arguments to use (e.g., aux) |
|
117
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
118
|
|
|
* |
|
119
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerTop |
|
120
|
|
|
*/ |
|
121
|
|
|
public function listProcesses($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
122
|
|
|
{ |
|
123
|
|
|
$queryParam = new QueryParam(); |
|
124
|
|
|
$queryParam->setDefault('ps_args', null); |
|
125
|
|
|
$url = '/containers/{id}/top'; |
|
126
|
|
|
$url = str_replace('{id}', $id, $url); |
|
127
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
128
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
129
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
130
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
131
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
132
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
133
|
|
|
if ('200' == $response->getStatusCode()) { |
|
134
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerTop', 'json'); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
return $response; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Get stdout and stderr logs from the container id. Note: This endpoint works only for containers with json-file logging driver. |
|
143
|
|
|
* |
|
144
|
|
|
* @param string $id The container id or name |
|
145
|
|
|
* @param array $parameters List of parameters |
|
146
|
|
|
* |
|
147
|
|
|
* (bool)follow: 1/True/true or 0/False/false, return stream. Default false. |
|
148
|
|
|
* (bool)stdout: 1/True/true or 0/False/false, show stdout log. Default false. |
|
149
|
|
|
* (bool)stderr: 1/True/true or 0/False/false, show stderr log. Default false. |
|
150
|
|
|
* (int)since: UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered) |
|
151
|
|
|
* (bool)timestamps: 1/True/true or 0/False/false, print timestamps for every log line. |
|
152
|
|
|
* (string)tail: Output specified number of lines at the end of logs: all or <number>. Default all. |
|
153
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
154
|
|
|
* |
|
155
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
156
|
|
|
*/ |
|
157
|
|
View Code Duplication |
public function logs($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
158
|
|
|
{ |
|
159
|
|
|
$queryParam = new QueryParam(); |
|
160
|
|
|
$queryParam->setDefault('follow', false); |
|
161
|
|
|
$queryParam->setDefault('stdout', false); |
|
162
|
|
|
$queryParam->setDefault('stderr', false); |
|
163
|
|
|
$queryParam->setDefault('since', 0); |
|
164
|
|
|
$queryParam->setDefault('timestamps', false); |
|
165
|
|
|
$queryParam->setDefault('tail', null); |
|
166
|
|
|
$url = '/containers/{id}/logs'; |
|
167
|
|
|
$url = str_replace('{id}', $id, $url); |
|
168
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
169
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
170
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
171
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
172
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
173
|
|
|
|
|
174
|
|
|
return $response; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Inspect changes on a container’s filesystem. |
|
179
|
|
|
* |
|
180
|
|
|
* @param string $id The container id or name |
|
181
|
|
|
* @param array $parameters List of parameters |
|
182
|
|
|
* |
|
183
|
|
|
* (int)kind: Kind of changes |
|
184
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
185
|
|
|
* |
|
186
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerChange[] |
|
187
|
|
|
*/ |
|
188
|
|
|
public function changes($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
189
|
|
|
{ |
|
190
|
|
|
$queryParam = new QueryParam(); |
|
191
|
|
|
$queryParam->setDefault('kind', null); |
|
192
|
|
|
$url = '/containers/{id}/changes'; |
|
193
|
|
|
$url = str_replace('{id}', $id, $url); |
|
194
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
195
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
196
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
197
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
198
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
199
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
200
|
|
|
if ('200' == $response->getStatusCode()) { |
|
201
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerChange[]', 'json'); |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
return $response; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Export the contents of container id. |
|
210
|
|
|
* |
|
211
|
|
|
* @param string $id The container id or name |
|
212
|
|
|
* @param array $parameters List of parameters |
|
213
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
214
|
|
|
* |
|
215
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
216
|
|
|
*/ |
|
217
|
|
|
public function export($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
218
|
|
|
{ |
|
219
|
|
|
$queryParam = new QueryParam(); |
|
220
|
|
|
$url = '/containers/{id}/export'; |
|
221
|
|
|
$url = str_replace('{id}', $id, $url); |
|
222
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
223
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
224
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
225
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
226
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
227
|
|
|
|
|
228
|
|
|
return $response; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* This endpoint returns a live stream of a container’s resource usage statistics. |
|
233
|
|
|
* |
|
234
|
|
|
* @param string $id The container id or name |
|
235
|
|
|
* @param array $parameters List of parameters |
|
236
|
|
|
* |
|
237
|
|
|
* (bool)stream: Stream stats |
|
238
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
239
|
|
|
* |
|
240
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
241
|
|
|
*/ |
|
242
|
|
|
public function stats($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
243
|
|
|
{ |
|
244
|
|
|
$queryParam = new QueryParam(); |
|
245
|
|
|
$queryParam->setDefault('stream', null); |
|
246
|
|
|
$url = '/containers/{id}/stats'; |
|
247
|
|
|
$url = str_replace('{id}', $id, $url); |
|
248
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
249
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
250
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
251
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
252
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
253
|
|
|
|
|
254
|
|
|
return $response; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* Resize the TTY for container with id. The unit is number of characters. You must restart the container for the resize to take effect. |
|
259
|
|
|
* |
|
260
|
|
|
* @param string $id The container id or name |
|
261
|
|
|
* @param array $parameters List of parameters |
|
262
|
|
|
* |
|
263
|
|
|
* (int)h: Height of the tty session |
|
264
|
|
|
* (int)w: Width of the tty session |
|
265
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
266
|
|
|
* |
|
267
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
268
|
|
|
*/ |
|
269
|
|
View Code Duplication |
public function resize($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
270
|
|
|
{ |
|
271
|
|
|
$queryParam = new QueryParam(); |
|
272
|
|
|
$queryParam->setDefault('h', null); |
|
273
|
|
|
$queryParam->setDefault('w', null); |
|
274
|
|
|
$url = '/containers/{id}/resize'; |
|
275
|
|
|
$url = str_replace('{id}', $id, $url); |
|
276
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
277
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
278
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
279
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
280
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
281
|
|
|
|
|
282
|
|
|
return $response; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* Start the container id. |
|
287
|
|
|
* |
|
288
|
|
|
* @param string $id The container id or name |
|
289
|
|
|
* @param array $parameters List of parameters |
|
290
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
291
|
|
|
* |
|
292
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
293
|
|
|
*/ |
|
294
|
|
|
public function start($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
295
|
|
|
{ |
|
296
|
|
|
$queryParam = new QueryParam(); |
|
297
|
|
|
$url = '/containers/{id}/start'; |
|
298
|
|
|
$url = str_replace('{id}', $id, $url); |
|
299
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
300
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
301
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
302
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
303
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
304
|
|
|
|
|
305
|
|
|
return $response; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
/** |
|
309
|
|
|
* Stop the container id. |
|
310
|
|
|
* |
|
311
|
|
|
* @param string $id The container id or name |
|
312
|
|
|
* @param array $parameters List of parameters |
|
313
|
|
|
* |
|
314
|
|
|
* (int)t: number of seconds to wait before killing the container |
|
315
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
316
|
|
|
* |
|
317
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
318
|
|
|
*/ |
|
319
|
|
|
public function stop($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
320
|
|
|
{ |
|
321
|
|
|
$queryParam = new QueryParam(); |
|
322
|
|
|
$queryParam->setDefault('t', null); |
|
323
|
|
|
$url = '/containers/{id}/stop'; |
|
324
|
|
|
$url = str_replace('{id}', $id, $url); |
|
325
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
326
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
327
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
328
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
329
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
330
|
|
|
|
|
331
|
|
|
return $response; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* Restart the container id. |
|
336
|
|
|
* |
|
337
|
|
|
* @param string $id The container id or name |
|
338
|
|
|
* @param array $parameters List of parameters |
|
339
|
|
|
* |
|
340
|
|
|
* (int)t: number of seconds to wait before killing the container |
|
341
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
342
|
|
|
* |
|
343
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
344
|
|
|
*/ |
|
345
|
|
|
public function restart($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
346
|
|
|
{ |
|
347
|
|
|
$queryParam = new QueryParam(); |
|
348
|
|
|
$queryParam->setDefault('t', null); |
|
349
|
|
|
$url = '/containers/{id}/restart'; |
|
350
|
|
|
$url = str_replace('{id}', $id, $url); |
|
351
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
352
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
353
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
354
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
355
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
356
|
|
|
|
|
357
|
|
|
return $response; |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
/** |
|
361
|
|
|
* Send a posix signal to a container. |
|
362
|
|
|
* |
|
363
|
|
|
* @param string $id The container id or name |
|
364
|
|
|
* @param array $parameters List of parameters |
|
365
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
366
|
|
|
* |
|
367
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
368
|
|
|
*/ |
|
369
|
|
|
public function kill($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
370
|
|
|
{ |
|
371
|
|
|
$queryParam = new QueryParam(); |
|
372
|
|
|
$url = '/containers/{id}/kill'; |
|
373
|
|
|
$url = str_replace('{id}', $id, $url); |
|
374
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
375
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
376
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
377
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
378
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
379
|
|
|
|
|
380
|
|
|
return $response; |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
/** |
|
384
|
|
|
* Rename the container id to a new_name. |
|
385
|
|
|
* |
|
386
|
|
|
* @param string $id The container id or name |
|
387
|
|
|
* @param array $parameters List of parameters |
|
388
|
|
|
* |
|
389
|
|
|
* (string)name: New name for the container |
|
390
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
391
|
|
|
* |
|
392
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
393
|
|
|
*/ |
|
394
|
|
|
public function rename($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
395
|
|
|
{ |
|
396
|
|
|
$queryParam = new QueryParam(); |
|
397
|
|
|
$queryParam->setRequired('name'); |
|
398
|
|
|
$url = '/containers/{id}/rename'; |
|
399
|
|
|
$url = str_replace('{id}', $id, $url); |
|
400
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
401
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
402
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
403
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
404
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
405
|
|
|
|
|
406
|
|
|
return $response; |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* Pause the container id. |
|
411
|
|
|
* |
|
412
|
|
|
* @param string $id The container id or name |
|
413
|
|
|
* @param array $parameters List of parameters |
|
414
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
415
|
|
|
* |
|
416
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
417
|
|
|
*/ |
|
418
|
|
|
public function pause($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
419
|
|
|
{ |
|
420
|
|
|
$queryParam = new QueryParam(); |
|
421
|
|
|
$url = '/containers/{id}/pause'; |
|
422
|
|
|
$url = str_replace('{id}', $id, $url); |
|
423
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
424
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
425
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
426
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
427
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
428
|
|
|
|
|
429
|
|
|
return $response; |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
/** |
|
433
|
|
|
* Unpause the container id. |
|
434
|
|
|
* |
|
435
|
|
|
* @param string $id The container id or name |
|
436
|
|
|
* @param array $parameters List of parameters |
|
437
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
438
|
|
|
* |
|
439
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
440
|
|
|
*/ |
|
441
|
|
|
public function unpause($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
442
|
|
|
{ |
|
443
|
|
|
$queryParam = new QueryParam(); |
|
444
|
|
|
$url = '/containers/{id}/unpause'; |
|
445
|
|
|
$url = str_replace('{id}', $id, $url); |
|
446
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
447
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
448
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
449
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
450
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
451
|
|
|
|
|
452
|
|
|
return $response; |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* Attach to the container id. |
|
457
|
|
|
* |
|
458
|
|
|
* @param string $id The container id or name |
|
459
|
|
|
* @param array $parameters List of parameters |
|
460
|
|
|
* |
|
461
|
|
|
* (string)logs: 1/True/true or 0/False/false, return logs. Default false |
|
462
|
|
|
* (string)stream: 1/True/true or 0/False/false, return stream. Default false |
|
463
|
|
|
* (string)stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false. |
|
464
|
|
|
* (string)stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false. |
|
465
|
|
|
* (string)stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false. |
|
466
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
467
|
|
|
* |
|
468
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
469
|
|
|
*/ |
|
470
|
|
View Code Duplication |
public function attach($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
471
|
|
|
{ |
|
472
|
|
|
$queryParam = new QueryParam(); |
|
473
|
|
|
$queryParam->setDefault('logs', null); |
|
474
|
|
|
$queryParam->setDefault('stream', null); |
|
475
|
|
|
$queryParam->setDefault('stdin', null); |
|
476
|
|
|
$queryParam->setDefault('stdout', null); |
|
477
|
|
|
$queryParam->setDefault('stderr', null); |
|
478
|
|
|
$url = '/containers/{id}/attach'; |
|
479
|
|
|
$url = str_replace('{id}', $id, $url); |
|
480
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
481
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
482
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
483
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
484
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
485
|
|
|
|
|
486
|
|
|
return $response; |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
/** |
|
490
|
|
|
* Block until container id stops, then returns the exit code. |
|
491
|
|
|
* |
|
492
|
|
|
* @param string $id The container id or name |
|
493
|
|
|
* @param array $parameters List of parameters |
|
494
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
495
|
|
|
* |
|
496
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerWait |
|
497
|
|
|
*/ |
|
498
|
|
|
public function wait($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
499
|
|
|
{ |
|
500
|
|
|
$queryParam = new QueryParam(); |
|
501
|
|
|
$url = '/containers/{id}/wait'; |
|
502
|
|
|
$url = str_replace('{id}', $id, $url); |
|
503
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
504
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
505
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
506
|
|
|
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body); |
|
507
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
508
|
|
|
if (self::FETCH_OBJECT == $fetch) { |
|
509
|
|
|
if ('200' == $response->getStatusCode()) { |
|
510
|
|
|
return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerWait', 'json'); |
|
511
|
|
|
} |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
return $response; |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* Remove the container id from the filesystem. |
|
519
|
|
|
* |
|
520
|
|
|
* @param string $id The container id or name |
|
521
|
|
|
* @param array $parameters List of parameters |
|
522
|
|
|
* |
|
523
|
|
|
* (string)v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false. |
|
524
|
|
|
* (string)force: 1/True/true or 0/False/false, Kill then remove the container. Default false. |
|
525
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
526
|
|
|
* |
|
527
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
528
|
|
|
*/ |
|
529
|
|
View Code Duplication |
public function remove($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
530
|
|
|
{ |
|
531
|
|
|
$queryParam = new QueryParam(); |
|
532
|
|
|
$queryParam->setDefault('v', null); |
|
533
|
|
|
$queryParam->setDefault('force', null); |
|
534
|
|
|
$url = '/containers/{id}'; |
|
535
|
|
|
$url = str_replace('{id}', $id, $url); |
|
536
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
537
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
538
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
539
|
|
|
$request = $this->messageFactory->createRequest('DELETE', $url, $headers, $body); |
|
540
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
541
|
|
|
|
|
542
|
|
|
return $response; |
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
/** |
|
546
|
|
|
* Get an tar archive of a resource in the filesystem of container id. |
|
547
|
|
|
* |
|
548
|
|
|
* @param string $id The container id or name |
|
549
|
|
|
* @param array $parameters List of parameters |
|
550
|
|
|
* |
|
551
|
|
|
* (string)path: Resource in the container’s filesystem to archive. |
|
552
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
553
|
|
|
* |
|
554
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
555
|
|
|
*/ |
|
556
|
|
|
public function getArchive($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
557
|
|
|
{ |
|
558
|
|
|
$queryParam = new QueryParam(); |
|
559
|
|
|
$queryParam->setRequired('path'); |
|
560
|
|
|
$url = '/containers/{id}/archive'; |
|
561
|
|
|
$url = str_replace('{id}', $id, $url); |
|
562
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
563
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
564
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
565
|
|
|
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body); |
|
566
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
567
|
|
|
|
|
568
|
|
|
return $response; |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
/** |
|
572
|
|
|
* Retrieving information about files and folders in a container. |
|
573
|
|
|
* |
|
574
|
|
|
* @param string $id The container id or name |
|
575
|
|
|
* @param array $parameters List of parameters |
|
576
|
|
|
* |
|
577
|
|
|
* (string)path: Resource in the container’s filesystem to archive. |
|
578
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
579
|
|
|
* |
|
580
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
581
|
|
|
*/ |
|
582
|
|
|
public function getArchiveInformation($id, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
583
|
|
|
{ |
|
584
|
|
|
$queryParam = new QueryParam(); |
|
585
|
|
|
$queryParam->setRequired('path'); |
|
586
|
|
|
$url = '/containers/{id}/archive'; |
|
587
|
|
|
$url = str_replace('{id}', $id, $url); |
|
588
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
589
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
590
|
|
|
$body = $queryParam->buildFormDataString($parameters); |
|
591
|
|
|
$request = $this->messageFactory->createRequest('HEAD', $url, $headers, $body); |
|
592
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
593
|
|
|
|
|
594
|
|
|
return $response; |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
/** |
|
598
|
|
|
* Upload a tar archive to be extracted to a path in the filesystem of container id. |
|
599
|
|
|
* |
|
600
|
|
|
* @param string $id The container id or name |
|
601
|
|
|
* @param string $inputStream The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. |
|
602
|
|
|
* @param array $parameters List of parameters |
|
603
|
|
|
* |
|
604
|
|
|
* (string)path: Path to a directory in the container to extract the archive’s contents into. |
|
605
|
|
|
* (string)noOverwriteDirNonDir: If “1”, “true”, or “True” then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa. |
|
606
|
|
|
* @param string $fetch Fetch mode (object or response) |
|
607
|
|
|
* |
|
608
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
609
|
|
|
*/ |
|
610
|
|
|
public function putArchive($id, $inputStream, $parameters = [], $fetch = self::FETCH_OBJECT) |
|
|
|
|
|
|
611
|
|
|
{ |
|
612
|
|
|
$queryParam = new QueryParam(); |
|
613
|
|
|
$queryParam->setRequired('path'); |
|
614
|
|
|
$queryParam->setDefault('noOverwriteDirNonDir', null); |
|
615
|
|
|
$url = '/containers/{id}/archive'; |
|
616
|
|
|
$url = str_replace('{id}', $id, $url); |
|
617
|
|
|
$url = $url . ('?' . $queryParam->buildQueryString($parameters)); |
|
618
|
|
|
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters)); |
|
619
|
|
|
$body = $inputStream; |
|
620
|
|
|
$request = $this->messageFactory->createRequest('PUT', $url, $headers, $body); |
|
621
|
|
|
$response = $this->httpClient->sendRequest($request); |
|
622
|
|
|
|
|
623
|
|
|
return $response; |
|
624
|
|
|
} |
|
625
|
|
|
} |
|
626
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.