Skip to content
Navigation Menu
{{ message }}
forked from docker-php/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerResource.php
More file actions
830 lines (780 loc) · 34.7 KB
/
Copy pathContainerResource.php
File metadata and controls
830 lines (780 loc) · 34.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
<?php
namespace Docker\API\Resource;
use Joli\Jane\OpenApi\Runtime\Client\QueryParam;
use Joli\Jane\OpenApi\Runtime\Client\Resource;
class ContainerResource extends Resource
{
/**
* List containers.
*
* @param array $parameters {
*
* @var bool $all Show all containers. Only running containers are shown by default (i.e., this defaults to false)
* @var int $limit Show <limit> last created containers, include non-running ones.
* @var string $since Show only containers created since Id, include non-running ones.
* @var string $before Show only containers created before Id, include non-running ones.
* @var bool $size 1/True/true or 0/False/false, Show the containers sizes.
* @var array $filters A JSON encoded value of the filters (a map[string][]string) to process on the containers list
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerInfo[]
*/
public function findAll($parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('all', false);
$queryParam->setDefault('limit', null);
$queryParam->setDefault('since', null);
$queryParam->setDefault('before', null);
$queryParam->setDefault('size', null);
$queryParam->setDefault('filters', null);
$url = '/containers/json';
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerInfo[]', 'json');
}
}
return $response;
}
/**
* Create a container.
*
* @param \Docker\API\Model\ContainerConfig $container Container to create
* @param array $parameters {
*
* @var string $name Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+.
* @var string $Content-Type Content Type of input
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerCreateResult
*/
public function create(\Docker\API\Model\ContainerConfig $container, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('name', null);
$queryParam->setDefault('Content-Type', 'application/json');
$queryParam->setHeaderParameters(['Content-Type']);
$url = '/containers/create';
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $this->serializer->serialize($container, 'json');
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('201' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerCreateResult', 'json');
}
}
return $response;
}
/**
* Return low-level information on the container id.
*
* @param string $id The container id or name
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\Container
*/
public function find($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/json';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\Container', 'json');
}
}
return $response;
}
/**
* List processes running inside the container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $ps_args ps arguments to use (e.g., aux)
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerTop
*/
public function listProcesses($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('ps_args', null);
$url = '/containers/{id}/top';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerTop', 'json');
}
}
return $response;
}
/**
* Get stdout and stderr logs from the container id. Note: This endpoint works only for containers with json-file logging driver.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var bool $follow 1/True/true or 0/False/false, return stream. Default false.
* @var bool $stdout 1/True/true or 0/False/false, show stdout log. Default false.
* @var bool $stderr 1/True/true or 0/False/false, show stderr log. Default false.
* @var int $since UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered)
* @var bool $timestamps 1/True/true or 0/False/false, print timestamps for every log line.
* @var string $tail Output specified number of lines at the end of logs: all or <number>. Default all.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function logs($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('follow', false);
$queryParam->setDefault('stdout', false);
$queryParam->setDefault('stderr', false);
$queryParam->setDefault('since', 0);
$queryParam->setDefault('timestamps', false);
$queryParam->setDefault('tail', null);
$url = '/containers/{id}/logs';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Inspect changes on a container’s filesystem.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var int $kind Kind of changes
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerChange[]
*/
public function changes($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('kind', null);
$url = '/containers/{id}/changes';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerChange[]', 'json');
}
}
return $response;
}
/**
* Export the contents of container id.
*
* @param string $id The container id or name
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function export($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/export';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* This endpoint returns a live stream of a container’s resource usage statistics.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var bool $stream Stream stats
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function stats($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('stream', null);
$url = '/containers/{id}/stats';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Resize the TTY for container with id. The unit is number of characters. You must restart the container for the resize to take effect.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var int $h Height of the tty session
* @var int $w Width of the tty session
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function resize($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('h', null);
$queryParam->setDefault('w', null);
$url = '/containers/{id}/resize';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Start the container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $detachKeys Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function start($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('detachKeys', null);
$url = '/containers/{id}/start';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Stop the container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var int $t number of seconds to wait before killing the container
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function stop($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('t', null);
$url = '/containers/{id}/stop';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Restart the container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var int $t number of seconds to wait before killing the container
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function restart($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('t', null);
$url = '/containers/{id}/restart';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Send a posix signal to a container.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $signal Signal to send to the container, integer or string like SIGINT, defaults to SIGKILL
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function kill($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('signal', null);
$url = '/containers/{id}/kill';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Update resource configs of one or more containers.
*
* @param string $id The container id or name
* @param \Docker\API\Model\ResourceUpdate $resourceConfig Resources to update on container
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerUpdateResult
*/
public function update($id, \Docker\API\Model\ResourceUpdate $resourceConfig, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/update';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $this->serializer->serialize($resourceConfig, 'json');
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerUpdateResult', 'json');
}
}
return $response;
}
/**
* Rename the container id to a new_name.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $name New name for the container
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function rename($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setRequired('name');
$url = '/containers/{id}/rename';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Pause the container id.
*
* @param string $id The container id or name
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function pause($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/pause';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Unpause the container id.
*
* @param string $id The container id or name
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function unpause($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/unpause';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Attach to the container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $logs 1/True/true or 0/False/false, return logs. Default false
* @var string $stream 1/True/true or 0/False/false, return stream. Default false
* @var string $stdin 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false.
* @var string $stdout 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false.
* @var string $stderr 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false.
* @var string $detachKeys Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function attach($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('logs', null);
$queryParam->setDefault('stream', null);
$queryParam->setDefault('stdin', null);
$queryParam->setDefault('stdout', null);
$queryParam->setDefault('stderr', null);
$queryParam->setDefault('detachKeys', null);
$url = '/containers/{id}/attach';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Attach to the container id with a websocket.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $logs 1/True/true or 0/False/false, return logs. Default false
* @var string $stream 1/True/true or 0/False/false, return stream. Default false
* @var string $stdin 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false.
* @var string $stdout 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false.
* @var string $stderr 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false.
* @var string $detachKeys Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function attachWebsocket($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('logs', null);
$queryParam->setDefault('stream', null);
$queryParam->setDefault('stdin', null);
$queryParam->setDefault('stdout', null);
$queryParam->setDefault('stderr', null);
$queryParam->setDefault('detachKeys', null);
$url = '/containers/{id}/attach/ws';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Block until container id stops, then returns the exit code.
*
* @param string $id The container id or name
* @param array $parameters List of parameters
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\ContainerWait
*/
public function wait($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$url = '/containers/{id}/wait';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerWait', 'json');
}
}
return $response;
}
/**
* Remove the container id from the filesystem.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $v 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false.
* @var string $force 1/True/true or 0/False/false, Kill then remove the container. Default false.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function remove($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setDefault('v', null);
$queryParam->setDefault('force', null);
$url = '/containers/{id}';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('DELETE', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Get an tar archive of a resource in the filesystem of container id.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $path Resource in the container’s filesystem to archive.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function getArchive($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setRequired('path');
$url = '/containers/{id}/archive';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Retrieving information about files and folders in a container.
*
* @param string $id The container id or name
* @param array $parameters {
*
* @var string $path Resource in the container’s filesystem to archive.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function getArchiveInformation($id, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setRequired('path');
$url = '/containers/{id}/archive';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $queryParam->buildFormDataString($parameters);
$request = $this->messageFactory->createRequest('HEAD', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
/**
* Upload a tar archive to be extracted to a path in the filesystem of container id.
*
* @param string $id The container id or name
* @param string $inputStream The input stream must be a tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
* @param array $parameters {
*
* @var string $path Path to a directory in the container to extract the archive’s contents into.
* @var 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.
* }
*
* @param string $fetch Fetch mode (object or response)
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function putArchive($id, $inputStream, $parameters = [], $fetch = self::FETCH_OBJECT)
{
$queryParam = new QueryParam();
$queryParam->setRequired('path');
$queryParam->setDefault('noOverwriteDirNonDir', null);
$url = '/containers/{id}/archive';
$url = str_replace('{id}', urlencode($id), $url);
$url = $url . ('?' . $queryParam->buildQueryString($parameters));
$headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
$body = $inputStream;
$request = $this->messageFactory->createRequest('PUT', $url, $headers, $body);
$promise = $this->httpClient->sendAsyncRequest($request);
if (self::FETCH_PROMISE === $fetch) {
return $promise;
}
$response = $promise->wait();
return $response;
}
}
You can’t perform that action at this time.
