Exemple #1
0
        public Task CreateImageAsync(ImagesCreateParameters parameters, Stream imageStream, AuthConfig authConfig, IDictionary <string, string> headers, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            HttpMethod           httpMethod = HttpMethod.Post;
            BinaryRequestContent content    = null;

            if (imageStream != null)
            {
                content            = new BinaryRequestContent(imageStream, TarContentType);
                parameters.FromSrc = ImportFromBodySource;
            }

            IQueryString queryParameters = new QueryString <ImagesCreateParameters>(parameters);

            Dictionary <string, string> customHeaders = RegistryAuthHeaders(authConfig);

            if (headers != null)
            {
                foreach (string key in headers.Keys)
                {
                    customHeaders[key] = headers[key];
                }
            }

            return(StreamUtil.MonitorStreamForMessagesAsync(
                       this._client.MakeRequestForStreamAsync(this._client.NoErrorHandlers, httpMethod, "images/create", queryParameters, content, customHeaders, cancellationToken),
                       this._client,
                       cancellationToken,
                       progress));
        }
Exemple #2
0
 public Task GetContainerStatsAsync(string id, ContainerStatsParameters parameters, CancellationToken cancellationToken, IProgress <JSONMessage> progress)
 {
     return(StreamUtil.MonitorStreamForMessagesAsync(
                GetContainerStatsAsync(id, parameters, cancellationToken),
                this._client,
                cancellationToken,
                progress));
 }
 public Task PushImageAsync(string name, ImagePushParameters parameters, AuthConfig authConfig, IProgress <JSONMessage> progress)
 {
     return(StreamUtil.MonitorStreamForMessagesAsync(
                PushImageAsync(name, parameters, authConfig),
                this._client,
                default(CancellationToken),
                progress));
 }
Exemple #4
0
 public Task MonitorEventsAsync(ContainerEventsParameters parameters, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(StreamUtil.MonitorStreamForMessagesAsync(
                MonitorEventsAsync(parameters, cancellationToken),
                this._client,
                cancellationToken,
                progress));
 }
 public Task PullImageAsync(ImagesPullParameters parameters, AuthConfig authConfig, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(StreamUtil.MonitorStreamForMessagesAsync(
                PullImageAsync(parameters, authConfig),
                this._client,
                cancellationToken,
                progress));
 }
Exemple #6
0
        public Task MonitorEventsAsync(ContainerEventsParameters parameters, IProgress <Message> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (progress == null)
            {
                throw new ArgumentNullException(nameof(progress));
            }

            return(StreamUtil.MonitorStreamForMessagesAsync(
                       MonitorEventsAsync(parameters, cancellationToken),
                       this._client,
                       cancellationToken,
                       progress));
        }
Exemple #7
0
        public Task PushImageAsync(string name, ImagePushParameters parameters, AuthConfig authConfig, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            IQueryString queryParameters = new QueryString <ImagePushParameters>(parameters);

            return(StreamUtil.MonitorStreamForMessagesAsync(
                       this._client.MakeRequestForStreamAsync(this._client.NoErrorHandlers, HttpMethod.Post, $"images/{name}/push", queryParameters, null, RegistryAuthHeaders(authConfig), CancellationToken.None),
                       this._client,
                       cancellationToken,
                       progress));
        }
Exemple #8
0
        public Task LoadImageAsync(ImageLoadParameters parameters, Stream imageStream, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (imageStream == null)
            {
                throw new ArgumentNullException(nameof(imageStream));
            }

            BinaryRequestContent content = new BinaryRequestContent(imageStream, TarContentType);

            IQueryString queryParameters = new QueryString <ImageLoadParameters>(parameters);

            return(StreamUtil.MonitorStreamForMessagesAsync(
                       this._client.MakeRequestForStreamAsync(this._client.NoErrorHandlers, HttpMethod.Post, "images/load", queryParameters, content, cancellationToken),
                       this._client,
                       cancellationToken,
                       progress));
        }
        public Task InstallPluginAsync(PluginInstallParameters parameters, IProgress <JSONMessage> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            if (parameters.Privileges == null)
            {
                throw new ArgumentNullException(nameof(parameters.Privileges));
            }

            var data = new JsonRequestContent <IList <PluginPrivilege> >(parameters.Privileges, this._client.JsonSerializer);

            IQueryString queryParameters = new QueryString <PluginInstallParameters>(parameters);

            return(StreamUtil.MonitorStreamForMessagesAsync(
                       this._client.MakeRequestForStreamAsync(this._client.NoErrorHandlers, HttpMethod.Post, $"plugins/pull", queryParameters, data, null, CancellationToken.None),
                       this._client,
                       cancellationToken,
                       progress));
        }