@@ 598-609 (lines=12) @@ | ||
595 | * |
|
596 | * @return array |
|
597 | */ |
|
598 | public function changes(Container $container) |
|
599 | { |
|
600 | $response = $this->client->get(['/containers/{id}/changes', [ |
|
601 | 'id' => $container->getId() |
|
602 | ]]); |
|
603 | ||
604 | if ($response->getStatusCode() !== "200") { |
|
605 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
606 | } |
|
607 | ||
608 | return $response->json(); |
|
609 | } |
|
610 | ||
611 | /** |
|
612 | * Export a container to a tar |
|
@@ 620-631 (lines=12) @@ | ||
617 | * |
|
618 | * @return \GuzzleHttp\Stream\Stream |
|
619 | */ |
|
620 | public function export(Container $container) |
|
621 | { |
|
622 | $response = $this->client->get(['/containers/{id}/export', [ |
|
623 | 'id' => $container->getId() |
|
624 | ]]); |
|
625 | ||
626 | if ($response->getStatusCode() !== "200") { |
|
627 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
628 | } |
|
629 | ||
630 | return $response->getBody(); |
|
631 | } |
|
632 | ||
633 | /** |
|
634 | * Get logs from a container |
|
@@ 684-696 (lines=13) @@ | ||
681 | * |
|
682 | * @throws \Docker\Exception\UnexpectedStatusCodeException |
|
683 | */ |
|
684 | public function restart(Container $container, $timeBeforeKill = 5) |
|
685 | { |
|
686 | $response = $this->client->post(['/containers/{id}/restart?t={time}', [ |
|
687 | 'id' => $container->getId(), |
|
688 | 'time' => $timeBeforeKill |
|
689 | ]]); |
|
690 | ||
691 | if ($response->getStatusCode() !== "204") { |
|
692 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
693 | } |
|
694 | ||
695 | $this->inspect($container); |
|
696 | } |
|
697 | ||
698 | /** |
|
699 | * Send a signal to container |
|
@@ 706-716 (lines=11) @@ | ||
703 | * |
|
704 | * @throws \Docker\Exception\UnexpectedStatusCodeException |
|
705 | */ |
|
706 | public function kill(Container $container, $signal = "SIGKILL") |
|
707 | { |
|
708 | $response = $this->client->post(['/containers/{id}/kill?signal={signal}', [ |
|
709 | 'id' => $container->getId(), |
|
710 | 'signal' => $signal |
|
711 | ]]); |
|
712 | ||
713 | if ($response->getStatusCode() !== "204") { |
|
714 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
715 | } |
|
716 | } |
|
717 | ||
718 | /** |
|
719 | * Rename a container (API v1.17) |
|
@@ 726-738 (lines=13) @@ | ||
723 | * |
|
724 | * @throws \Docker\Exception\UnexpectedStatusCodeException |
|
725 | */ |
|
726 | public function rename(Container $container, $newname) |
|
727 | { |
|
728 | $response = $this->client->post(['/containers/{id}/rename?name={newname}', [ |
|
729 | 'id' => $container->getId(), |
|
730 | 'newname' => $newname |
|
731 | ]]); |
|
732 | ||
733 | if ($response->getStatusCode() !== "204") { |
|
734 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
735 | } |
|
736 | ||
737 | return $this; |
|
738 | } |
|
739 | ||
740 | /** |
|
741 | * Pause a container |
|
@@ 747-760 (lines=14) @@ | ||
744 | * |
|
745 | * @throws \Docker\Exception\UnexpectedStatusCodeException |
|
746 | */ |
|
747 | public function pause(Container $container) |
|
748 | { |
|
749 | $response = $this->client->post(['/containers/{id}/pause', [ |
|
750 | 'id' => $container->getId() |
|
751 | ]]); |
|
752 | ||
753 | if ($response->getStatusCode() !== "204") { |
|
754 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
755 | } |
|
756 | ||
757 | $this->inspect($container); |
|
758 | ||
759 | return $this; |
|
760 | } |
|
761 | ||
762 | /** |
|
763 | * Unpause a container |
|
@@ 769-782 (lines=14) @@ | ||
766 | * |
|
767 | * @throws \Docker\Exception\UnexpectedStatusCodeException |
|
768 | */ |
|
769 | public function unpause(Container $container) |
|
770 | { |
|
771 | $response = $this->client->post(['/containers/{id}/unpause', [ |
|
772 | 'id' => $container->getId() |
|
773 | ]]); |
|
774 | ||
775 | if ($response->getStatusCode() !== "204") { |
|
776 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
777 | } |
|
778 | ||
779 | $this->inspect($container); |
|
780 | ||
781 | return $this; |
|
782 | } |
|
783 | } |
|
784 |
@@ 410-421 (lines=12) @@ | ||
407 | * |
|
408 | * @return array |
|
409 | */ |
|
410 | public function history(Image $image) |
|
411 | { |
|
412 | $response = $this->client->get(['/images/{name}/history', [ |
|
413 | 'name' => $image->__toString() |
|
414 | ]]); |
|
415 | ||
416 | if ($response->getStatusCode() !== "200") { |
|
417 | throw UnexpectedStatusCodeException::fromResponse($response); |
|
418 | } |
|
419 | ||
420 | return $response->json(); |
|
421 | } |
|
422 | } |
|
423 |