Beispiel #1
0
 /**
  * {@inheritdoc}
  *
  * @return \Psr\Http\Message\ResponseInterface|PushImageInfo[]|CreateImageStream
  */
 public function push($name, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     if (isset($parameters['X-Registry-Auth']) && $parameters['X-Registry-Auth'] instanceof AuthConfig) {
         $parameters['X-Registry-Auth'] = base64_encode($this->serializer->serialize($parameters['X-Registry-Auth'], 'json'));
     }
     $queryParam = new QueryParam();
     $queryParam->setDefault('tag', null);
     $queryParam->setDefault('X-Registry-Auth', null);
     $queryParam->setHeaderParameters(['X-Registry-Auth']);
     $url = 'http://localhost/images/{name}/push';
     $url = str_replace('{name}', $name, $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);
     $response = $this->httpClient->sendRequest($request);
     if (200 === $response->getStatusCode()) {
         if (self::FETCH_STREAM === $fetch) {
             return new PushStream($response->getBody(), $this->serializer);
         }
         if (self::FETCH_OBJECT === $fetch) {
             $pushImageInfoList = [];
             $stream = new PushStream($response->getBody(), $this->serializer);
             $stream->onFrame(function (PushImageInfo $pushImageInfo) use(&$pushImageInfoList) {
                 $pushImageInfoList[] = $pushImageInfo;
             });
             $stream->wait();
             return $pushImageInfoList;
         }
     }
     return $response;
 }
Beispiel #2
0
 /**
  * Starts a previously set up exec instance id. If detach is true, this API returns after starting the exec command. Otherwise, this API sets up an interactive session with the exec command.
  *
  * @param string                            $id              Exec instance id
  * @param \Docker\API\Model\ExecStartConfig $execStartConfig Exec configuration
  * @param array                             $parameters      {
  *
  *     @var string $Content-Type Content Type Header
  * }
  *
  * @param string $fetch Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function start($id, \Docker\API\Model\ExecStartConfig $execStartConfig, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $queryParam->setDefault('Content-Type', 'application/json');
     $queryParam->setHeaderParameters(['Content-Type']);
     $url = '/exec/{id}/start';
     $url = str_replace('{id}', urlencode($id), $url);
     $url = $url . ('?' . $queryParam->buildQueryString($parameters));
     $headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
     $body = $this->serializer->serialize($execStartConfig, 'json');
     $request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }
Beispiel #3
0
 /**
  * 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);
     $response = $this->httpClient->sendRequest($request);
     if (self::FETCH_OBJECT == $fetch) {
         if ('201' == $response->getStatusCode()) {
             return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\ContainerCreateResult', 'json');
         }
     }
     return $response;
 }
 /**
  * @param array $parameters {
  *
  *     @var string $testString
  *     @var int $testInteger
  *     @var float $testFloat
  *     @var array $testArray
  *     @var string $testRequired
  *     @var string $testDefault
  * }
  *
  * @param string $fetch Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function testHeaderParameters($parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $queryParam->setDefault('testString', null);
     $queryParam->setHeaderParameters(['testString']);
     $queryParam->setDefault('testInteger', null);
     $queryParam->setHeaderParameters(['testInteger']);
     $queryParam->setDefault('testFloat', null);
     $queryParam->setHeaderParameters(['testFloat']);
     $queryParam->setDefault('testArray', null);
     $queryParam->setHeaderParameters(['testArray']);
     $queryParam->setRequired('testRequired');
     $queryParam->setHeaderParameters(['testRequired']);
     $queryParam->setDefault('testDefault', 'test');
     $queryParam->setHeaderParameters(['testDefault']);
     $url = '/test-header';
     $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);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }
Beispiel #5
0
 /**
  * Push the image name on the registry.
  *
  * @param string $name       Image name or id
  * @param array  $parameters {
  *
  *     @var string $tag The tag to associate with the image on the registry.
  *     @var string $X-Registry-Auth A base64-encoded AuthConfig object
  * }
  *
  * @param string $fetch Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function push($name, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $queryParam->setDefault('tag', null);
     $queryParam->setRequired('X-Registry-Auth');
     $queryParam->setHeaderParameters(['X-Registry-Auth']);
     $url = '/images/{name}/push';
     $url = str_replace('{name}', urlencode($name), $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);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }