/** * {@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; }
/** * 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 List of parameters * * (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}', $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; }
/** * Create a container. * * @param \Docker\API\Model\ContainerConfig $container Container to create * @param array $parameters List of parameters * * (string)name: Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+. * (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($response->getBody()->getContents(), 'Docker\\API\\Model\\ContainerCreateResult', 'json'); } } return $response; }
/** * Push the image name on the registry. * * @param string $name Image name or id * @param array $parameters List of parameters * * (string)tag: The tag to associate with the image on the registry. * (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}', $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; }