public Task AuthenticateAsync(AuthConfigParameters authConfig)
        {
            if (authConfig == null)
            {
                throw new ArgumentNullException(nameof(authConfig));
            }
            var data = new JsonRequestContent <AuthConfigParameters>(authConfig, this.Client.JsonSerializer);

            return(this.Client.MakeRequestAsync(this.Client.NoErrorHandlers, HttpMethod.Post, "auth", null, data));
        }
        public Task <Stream> CreateImageAsync(ImagesCreateParameters parameters, AuthConfigParameters authConfig)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            string path = "images/create";
            Dictionary <string, string> headers = authConfig == null ? null : RegistryAuthHeaders(authConfig);
            IQueryString queryParameters        = new QueryString <ImagesCreateParameters>(parameters);

            return(this.Client.MakeRequestForStreamAsync(this.Client.NoErrorHandlers, HttpMethod.Post, path, queryParameters, headers, null, CancellationToken.None));
        }
        private Dictionary <string, string> RegistryAuthHeaders(AuthConfigParameters authConfig)
        {
            if (authConfig == null)
            {
                throw new ArgumentNullException("authConfig");
            }

            return(new Dictionary <string, string>
            {
                {
                    RegistryAuthHeaderKey,
                    Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Client.JsonSerializer.SerializeObject(authConfig)))
                }
            });
        }
        public Task <Stream> PushImageAsync(string name, ImagePushParameters parameters, AuthConfigParameters authConfig)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

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

            if (authConfig == null)
            {
                throw new ArgumentNullException("authConfig");
            }

            string       path            = string.Format(CultureInfo.InvariantCulture, "images/{0}/push", name);
            IQueryString queryParameters = new QueryString <ImagePushParameters>(parameters);

            return(this.Client.MakeRequestForStreamAsync(this.Client.NoErrorHandlers, HttpMethod.Post, path, queryParameters, RegistryAuthHeaders(authConfig), null, CancellationToken.None));
        }