Completed
Pull Request — master (#147)
by Joel
06:04 queued 03:13
created

ContainerResource::findAll()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0857
cc 3
eloc 18
nc 3
nop 2
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 View Code Duplication
    public function create(\Docker\API\Model\ContainerConfig $container, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
    public function resize($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
     * 
366
     *     (string)signal: Signal to send to the container, integer or string like SIGINT, defaults to SIGKILL
367
     * @param string $fetch Fetch mode (object or response)
368
     *
369
     * @return \Psr\Http\Message\ResponseInterface
370
     */
371
    public function kill($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
372
    {
373
        $queryParam = new QueryParam();
374
        $queryParam->setDefault('signal', null);
375
        $url      = '/containers/{id}/kill';
376
        $url      = str_replace('{id}', $id, $url);
377
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
378
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
379
        $body     = $queryParam->buildFormDataString($parameters);
380
        $request  = $this->messageFactory->createRequest('POST', $url, $headers, $body);
381
        $response = $this->httpClient->sendRequest($request);
382
383
        return $response;
384
    }
385
386
    /**
387
     * Rename the container id to a new_name.
388
     *
389
     * @param string $id         The container id or name
390
     * @param array  $parameters List of parameters
391
     * 
392
     *     (string)name: New name for the container
393
     * @param string $fetch Fetch mode (object or response)
394
     *
395
     * @return \Psr\Http\Message\ResponseInterface
396
     */
397
    public function rename($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
398
    {
399
        $queryParam = new QueryParam();
400
        $queryParam->setRequired('name');
401
        $url      = '/containers/{id}/rename';
402
        $url      = str_replace('{id}', $id, $url);
403
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
404
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
405
        $body     = $queryParam->buildFormDataString($parameters);
406
        $request  = $this->messageFactory->createRequest('POST', $url, $headers, $body);
407
        $response = $this->httpClient->sendRequest($request);
408
409
        return $response;
410
    }
411
412
    /**
413
     * Pause the container id.
414
     *
415
     * @param string $id         The container id or name
416
     * @param array  $parameters List of parameters
417
     * @param string $fetch      Fetch mode (object or response)
418
     *
419
     * @return \Psr\Http\Message\ResponseInterface
420
     */
421
    public function pause($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
422
    {
423
        $queryParam = new QueryParam();
424
        $url        = '/containers/{id}/pause';
425
        $url        = str_replace('{id}', $id, $url);
426
        $url        = $url . ('?' . $queryParam->buildQueryString($parameters));
427
        $headers    = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
428
        $body       = $queryParam->buildFormDataString($parameters);
429
        $request    = $this->messageFactory->createRequest('POST', $url, $headers, $body);
430
        $response   = $this->httpClient->sendRequest($request);
431
432
        return $response;
433
    }
434
435
    /**
436
     * Unpause the container id.
437
     *
438
     * @param string $id         The container id or name
439
     * @param array  $parameters List of parameters
440
     * @param string $fetch      Fetch mode (object or response)
441
     *
442
     * @return \Psr\Http\Message\ResponseInterface
443
     */
444
    public function unpause($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
445
    {
446
        $queryParam = new QueryParam();
447
        $url        = '/containers/{id}/unpause';
448
        $url        = str_replace('{id}', $id, $url);
449
        $url        = $url . ('?' . $queryParam->buildQueryString($parameters));
450
        $headers    = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
451
        $body       = $queryParam->buildFormDataString($parameters);
452
        $request    = $this->messageFactory->createRequest('POST', $url, $headers, $body);
453
        $response   = $this->httpClient->sendRequest($request);
454
455
        return $response;
456
    }
457
458
    /**
459
     * Attach to the container id.
460
     *
461
     * @param string $id         The container id or name
462
     * @param array  $parameters List of parameters
463
     * 
464
     *     (string)logs: 1/True/true or 0/False/false, return logs. Default false
465
     *     (string)stream: 1/True/true or 0/False/false, return stream. Default false
466
     *     (string)stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false.
467
     *     (string)stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false.
468
     *     (string)stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false.
469
     * @param string $fetch Fetch mode (object or response)
470
     *
471
     * @return \Psr\Http\Message\ResponseInterface
472
     */
473 View Code Duplication
    public function attach($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
474
    {
475
        $queryParam = new QueryParam();
476
        $queryParam->setDefault('logs', null);
477
        $queryParam->setDefault('stream', null);
478
        $queryParam->setDefault('stdin', null);
479
        $queryParam->setDefault('stdout', null);
480
        $queryParam->setDefault('stderr', null);
481
        $url      = '/containers/{id}/attach';
482
        $url      = str_replace('{id}', $id, $url);
483
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
484
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
485
        $body     = $queryParam->buildFormDataString($parameters);
486
        $request  = $this->messageFactory->createRequest('POST', $url, $headers, $body);
487
        $response = $this->httpClient->sendRequest($request);
488
489
        return $response;
490
    }
491
492
    /**
493
     * Attach to the container id with a websocket.
494
     *
495
     * @param string $id         The container id or name
496
     * @param array  $parameters List of parameters
497
     * 
498
     *     (string)logs: 1/True/true or 0/False/false, return logs. Default false
499
     *     (string)stream: 1/True/true or 0/False/false, return stream. Default false
500
     *     (string)stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false.
501
     *     (string)stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false.
502
     *     (string)stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false.
503
     * @param string $fetch Fetch mode (object or response)
504
     *
505
     * @return \Psr\Http\Message\ResponseInterface
506
     */
507 View Code Duplication
    public function attachWebsocket($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
508
    {
509
        $queryParam = new QueryParam();
510
        $queryParam->setDefault('logs', null);
511
        $queryParam->setDefault('stream', null);
512
        $queryParam->setDefault('stdin', null);
513
        $queryParam->setDefault('stdout', null);
514
        $queryParam->setDefault('stderr', null);
515
        $url      = '/containers/{id}/attach/ws';
516
        $url      = str_replace('{id}', $id, $url);
517
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
518
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
519
        $body     = $queryParam->buildFormDataString($parameters);
520
        $request  = $this->messageFactory->createRequest('GET', $url, $headers, $body);
521
        $response = $this->httpClient->sendRequest($request);
522
523
        return $response;
524
    }
525
526
    /**
527
     * Block until container id stops, then returns the exit code.
528
     *
529
     * @param string $id         The container id or name
530
     * @param array  $parameters List of parameters
531
     * @param string $fetch      Fetch mode (object or response)
532
     *
533
     * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerWait
534
     */
535
    public function wait($id, $parameters = [], $fetch = self::FETCH_OBJECT)
536
    {
537
        $queryParam = new QueryParam();
538
        $url        = '/containers/{id}/wait';
539
        $url        = str_replace('{id}', $id, $url);
540
        $url        = $url . ('?' . $queryParam->buildQueryString($parameters));
541
        $headers    = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
542
        $body       = $queryParam->buildFormDataString($parameters);
543
        $request    = $this->messageFactory->createRequest('POST', $url, $headers, $body);
544
        $response   = $this->httpClient->sendRequest($request);
545
        if (self::FETCH_OBJECT == $fetch) {
546
            if ('200' == $response->getStatusCode()) {
547
                return $this->serializer->deserialize($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerWait', 'json');
548
            }
549
        }
550
551
        return $response;
552
    }
553
554
    /**
555
     * Remove the container id from the filesystem.
556
     *
557
     * @param string $id         The container id or name
558
     * @param array  $parameters List of parameters
559
     * 
560
     *     (string)v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false.
561
     *     (string)force: 1/True/true or 0/False/false, Kill then remove the container. Default false.
562
     * @param string $fetch Fetch mode (object or response)
563
     *
564
     * @return \Psr\Http\Message\ResponseInterface
565
     */
566
    public function remove($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
567
    {
568
        $queryParam = new QueryParam();
569
        $queryParam->setDefault('v', null);
570
        $queryParam->setDefault('force', null);
571
        $url      = '/containers/{id}';
572
        $url      = str_replace('{id}', $id, $url);
573
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
574
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
575
        $body     = $queryParam->buildFormDataString($parameters);
576
        $request  = $this->messageFactory->createRequest('DELETE', $url, $headers, $body);
577
        $response = $this->httpClient->sendRequest($request);
578
579
        return $response;
580
    }
581
582
    /**
583
     * Get an tar archive of a resource in the filesystem of container id.
584
     *
585
     * @param string $id         The container id or name
586
     * @param array  $parameters List of parameters
587
     * 
588
     *     (string)path: Resource in the container’s filesystem to archive.
589
     * @param string $fetch Fetch mode (object or response)
590
     *
591
     * @return \Psr\Http\Message\ResponseInterface
592
     */
593
    public function getArchive($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
594
    {
595
        $queryParam = new QueryParam();
596
        $queryParam->setRequired('path');
597
        $url      = '/containers/{id}/archive';
598
        $url      = str_replace('{id}', $id, $url);
599
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
600
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
601
        $body     = $queryParam->buildFormDataString($parameters);
602
        $request  = $this->messageFactory->createRequest('GET', $url, $headers, $body);
603
        $response = $this->httpClient->sendRequest($request);
604
605
        return $response;
606
    }
607
608
    /**
609
     * Retrieving information about files and folders in a container.
610
     *
611
     * @param string $id         The container id or name
612
     * @param array  $parameters List of parameters
613
     * 
614
     *     (string)path: Resource in the container’s filesystem to archive.
615
     * @param string $fetch Fetch mode (object or response)
616
     *
617
     * @return \Psr\Http\Message\ResponseInterface
618
     */
619
    public function getArchiveInformation($id, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
620
    {
621
        $queryParam = new QueryParam();
622
        $queryParam->setRequired('path');
623
        $url      = '/containers/{id}/archive';
624
        $url      = str_replace('{id}', $id, $url);
625
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
626
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
627
        $body     = $queryParam->buildFormDataString($parameters);
628
        $request  = $this->messageFactory->createRequest('HEAD', $url, $headers, $body);
629
        $response = $this->httpClient->sendRequest($request);
630
631
        return $response;
632
    }
633
634
    /**
635
     * Upload a tar archive to be extracted to a path in the filesystem of container id.
636
     *
637
     * @param string $id          The container id or name
638
     * @param string $inputStream The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
639
     * @param array  $parameters  List of parameters
640
     * 
641
     *     (string)path: Path to a directory in the container to extract the archive’s contents into. 
642
     *     (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.
643
     * @param string $fetch Fetch mode (object or response)
644
     *
645
     * @return \Psr\Http\Message\ResponseInterface
646
     */
647
    public function putArchive($id, $inputStream, $parameters = [], $fetch = self::FETCH_OBJECT)
0 ignored issues
show
Unused Code introduced by
The parameter $fetch is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
648
    {
649
        $queryParam = new QueryParam();
650
        $queryParam->setRequired('path');
651
        $queryParam->setDefault('noOverwriteDirNonDir', null);
652
        $url      = '/containers/{id}/archive';
653
        $url      = str_replace('{id}', $id, $url);
654
        $url      = $url . ('?' . $queryParam->buildQueryString($parameters));
655
        $headers  = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
656
        $body     = $inputStream;
657
        $request  = $this->messageFactory->createRequest('PUT', $url, $headers, $body);
658
        $response = $this->httpClient->sendRequest($request);
659
660
        return $response;
661
    }
662
}
663