diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs
new file mode 100644
index 000000000000..3b0cc40b1527
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperations.cs
@@ -0,0 +1,457 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// AccessTokensOperations operations.
+ ///
+ internal partial class AccessTokensOperations : IServiceOperations, IAccessTokensOperations
+ {
+ ///
+ /// Initializes a new instance of the AccessTokensOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal AccessTokensOperations(AzureContainerRegistryClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the AzureContainerRegistryClient
+ ///
+ public AzureContainerRegistryClient Client { get; private set; }
+
+ ///
+ /// Exchange ACR Refresh token for an ACR Access Token
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Which is expected to be a valid scope, and can be specified more than once
+ /// for multiple scope requests. You obtained this from the Www-Authenticate
+ /// response header from the challenge.
+ ///
+ ///
+ /// Must be a valid ACR refresh token
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string service, string scope, string refreshToken, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (service == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "service");
+ }
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ if (refreshToken == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "refreshToken");
+ }
+ string grantType = "refresh_token";
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("grantType", grantType);
+ tracingParameters.Add("service", service);
+ tracingParameters.Add("scope", scope);
+ tracingParameters.Add("refreshToken", refreshToken);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "oauth2/token";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ var values = new List>();
+ if(grantType != null)
+ {
+ values.Add(new KeyValuePair("grant_type", grantType));
+ }
+ if(service != null)
+ {
+ values.Add(new KeyValuePair("service", service));
+ }
+ if(scope != null)
+ {
+ values.Add(new KeyValuePair("scope", scope));
+ }
+ if(refreshToken != null)
+ {
+ values.Add(new KeyValuePair("refresh_token", refreshToken));
+ }
+ var _formContent = new FormUrlEncodedContent(values);
+ _httpRequest.Content = _formContent;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Exchange Username, Password and Scope an ACR Access Token
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Expected to be a valid scope, and can be specified more than once for
+ /// multiple scope requests. You can obtain this from the Www-Authenticate
+ /// response header from the challenge.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetFromLoginWithHttpMessagesAsync(string service, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (service == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "service");
+ }
+ if (scope == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "scope");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("service", service);
+ tracingParameters.Add("scope", scope);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetFromLogin", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "oauth2/token";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ List _queryParameters = new List();
+ if (service != null)
+ {
+ _queryParameters.Add(string.Format("service={0}", System.Uri.EscapeDataString(service)));
+ }
+ if (scope != null)
+ {
+ _queryParameters.Add(string.Format("scope={0}", System.Uri.EscapeDataString(scope)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs
new file mode 100644
index 000000000000..3420f387fd0b
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AccessTokensOperationsExtensions.cs
@@ -0,0 +1,78 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for AccessTokensOperations.
+ ///
+ public static partial class AccessTokensOperationsExtensions
+ {
+ ///
+ /// Exchange ACR Refresh token for an ACR Access Token
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Which is expected to be a valid scope, and can be specified more than once
+ /// for multiple scope requests. You obtained this from the Www-Authenticate
+ /// response header from the challenge.
+ ///
+ ///
+ /// Must be a valid ACR refresh token
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IAccessTokensOperations operations, string service, string scope, string refreshToken, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(service, scope, refreshToken, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Exchange Username, Password and Scope an ACR Access Token
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Expected to be a valid scope, and can be specified more than once for
+ /// multiple scope requests. You can obtain this from the Www-Authenticate
+ /// response header from the challenge.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetFromLoginAsync(this IAccessTokensOperations operations, string service, string scope, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetFromLoginWithHttpMessagesAsync(service, scope, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs
new file mode 100644
index 000000000000..735420bc400d
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/AzureContainerRegistryClient.cs
@@ -0,0 +1,274 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+
+ ///
+ /// Metadata API definition for the Azure Container Registry runtime
+ ///
+ public partial class AzureContainerRegistryClient : ServiceClient, IAzureContainerRegistryClient, IAzureClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ internal string BaseUri {get; set;}
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ public ServiceClientCredentials Credentials { get; private set; }
+
+ ///
+ /// Registry login URL
+ ///
+ public string LoginUri { get; set; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default value is
+ /// 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When set to
+ /// true a unique x-ms-client-request-id value is generated and included in
+ /// each request. Default is true.
+ ///
+ public bool? GenerateClientRequestId { get; set; }
+
+ ///
+ /// Gets the IV2SupportOperations.
+ ///
+ public virtual IV2SupportOperations V2Support { get; private set; }
+
+ ///
+ /// Gets the IManifestsOperations.
+ ///
+ public virtual IManifestsOperations Manifests { get; private set; }
+
+ ///
+ /// Gets the IBlobOperations.
+ ///
+ public virtual IBlobOperations Blob { get; private set; }
+
+ ///
+ /// Gets the IRepositoryOperations.
+ ///
+ public virtual IRepositoryOperations Repository { get; private set; }
+
+ ///
+ /// Gets the ITagOperations.
+ ///
+ public virtual ITagOperations Tag { get; private set; }
+
+ ///
+ /// Gets the IRefreshTokensOperations.
+ ///
+ public virtual IRefreshTokensOperations RefreshTokens { get; private set; }
+
+ ///
+ /// Gets the IAccessTokensOperations.
+ ///
+ public virtual IAccessTokensOperations AccessTokens { get; private set; }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling AzureContainerRegistryClient.Dispose(). False: will not dispose provided httpClient
+ protected AzureContainerRegistryClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected AzureContainerRegistryClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected AzureContainerRegistryClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureContainerRegistryClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling AzureContainerRegistryClient.Dispose(). False: will not dispose provided httpClient
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureContainerRegistryClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the AzureContainerRegistryClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureContainerRegistryClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ V2Support = new V2SupportOperations(this);
+ Manifests = new ManifestsOperations(this);
+ Blob = new BlobOperations(this);
+ Repository = new RepositoryOperations(this);
+ Tag = new TagOperations(this);
+ RefreshTokens = new RefreshTokensOperations(this);
+ AccessTokens = new AccessTokensOperations(this);
+ BaseUri = "{url}";
+ AcceptLanguage = "en-US";
+ LongRunningOperationRetryTimeout = 30;
+ GenerateClientRequestId = true;
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
+ }
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs
new file mode 100644
index 000000000000..3092d0aa255a
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperations.cs
@@ -0,0 +1,2059 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// BlobOperations operations.
+ ///
+ internal partial class BlobOperations : IServiceOperations, IBlobOperations
+ {
+ ///
+ /// Initializes a new instance of the BlobOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal BlobOperations(AzureContainerRegistryClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the AzureContainerRegistryClient
+ ///
+ public AzureContainerRegistryClient Client { get; private set; }
+
+ ///
+ /// Retrieve the blob from the registry identified by digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 307)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Check", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 307)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Removes an already uploaded blob.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> DeleteWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 202)
+ {
+ _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Mount a blob identified by the `mount` parameter from another repository.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Name of the source repository.
+ ///
+ ///
+ /// Digest of blob to mount from the source repository.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> MountWithHttpMessagesAsync(string name, string fromParameter, string mount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (fromParameter == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "fromParameter");
+ }
+ if (mount == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "mount");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("fromParameter", fromParameter);
+ tracingParameters.Add("mount", mount);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Mount", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/uploads/";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ List _queryParameters = new List();
+ if (fromParameter != null)
+ {
+ _queryParameters.Add(string.Format("from={0}", System.Uri.EscapeDataString(fromParameter)));
+ }
+ if (mount != null)
+ {
+ _queryParameters.Add(string.Format("mount={0}", System.Uri.EscapeDataString(mount)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 201)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Retrieve status of upload identified by uuid. The primary purpose of this
+ /// endpoint is to resolve the current status of a resumable upload.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetStatusWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (location == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "location");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("location", location);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetStatus", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Upload a stream of data without completing the upload.
+ ///
+ ///
+ /// Raw data of blob
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> UploadWithHttpMessagesAsync(Stream value, string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (value == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "value");
+ }
+ if (location == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "location");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("value", value);
+ tracingParameters.Add("location", location);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Upload", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PATCH");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(value == null)
+ {
+ throw new System.ArgumentNullException("value");
+ }
+ if (value != null && value != Stream.Null)
+ {
+ _httpRequest.Content = new StreamContent(value);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Complete the upload, providing all the data in the body, if necessary. A
+ /// request without a body will just complete the upload with previously
+ /// uploaded content.
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// Optional raw data of blob
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> EndUploadWithHttpMessagesAsync(string digest, string location, Stream value = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ if (location == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "location");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("value", value);
+ tracingParameters.Add("location", location);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "EndUpload", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
+ List _queryParameters = new List();
+ if (digest != null)
+ {
+ _queryParameters.Add(string.Format("digest={0}", System.Uri.EscapeDataString(digest)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if (value != null && value != Stream.Null)
+ {
+ _httpRequest.Content = new StreamContent(value);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 201)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Cancel outstanding upload processes, releasing associated resources. If
+ /// this is not called, the unfinished uploads will eventually timeout.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task CancelUploadWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (location == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "location");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("location", location);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CancelUpload", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "{nextBlobUuidLink}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace(location.StartsWith("/") ? "/{nextBlobUuidLink}" : "{nextBlobUuidLink}", location);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Initiate a resumable blob upload with an empty request body.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> StartUploadWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "StartUpload", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/uploads/";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Retrieve the blob from the registry identified by `digest`. This endpoint
+ /// may also support RFC7233 compliant range requests. Support can be detected
+ /// by issuing a HEAD request. If the header `Accept-Range: bytes` is returned,
+ /// range requests can be used to fetch partial content.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header specifying
+ /// blob chunk.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ if (range == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "range");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("range", range);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetChunk", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (range != null)
+ {
+ if (_httpRequest.Headers.Contains("Range"))
+ {
+ _httpRequest.Headers.Remove("Range");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Range", range);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 206)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 206)
+ {
+ _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header specifying
+ /// blob chunk.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (digest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "digest");
+ }
+ if (range == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "range");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("digest", digest);
+ tracingParameters.Add("range", range);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckChunk", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/blobs/{digest}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{digest}", System.Uri.EscapeDataString(digest));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (range != null)
+ {
+ if (_httpRequest.Headers.Contains("Range"))
+ {
+ _httpRequest.Headers.Remove("Range");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Range", range);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs
new file mode 100644
index 000000000000..f93a84318eac
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/BlobOperationsExtensions.cs
@@ -0,0 +1,289 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.IO;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for BlobOperations.
+ ///
+ public static partial class BlobOperationsExtensions
+ {
+ ///
+ /// Retrieve the blob from the registry identified by digest.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var _result = await operations.GetWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false);
+ _result.Request.Dispose();
+ return _result.Body;
+ }
+
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Removes an already uploaded blob.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IBlobOperations operations, string name, string digest, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var _result = await operations.DeleteWithHttpMessagesAsync(name, digest, null, cancellationToken).ConfigureAwait(false);
+ _result.Request.Dispose();
+ return _result.Body;
+ }
+
+ ///
+ /// Mount a blob identified by the `mount` parameter from another repository.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Name of the source repository.
+ ///
+ ///
+ /// Digest of blob to mount from the source repository.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task MountAsync(this IBlobOperations operations, string name, string fromParameter, string mount, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.MountWithHttpMessagesAsync(name, fromParameter, mount, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Retrieve status of upload identified by uuid. The primary purpose of this
+ /// endpoint is to resolve the current status of a resumable upload.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetStatusAsync(this IBlobOperations operations, string location, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetStatusWithHttpMessagesAsync(location, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Upload a stream of data without completing the upload.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Raw data of blob
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task UploadAsync(this IBlobOperations operations, Stream value, string location, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.UploadWithHttpMessagesAsync(value, location, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Complete the upload, providing all the data in the body, if necessary. A
+ /// request without a body will just complete the upload with previously
+ /// uploaded content.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// Optional raw data of blob
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task EndUploadAsync(this IBlobOperations operations, string digest, string location, Stream value = default(Stream), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.EndUploadWithHttpMessagesAsync(digest, location, value, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Cancel outstanding upload processes, releasing associated resources. If
+ /// this is not called, the unfinished uploads will eventually timeout.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not include
+ /// initial / (must do substring(1) )
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CancelUploadAsync(this IBlobOperations operations, string location, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CancelUploadWithHttpMessagesAsync(location, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Initiate a resumable blob upload with an empty request body.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task StartUploadAsync(this IBlobOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.StartUploadWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Retrieve the blob from the registry identified by `digest`. This endpoint
+ /// may also support RFC7233 compliant range requests. Support can be detected
+ /// by issuing a HEAD request. If the header `Accept-Range: bytes` is returned,
+ /// range requests can be used to fetch partial content.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header specifying
+ /// blob chunk.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetChunkAsync(this IBlobOperations operations, string name, string digest, string range, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var _result = await operations.GetChunkWithHttpMessagesAsync(name, digest, range, null, cancellationToken).ConfigureAwait(false);
+ _result.Request.Dispose();
+ return _result.Body;
+ }
+
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header specifying
+ /// blob chunk.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckChunkAsync(this IBlobOperations operations, string name, string digest, string range, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckChunkWithHttpMessagesAsync(name, digest, range, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs
new file mode 100644
index 000000000000..b6adbea754f5
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAccessTokensOperations.cs
@@ -0,0 +1,84 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// AccessTokensOperations operations.
+ ///
+ public partial interface IAccessTokensOperations
+ {
+ ///
+ /// Exchange ACR Refresh token for an ACR Access Token
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Which is expected to be a valid scope, and can be specified more
+ /// than once for multiple scope requests. You obtained this from the
+ /// Www-Authenticate response header from the challenge.
+ ///
+ ///
+ /// Must be a valid ACR refresh token
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string service, string scope, string refreshToken, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Exchange Username, Password and Scope an ACR Access Token
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// Expected to be a valid scope, and can be specified more than once
+ /// for multiple scope requests. You can obtain this from the
+ /// Www-Authenticate response header from the challenge.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetFromLoginWithHttpMessagesAsync(string service, string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs
new file mode 100644
index 000000000000..aa7ce06fa71c
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IAzureContainerRegistryClient.cs
@@ -0,0 +1,102 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ /// Metadata API definition for the Azure Container Registry runtime
+ ///
+ public partial interface IAzureContainerRegistryClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ ServiceClientCredentials Credentials { get; }
+
+ ///
+ /// Registry login URL
+ ///
+ string LoginUri { get; set; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default
+ /// value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When
+ /// set to true a unique x-ms-client-request-id value is generated and
+ /// included in each request. Default is true.
+ ///
+ bool? GenerateClientRequestId { get; set; }
+
+
+ ///
+ /// Gets the IV2SupportOperations.
+ ///
+ IV2SupportOperations V2Support { get; }
+
+ ///
+ /// Gets the IManifestsOperations.
+ ///
+ IManifestsOperations Manifests { get; }
+
+ ///
+ /// Gets the IBlobOperations.
+ ///
+ IBlobOperations Blob { get; }
+
+ ///
+ /// Gets the IRepositoryOperations.
+ ///
+ IRepositoryOperations Repository { get; }
+
+ ///
+ /// Gets the ITagOperations.
+ ///
+ ITagOperations Tag { get; }
+
+ ///
+ /// Gets the IRefreshTokensOperations.
+ ///
+ IRefreshTokensOperations RefreshTokens { get; }
+
+ ///
+ /// Gets the IAccessTokensOperations.
+ ///
+ IAccessTokensOperations AccessTokens { get; }
+
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs
new file mode 100644
index 000000000000..31215937a9c5
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IBlobOperations.cs
@@ -0,0 +1,299 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// BlobOperations operations.
+ ///
+ public partial interface IBlobOperations
+ {
+ ///
+ /// Retrieve the blob from the registry identified by digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CheckWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Removes an already uploaded blob.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> DeleteWithHttpMessagesAsync(string name, string digest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Mount a blob identified by the `mount` parameter from another
+ /// repository.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Name of the source repository.
+ ///
+ ///
+ /// Digest of blob to mount from the source repository.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> MountWithHttpMessagesAsync(string name, string fromParameter, string mount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve status of upload identified by uuid. The primary purpose
+ /// of this endpoint is to resolve the current status of a resumable
+ /// upload.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not
+ /// include initial / (must do substring(1) )
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetStatusWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Upload a stream of data without completing the upload.
+ ///
+ ///
+ /// Raw data of blob
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not
+ /// include initial / (must do substring(1) )
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> UploadWithHttpMessagesAsync(Stream value, string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Complete the upload, providing all the data in the body, if
+ /// necessary. A request without a body will just complete the upload
+ /// with previously uploaded content.
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not
+ /// include initial / (must do substring(1) )
+ ///
+ ///
+ /// Optional raw data of blob
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> EndUploadWithHttpMessagesAsync(string digest, string location, Stream value = default(Stream), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Cancel outstanding upload processes, releasing associated
+ /// resources. If this is not called, the unfinished uploads will
+ /// eventually timeout.
+ ///
+ ///
+ /// Link acquired from upload start or previous chunk. Note, do not
+ /// include initial / (must do substring(1) )
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task CancelUploadWithHttpMessagesAsync(string location, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Initiate a resumable blob upload with an empty request body.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> StartUploadWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Retrieve the blob from the registry identified by `digest`. This
+ /// endpoint may also support RFC7233 compliant range requests. Support
+ /// can be detected by issuing a HEAD request. If the header
+ /// `Accept-Range: bytes` is returned, range requests can be used to
+ /// fetch partial content.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header
+ /// specifying blob chunk.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Same as GET, except only the headers are returned.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Digest of a BLOB
+ ///
+ ///
+ /// Format : bytes=<start>-<end>, HTTP Range header
+ /// specifying blob chunk.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CheckChunkWithHttpMessagesAsync(string name, string digest, string range, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs
new file mode 100644
index 000000000000..44fca65b9fed
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IManifestsOperations.cs
@@ -0,0 +1,191 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManifestsOperations operations.
+ ///
+ public partial interface IManifestsOperations
+ {
+ ///
+ /// Get the manifest identified by `name` and `reference` where
+ /// `reference` can be a tag or digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// Accept header string delimited by comma. For example,
+ /// application/vnd.docker.distribution.manifest.v2+json
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string name, string reference, string accept = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Put the manifest identified by `name` and `reference` where
+ /// `reference` can be a tag or digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// Manifest body, can take v1 or v2 values depending on accept header
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CreateWithHttpMessagesAsync(string name, string reference, Manifest payload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Delete the manifest identified by `name` and `reference`. Note that
+ /// a manifest can _only_ be deleted by `digest`.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// List manifests of a repository
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Query parameter for the last item in previous query. Result set
+ /// will include values lexically after last.
+ ///
+ ///
+ /// query parameter for max number of items
+ ///
+ ///
+ /// orderby query parameter
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetListWithHttpMessagesAsync(string name, string last = default(string), int? n = default(int?), string orderby = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Get manifest attributes
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetAttributesWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Update attributes of a manifest
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// Manifest attribute value
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task UpdateAttributesWithHttpMessagesAsync(string name, string reference, ManifestChangeableAttributes value = default(ManifestChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs
new file mode 100644
index 000000000000..d9888da30e89
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRefreshTokensOperations.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// RefreshTokensOperations operations.
+ ///
+ public partial interface IRefreshTokensOperations
+ {
+ ///
+ /// Exchange AAD tokens for an ACR refresh Token
+ ///
+ ///
+ /// Can take a value of access_token_refresh_token, or access_token, or
+ /// refresh_token. Possible values include:
+ /// 'access_token_refresh_token', 'access_token', 'refresh_token'
+ ///
+ ///
+ /// Indicates the name of your Azure container registry.
+ ///
+ ///
+ /// AAD tenant associated to the AAD credentials.
+ ///
+ ///
+ /// AAD refresh token, mandatory when grant_type is
+ /// access_token_refresh_token or refresh_token
+ ///
+ ///
+ /// AAD access token, mandatory when grant_type is
+ /// access_token_refresh_token or access_token.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetFromExchangeWithHttpMessagesAsync(string grantType, string service, string tenant = default(string), string refreshToken = default(string), string accessToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs
new file mode 100644
index 000000000000..ef7b09999f70
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IRepositoryOperations.cs
@@ -0,0 +1,120 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// RepositoryOperations operations.
+ ///
+ public partial interface IRepositoryOperations
+ {
+ ///
+ /// List repositories
+ ///
+ ///
+ /// Query parameter for the last item in previous query. Result set
+ /// will include values lexically after last.
+ ///
+ ///
+ /// query parameter for max number of items
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetListWithHttpMessagesAsync(string last = default(string), int? n = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Get repository attributes
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetAttributesWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Delete the repository identified by `name`
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> DeleteWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Update the attribute identified by `name` where `reference` is the
+ /// name of the repository.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Repository attribute value
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task UpdateAttributesWithHttpMessagesAsync(string name, RepositoryChangeableAttributes value = default(RepositoryChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs
new file mode 100644
index 000000000000..13ef06e592f6
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ITagOperations.cs
@@ -0,0 +1,134 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// TagOperations operations.
+ ///
+ public partial interface ITagOperations
+ {
+ ///
+ /// List tags of a repository
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Query parameter for the last item in previous query. Result set
+ /// will include values lexically after last.
+ ///
+ ///
+ /// query parameter for max number of items
+ ///
+ ///
+ /// orderby query parameter
+ ///
+ ///
+ /// filter by digest
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetListWithHttpMessagesAsync(string name, string last = default(string), int? n = default(int?), string orderby = default(string), string digest = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Get tag attributes by tag
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Tag name
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetAttributesWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Update tag attributes
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Tag name
+ ///
+ ///
+ /// Tag attribute value
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task UpdateAttributesWithHttpMessagesAsync(string name, string reference, TagChangeableAttributes value = default(TagChangeableAttributes), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Delete tag
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// Tag name
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string name, string reference, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs
new file mode 100644
index 000000000000..3ed6177c7667
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/IV2SupportOperations.cs
@@ -0,0 +1,44 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// V2SupportOperations operations.
+ ///
+ public partial interface IV2SupportOperations
+ {
+ ///
+ /// Tells whether this Docker Registry instance supports Docker
+ /// Registry HTTP API v2
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task CheckWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs
new file mode 100644
index 000000000000..4ba1d2503999
--- /dev/null
+++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperations.cs
@@ -0,0 +1,1179 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.ContainerRegistry
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManifestsOperations operations.
+ ///
+ internal partial class ManifestsOperations : IServiceOperations, IManifestsOperations
+ {
+ ///
+ /// Initializes a new instance of the ManifestsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal ManifestsOperations(AzureContainerRegistryClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the AzureContainerRegistryClient
+ ///
+ public AzureContainerRegistryClient Client { get; private set; }
+
+ ///
+ /// Get the manifest identified by `name` and `reference` where `reference` can
+ /// be a tag or digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// Accept header string delimited by comma. For example,
+ /// application/vnd.docker.distribution.manifest.v2+json
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string name, string reference, string accept = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (reference == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "reference");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("reference", reference);
+ tracingParameters.Add("accept", accept);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/manifests/{reference}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (accept != null)
+ {
+ if (_httpRequest.Headers.Contains("accept"))
+ {
+ _httpRequest.Headers.Remove("accept");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept", accept);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Put the manifest identified by `name` and `reference` where `reference` can
+ /// be a tag or digest.
+ ///
+ ///
+ /// Name of the image (including the namespace)
+ ///
+ ///
+ /// A tag or a digest, pointing to a specific image
+ ///
+ ///
+ /// Manifest body, can take v1 or v2 values depending on accept header
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CreateWithHttpMessagesAsync(string name, string reference, Manifest payload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.LoginUri == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
+ }
+ if (name == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "name");
+ }
+ if (reference == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "reference");
+ }
+ if (payload == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "payload");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("reference", reference);
+ tracingParameters.Add("payload", payload);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/{name}/manifests/{reference}";
+ _url = _url.Replace("{url}", Client.LoginUri);
+ _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
+ _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(payload != null)
+ {
+ _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(payload, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/vnd.docker.distribution.manifest.v2+json");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 201)
+ {
+ var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ AcrErrors _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse