Example #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;
 }
 /**
  * @param array  $testObjectList
  * @param array  $parameters     List of parameters
  * @param string $fetch          Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function testObjectListBodyParameter(array $testObjectList, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/test-object-list';
     $url = $url . ('?' . $queryParam->buildQueryString($parameters));
     $headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
     $body = $testObjectList;
     $request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }
 /**
  * @param array  $parameters List of parameters
  * @param string $fetch      Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function testReferenceResponse($parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/test-query';
     $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;
 }
 /**
  * @param array  $parameters List of parameters
  * @param string $fetch      Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface|\Joli\Jane\OpenApi\Tests\Expected\Model\Schema[]
  */
 public function getTestList($parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/test-list';
     $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);
     if (self::FETCH_OBJECT == $fetch) {
         if ('200' == $response->getStatusCode()) {
             return $this->serializer->deserialize($response->getBody()->getContents(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Schema[]', 'json');
         }
     }
     return $response;
 }
 /**
  * Retrieves a person and company by email address.
  *
  * @param array  $parameters {
  *     @var string $email the person's email address
  * }
  * @param string $fetch      Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface|\Clearbit\Generated\Model\Combined
  */
 public function getCombined($parameters = array(), $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $queryParam->setRequired('email');
     $url = '/v2/combined/find';
     $url = $url . ('?' . $queryParam->buildQueryString($parameters));
     $headers = array_merge(array('Host' => 'person.clearbit.com'), $queryParam->buildHeaders($parameters));
     $body = $queryParam->buildFormDataString($parameters);
     $request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     if (self::FETCH_OBJECT == $fetch) {
         if ('200' == $response->getStatusCode()) {
             return $this->serializer->deserialize((string) $response->getBody(), 'Clearbit\\Generated\\Model\\Combined', 'json');
         }
     }
     return $response;
 }
 /**
  * Retrieves a person and company by email address.
  *
  * @param array  $parameters {
  *     @var string $email the person's email address
  * }
  * @param string $fetch      Fetch mode (object or response)
  * @param array  $options
  *
  * @return \Psr\Http\Message\ResponseInterface|\Clearbit\Generated\Model\Combined
  */
 public function getCombined($parameters = [], $fetch = self::FETCH_OBJECT, $options = [])
 {
     $queryParam = new QueryParam();
     $queryParam->setRequired('email');
     $options = array_merge(['scheme' => 'https', 'host' => 'person.clearbit.com', 'path' => '/v2/combined/find'], $options);
     $url = sprintf('%s://%s%s?%s', $options['scheme'], $options['host'], $options['path'], $queryParam->buildQueryString($parameters));
     $headers = array_merge(['Host' => $options['host']], $queryParam->buildHeaders($parameters));
     $body = $queryParam->buildFormDataString($parameters);
     $request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     $statusCode = $response->getStatusCode();
     switch (true) {
         case 202 == $statusCode:
             throw new Exception\AsyncLookingException();
         case 404 == $statusCode:
             throw new Exception\NotFoundException();
         case 200 != $statusCode:
             throw new Exception\BadResponseException($response);
     }
     if (self::FETCH_OBJECT == $fetch) {
         return $this->serializer->deserialize($response->getBody()->getContents(), 'Clearbit\\Generated\\Model\\Combined', 'json');
     }
     return $response;
 }
Example #7
0
 /**
  * {@inheritdoc}
  *
  * @return \Psr\Http\Message\ResponseInterface|AttachWebsocketStream
  */
 public function attachWebsocket($id, $parameters = [], $fetch = self::FETCH_STREAM)
 {
     $queryParam = new QueryParam();
     $queryParam->setDefault('logs', null);
     $queryParam->setDefault('stream', null);
     $queryParam->setDefault('stdin', null);
     $queryParam->setDefault('stdout', null);
     $queryParam->setDefault('stderr', null);
     $url = '/containers/{id}/attach/ws';
     $url = str_replace('{id}', $id, $url);
     $url = $url . ('?' . $queryParam->buildQueryString($parameters));
     $headers = array_merge(['Host' => 'localhost', 'Origin' => 'php://docker-php', 'Upgrade' => 'websocket', 'Connection' => 'Upgrade', 'Sec-WebSocket-Version' => '13', 'Sec-WebSocket-Key' => base64_encode(uniqid())], $queryParam->buildHeaders($parameters));
     $body = $queryParam->buildFormDataString($parameters);
     $request = $this->messageFactory->createRequest('GET', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     if ($response->getStatusCode() == 101) {
         if ($fetch == self::FETCH_STREAM) {
             return new AttachWebsocketStream($response->getBody());
         }
     }
     return $response;
 }
Example #8
0
 /**
  * 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);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }
Example #9
0
 /**
  * Load a set of images and tags into a Docker repository. See the image tarball format for more details.
  *
  * @param string $imagesTarball Tar archive containing images
  * @param array  $parameters    List of parameters
  * @param string $fetch         Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function load($imagesTarball, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/images/load';
     $url = $url . ('?' . $queryParam->buildQueryString($parameters));
     $headers = array_merge(['Host' => 'localhost'], $queryParam->buildHeaders($parameters));
     $body = $imagesTarball;
     $request = $this->messageFactory->createRequest('POST', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }
Example #10
0
 /**
  * Inspect a volume.
  *
  * @param string $name       Volume name or id
  * @param array  $parameters List of parameters
  * @param string $fetch      Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface|\Docker\API\Model\Volume
  */
 public function find($name, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/volumes/{name}';
     $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('GET', $url, $headers, $body);
     $response = $this->httpClient->sendRequest($request);
     if (self::FETCH_OBJECT == $fetch) {
         if ('200' == $response->getStatusCode()) {
             return $this->serializer->deserialize((string) $response->getBody(), 'Docker\\API\\Model\\Volume', 'json');
         }
     }
     return $response;
 }
Example #11
0
 /**
  * Disconnect a container to a network.
  *
  * @param \Docker\API\Model\ContainerConnect $container  Container
  * @param array                              $parameters List of parameters
  * @param string                             $fetch      Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function disconnect(\Docker\API\Model\ContainerConnect $container, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/networks/{id}/disconnect';
     $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);
     return $response;
 }
Example #12
0
 /**
  * Get container events from docker, either in real time via streaming, or via polling (using since).
  *
  * @param array $parameters {
  *
  *     @var int $since Timestamp used for polling
  *     @var int $until Timestamp used for polling
  *     @var string $filters A json encoded value of the filters (a map[string][]string) to process on the event list.
  * }
  *
  * @param string $fetch Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function getEvents($parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $queryParam->setDefault('since', null);
     $queryParam->setDefault('until', null);
     $queryParam->setDefault('filters', null);
     $url = '/events';
     $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;
 }
 /**
  * @param string $testString
  * @param int    $testInteger
  * @param float  $testFloat
  * @param array  $parameters  List of parameters
  * @param string $fetch       Fetch mode (object or response)
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function testPathParameters($testString, $testInteger, $testFloat, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $queryParam = new QueryParam();
     $url = '/test-path/{testString}/{testInteger}/{testFloat}';
     $url = str_replace('{testString}', urlencode($testString), $url);
     $url = str_replace('{testInteger}', urlencode($testInteger), $url);
     $url = str_replace('{testFloat}', urlencode($testFloat), $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);
     $response = $this->httpClient->sendRequest($request);
     return $response;
 }