public Task AuthenticateAsync(AuthConfig authConfig) { if (authConfig == null) { throw new ArgumentNullException("authConfig"); } var data = new JsonRequestContent<AuthConfig>(authConfig, this.Client.JsonSerializer); const string path = "auth"; return this.Client.MakeRequestAsync(this.Client.NoErrorHandlers, HttpMethod.Post, path, null, data); }
// StartContainerExecAsync will start the process specified by id in detach mode with no connected // stdin, stdout, or stderr pipes. public Task StartContainerExecAsync(string id, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } var parameters = new ContainerExecStartParameters { Detach = true, }; var data = new JsonRequestContent <ContainerExecStartParameters>(parameters, this._client.JsonSerializer); return(this._client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"exec/{id}/start", null, data, cancellationToken)); }
public async Task <ContainerExecCreateResponse> ExecCreateContainerAsync(string id, ContainerExecCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } var data = new JsonRequestContent <ContainerExecCreateParameters>(parameters, this._client.JsonSerializer); var response = await this._client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"containers/{id}/exec", null, data, cancellationToken).ConfigureAwait(false); return(this._client.JsonSerializer.DeserializeObject <ContainerExecCreateResponse>(response.Body)); }
public async Task <MultiplexedStream> StartWithConfigContainerExecAsync(string id, ContainerExecStartParameters eConfig, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } var data = new JsonRequestContent <ContainerExecStartParameters>(eConfig, this._client.JsonSerializer); var stream = await this._client.MakeRequestForHijackedStreamAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, $"exec/{id}/start", null, data, null, cancellationToken).ConfigureAwait(false); if (!stream.CanCloseWrite) { stream.Dispose(); throw new NotSupportedException("Cannot shutdown write on this transport"); } return(new MultiplexedStream(stream, !eConfig.Tty)); }
public async Task<CreateContainerResponse> CreateContainerAsync(CreateContainerParameters parameters) { IQueryString qs = null; if (parameters == null) { throw new ArgumentNullException("parameters"); } if (!string.IsNullOrEmpty(parameters.ContainerName)) { qs = new QueryString<CreateContainerParameters>(parameters); } string path = "containers/create"; JsonRequestContent<Config> data = null; if (parameters.Config != null) { data = new JsonRequestContent<Config>(parameters.Config, this.Client.JsonSerializer); } DockerApiResponse response = await this.Client.MakeRequestAsync(new[] {NoSuchContainerHandler}, HttpMethod.Post, path, qs, data); return this.Client.JsonSerializer.DeserializeObject<CreateContainerResponse>(response.Body); }
public Task<Stream> CopyFromContainerAsync(string id, CopyFromContainerParameters parameters, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } // Extra check for this field since it's required and API behaves and just returns // HTTP 500 Internal Server Error with response body as "EOF" which makes hard to debug. if (string.IsNullOrEmpty(parameters.Resource)) { throw new ArgumentException("ResourcePath is empty", "parameters"); } var data = new JsonRequestContent<CopyFromContainerParameters>(parameters, this.Client.JsonSerializer); string path = string.Format(CultureInfo.InvariantCulture, "containers/{0}/copy", id); return this.Client.MakeRequestForStreamAsync(new[] {NoSuchContainerHandler}, HttpMethod.Post, path, null, data, cancellationToken); }
public async Task<ExecCreateContainerResponse> ExecCreateContainerAsync(string id, ExecCreateContainerParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } string path = string.Format(CultureInfo.InvariantCulture, "containers/{0}/exec", id); JsonRequestContent<ExecCreateContainerConfig> data = null; if (parameters.Config != null) { data = new JsonRequestContent<ExecCreateContainerConfig>(parameters.Config, this.Client.JsonSerializer); } DockerApiResponse response = await this.Client.MakeRequestAsync(new[] { NoSuchContainerHandler }, HttpMethod.Post, path, null, data); return this.Client.JsonSerializer.DeserializeObject<ExecCreateContainerResponse>(response.Body); }
public async Task<bool> StartContainerAsync(string id, HostConfig hostConfig) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException("id"); } string path = string.Format(CultureInfo.InvariantCulture, "containers/{0}/start", id); JsonRequestContent<HostConfig> data = null; if (hostConfig != null) { data = new JsonRequestContent<HostConfig>(hostConfig, this.Client.JsonSerializer); } DockerApiResponse response = await this.Client.MakeRequestAsync(new[] {NoSuchContainerHandler}, HttpMethod.Post, path, null, data); return response.StatusCode != HttpStatusCode.NotModified; }