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(); + _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 == 201) + { + _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); + } + } + 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; + } + + /// + /// 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 + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string name, string reference, 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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("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 != 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 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; + } + + /// + /// 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 + /// + /// + /// 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> GetListWithHttpMessagesAsync(string name, string last = default(string), int? n = default(int?), string orderby = 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"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("name", name); + tracingParameters.Add("last", last); + tracingParameters.Add("n", n); + tracingParameters.Add("orderby", orderby); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetList", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_manifests"; + _url = _url.Replace("{url}", Client.LoginUri); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (last != null) + { + _queryParameters.Add(string.Format("last={0}", System.Uri.EscapeDataString(last))); + } + if (n != null) + { + _queryParameters.Add(string.Format("n={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(n, Client.SerializationSettings).Trim('"')))); + } + if (orderby != null) + { + _queryParameters.Add(string.Format("orderby={0}", System.Uri.EscapeDataString(orderby))); + } + 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; + } + + /// + /// Get manifest attributes + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// A tag or a digest, pointing to a specific image + /// + /// + /// 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> GetAttributesWithHttpMessagesAsync(string name, string reference, 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{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 (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; + } + + /// + /// 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 + /// + /// + /// 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 UpdateAttributesWithHttpMessagesAsync(string name, string reference, ManifestChangeableAttributes value = default(ManifestChangeableAttributes), 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("value", value); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{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("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) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(value, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperationsExtensions.cs new file mode 100644 index 000000000000..264fdf54df41 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/ManifestsOperationsExtensions.cs @@ -0,0 +1,177 @@ +// +// 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 ManifestsOperations. + /// + public static partial class ManifestsOperationsExtensions + { + /// + /// Get the manifest identified by `name` and `reference` where `reference` can + /// be a tag or digest. + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task GetAsync(this IManifestsOperations operations, string name, string reference, string accept = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(name, reference, accept, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Put the manifest identified by `name` and `reference` where `reference` can + /// be a tag or digest. + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task CreateAsync(this IManifestsOperations operations, string name, string reference, Manifest payload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(name, reference, payload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete the manifest identified by `name` and `reference`. Note that a + /// manifest can _only_ be deleted by `digest`. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// A tag or a digest, pointing to a specific image + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IManifestsOperations operations, string name, string reference, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(name, reference, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List manifests of a repository + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task GetListAsync(this IManifestsOperations operations, string name, string last = default(string), int? n = default(int?), string orderby = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetListWithHttpMessagesAsync(name, last, n, orderby, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get manifest attributes + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// A tag or a digest, pointing to a specific image + /// + /// + /// The cancellation token. + /// + public static async Task GetAttributesAsync(this IManifestsOperations operations, string name, string reference, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAttributesWithHttpMessagesAsync(name, reference, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update attributes of a manifest + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// A tag or a digest, pointing to a specific image + /// + /// + /// Manifest attribute value + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAttributesAsync(this IManifestsOperations operations, string name, string reference, ManifestChangeableAttributes value = default(ManifestChangeableAttributes), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateAttributesWithHttpMessagesAsync(name, reference, value, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AccessToken.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AccessToken.cs new file mode 100644 index 000000000000..1a9b802395d1 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AccessToken.cs @@ -0,0 +1,49 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class AccessToken + { + /// + /// Initializes a new instance of the AccessToken class. + /// + public AccessToken() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AccessToken class. + /// + /// The access token for performing + /// authenticated requests + public AccessToken(string accessTokenProperty = default(string)) + { + AccessTokenProperty = accessTokenProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the access token for performing authenticated requests + /// + [JsonProperty(PropertyName = "access_token")] + public string AccessTokenProperty { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorInfo.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorInfo.cs new file mode 100644 index 000000000000..74d3709422de --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorInfo.cs @@ -0,0 +1,67 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error information + /// + public partial class AcrErrorInfo + { + /// + /// Initializes a new instance of the AcrErrorInfo class. + /// + public AcrErrorInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcrErrorInfo class. + /// + /// Error code + /// Error message + /// Error details + public AcrErrorInfo(string code = default(string), string message = default(string), object detail = default(object)) + { + Code = code; + Message = message; + Detail = detail; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets error details + /// + [JsonProperty(PropertyName = "detail")] + public object Detail { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrors.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrors.cs new file mode 100644 index 000000000000..0c035662f173 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrors.cs @@ -0,0 +1,53 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Acr error response describing why the operation failed + /// + public partial class AcrErrors + { + /// + /// Initializes a new instance of the AcrErrors class. + /// + public AcrErrors() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcrErrors class. + /// + /// Array of detailed error + public AcrErrors(IList errors = default(IList)) + { + Errors = errors; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets array of detailed error + /// + [JsonProperty(PropertyName = "errors")] + public IList Errors { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorsException.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorsException.cs new file mode 100644 index 000000000000..db218b173193 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrErrorsException.cs @@ -0,0 +1,61 @@ +// +// 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.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with AcrErrors information. + /// + public partial class AcrErrorsException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public AcrErrors Body { get; set; } + + /// + /// Initializes a new instance of the AcrErrorsException class. + /// + public AcrErrorsException() + { + } + + /// + /// Initializes a new instance of the AcrErrorsException class. + /// + /// The exception message. + public AcrErrorsException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the AcrErrorsException class. + /// + /// The exception message. + /// Inner exception. + public AcrErrorsException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrManifests.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrManifests.cs new file mode 100644 index 000000000000..514ace827abc --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/AcrManifests.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Manifest attributes + /// + public partial class AcrManifests + { + /// + /// Initializes a new instance of the AcrManifests class. + /// + public AcrManifests() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AcrManifests class. + /// + /// Registry name + /// Image name + /// List of manifests + public AcrManifests(string registry = default(string), string imageName = default(string), IList manifestsAttributes = default(IList)) + { + Registry = registry; + ImageName = imageName; + ManifestsAttributes = manifestsAttributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets registry name + /// + [JsonProperty(PropertyName = "registry")] + public string Registry { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; set; } + + /// + /// Gets or sets list of manifests + /// + [JsonProperty(PropertyName = "manifests")] + public IList ManifestsAttributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Annotations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Annotations.cs new file mode 100644 index 000000000000..299f50cfe481 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Annotations.cs @@ -0,0 +1,172 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Additional information provided through arbitrary metadata. + /// + public partial class Annotations + { + /// + /// Initializes a new instance of the Annotations class. + /// + public Annotations() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Annotations class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// Date and time on which the image was built + /// (string, date-time as defined by + /// https://tools.ietf.org/html/rfc3339#section-5.6) + /// Contact details of the people or organization + /// responsible for the image. + /// URL to find more information on the + /// image. + /// URL to get documentation on the + /// image. + /// URL to get source code for building the + /// image. + /// Version of the packaged software. The version + /// MAY match a label or tag in the source code repository, may also be + /// Semantic versioning-compatible + /// Source control revision identifier for the + /// packaged software. + /// Name of the distributing entity, organization + /// or individual. + /// License(s) under which contained software is + /// distributed as an SPDX License Expression. + /// Name of the reference for a target. + /// Human-readable title of the image + /// Human-readable description of the + /// software packaged in the image + public Annotations(IDictionary additionalProperties = default(IDictionary), System.DateTime? created = default(System.DateTime?), string authors = default(string), string url = default(string), string documentation = default(string), string source = default(string), string version = default(string), string revision = default(string), string vendor = default(string), string licenses = default(string), string name = default(string), string title = default(string), string description = default(string)) + { + AdditionalProperties = additionalProperties; + Created = created; + Authors = authors; + Url = url; + Documentation = documentation; + Source = source; + Version = version; + Revision = revision; + Vendor = vendor; + Licenses = licenses; + Name = name; + Title = title; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets date and time on which the image was built (string, + /// date-time as defined by + /// https://tools.ietf.org/html/rfc3339#section-5.6) + /// + [JsonProperty(PropertyName = "org.opencontainers.image.created")] + public System.DateTime? Created { get; set; } + + /// + /// Gets or sets contact details of the people or organization + /// responsible for the image. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.authors")] + public string Authors { get; set; } + + /// + /// Gets or sets URL to find more information on the image. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.url")] + public string Url { get; set; } + + /// + /// Gets or sets URL to get documentation on the image. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.documentation")] + public string Documentation { get; set; } + + /// + /// Gets or sets URL to get source code for building the image. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.source")] + public string Source { get; set; } + + /// + /// Gets or sets version of the packaged software. The version MAY + /// match a label or tag in the source code repository, may also be + /// Semantic versioning-compatible + /// + [JsonProperty(PropertyName = "org.opencontainers.image.version")] + public string Version { get; set; } + + /// + /// Gets or sets source control revision identifier for the packaged + /// software. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.revision")] + public string Revision { get; set; } + + /// + /// Gets or sets name of the distributing entity, organization or + /// individual. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.vendor")] + public string Vendor { get; set; } + + /// + /// Gets or sets license(s) under which contained software is + /// distributed as an SPDX License Expression. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.licenses")] + public string Licenses { get; set; } + + /// + /// Gets or sets name of the reference for a target. + /// + [JsonProperty(PropertyName = "org.opencontainers.image.ref.name")] + public string Name { get; set; } + + /// + /// Gets or sets human-readable title of the image + /// + [JsonProperty(PropertyName = "org.opencontainers.image.title")] + public string Title { get; set; } + + /// + /// Gets or sets human-readable description of the software packaged in + /// the image + /// + [JsonProperty(PropertyName = "org.opencontainers.image.description")] + public string Description { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckChunkHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckChunkHeaders.cs new file mode 100644 index 000000000000..5be91a5c749d --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckChunkHeaders.cs @@ -0,0 +1,60 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckChunk operation. + /// + public partial class BlobCheckChunkHeaders + { + /// + /// Initializes a new instance of the BlobCheckChunkHeaders class. + /// + public BlobCheckChunkHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobCheckChunkHeaders class. + /// + /// The length of the requested blob + /// content. + /// Content range of blob chunk. + public BlobCheckChunkHeaders(long? contentLength = default(long?), string contentRange = default(string)) + { + ContentLength = contentLength; + ContentRange = contentRange; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the length of the requested blob content. + /// + [JsonProperty(PropertyName = "Content-Length")] + public long? ContentLength { get; set; } + + /// + /// Gets or sets content range of blob chunk. + /// + [JsonProperty(PropertyName = "Content-Range")] + public string ContentRange { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckHeaders.cs new file mode 100644 index 000000000000..a1abb3a95fb1 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobCheckHeaders.cs @@ -0,0 +1,70 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Check operation. + /// + public partial class BlobCheckHeaders + { + /// + /// Initializes a new instance of the BlobCheckHeaders class. + /// + public BlobCheckHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobCheckHeaders class. + /// + /// The length of the requested blob + /// content. + /// Digest of the targeted content + /// for the request. + /// The location where the layer should be + /// accessible. + public BlobCheckHeaders(long? contentLength = default(long?), string dockerContentDigest = default(string), string location = default(string)) + { + ContentLength = contentLength; + DockerContentDigest = dockerContentDigest; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the length of the requested blob content. + /// + [JsonProperty(PropertyName = "Content-Length")] + public long? ContentLength { get; set; } + + /// + /// Gets or sets digest of the targeted content for the request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + /// + /// Gets or sets the location where the layer should be accessible. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobDeleteHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobDeleteHeaders.cs new file mode 100644 index 000000000000..c5a1289de303 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobDeleteHeaders.cs @@ -0,0 +1,52 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class BlobDeleteHeaders + { + /// + /// Initializes a new instance of the BlobDeleteHeaders class. + /// + public BlobDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobDeleteHeaders class. + /// + /// Digest of the targeted content + /// for the request. + public BlobDeleteHeaders(string dockerContentDigest = default(string)) + { + DockerContentDigest = dockerContentDigest; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets digest of the targeted content for the request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobEndUploadHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobEndUploadHeaders.cs new file mode 100644 index 000000000000..d9a865ec830b --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobEndUploadHeaders.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for EndUpload operation. + /// + public partial class BlobEndUploadHeaders + { + /// + /// Initializes a new instance of the BlobEndUploadHeaders class. + /// + public BlobEndUploadHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobEndUploadHeaders class. + /// + /// Provided location for blob + /// Range indicating the current progress of the + /// upload. + /// Digest of the targeted content + /// for the request. + public BlobEndUploadHeaders(string location = default(string), string range = default(string), string dockerContentDigest = default(string)) + { + Location = location; + Range = range; + DockerContentDigest = dockerContentDigest; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provided location for blob + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets range indicating the current progress of the upload. + /// + [JsonProperty(PropertyName = "Range")] + public string Range { get; set; } + + /// + /// Gets or sets digest of the targeted content for the request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetChunkHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetChunkHeaders.cs new file mode 100644 index 000000000000..4a545f29bb61 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetChunkHeaders.cs @@ -0,0 +1,60 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetChunk operation. + /// + public partial class BlobGetChunkHeaders + { + /// + /// Initializes a new instance of the BlobGetChunkHeaders class. + /// + public BlobGetChunkHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobGetChunkHeaders class. + /// + /// The length of the requested blob + /// content. + /// Content range of blob chunk. + public BlobGetChunkHeaders(long? contentLength = default(long?), string contentRange = default(string)) + { + ContentLength = contentLength; + ContentRange = contentRange; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the length of the requested blob content. + /// + [JsonProperty(PropertyName = "Content-Length")] + public long? ContentLength { get; set; } + + /// + /// Gets or sets content range of blob chunk. + /// + [JsonProperty(PropertyName = "Content-Range")] + public string ContentRange { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetHeaders.cs new file mode 100644 index 000000000000..9cb664166f3a --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetHeaders.cs @@ -0,0 +1,70 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Get operation. + /// + public partial class BlobGetHeaders + { + /// + /// Initializes a new instance of the BlobGetHeaders class. + /// + public BlobGetHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobGetHeaders class. + /// + /// The length of the requested blob + /// content. + /// Digest of the targeted content + /// for the request. + /// The location where the layer should be + /// accessible. + public BlobGetHeaders(long? contentLength = default(long?), string dockerContentDigest = default(string), string location = default(string)) + { + ContentLength = contentLength; + DockerContentDigest = dockerContentDigest; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the length of the requested blob content. + /// + [JsonProperty(PropertyName = "Content-Length")] + public long? ContentLength { get; set; } + + /// + /// Gets or sets digest of the targeted content for the request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + /// + /// Gets or sets the location where the layer should be accessible. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetStatusHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetStatusHeaders.cs new file mode 100644 index 000000000000..67ce591959a9 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobGetStatusHeaders.cs @@ -0,0 +1,62 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetStatus operation. + /// + public partial class BlobGetStatusHeaders + { + /// + /// Initializes a new instance of the BlobGetStatusHeaders class. + /// + public BlobGetStatusHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobGetStatusHeaders class. + /// + /// Range indicating the current progress of the + /// upload. + /// Identifies the docker upload uuid + /// for the current request. + public BlobGetStatusHeaders(string range = default(string), string dockerUploadUUID = default(string)) + { + Range = range; + DockerUploadUUID = dockerUploadUUID; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets range indicating the current progress of the upload. + /// + [JsonProperty(PropertyName = "Range")] + public string Range { get; set; } + + /// + /// Gets or sets identifies the docker upload uuid for the current + /// request. + /// + [JsonProperty(PropertyName = "Docker-Upload-UUID")] + public string DockerUploadUUID { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobMountHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobMountHeaders.cs new file mode 100644 index 000000000000..c78000faa4be --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobMountHeaders.cs @@ -0,0 +1,70 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Mount operation. + /// + public partial class BlobMountHeaders + { + /// + /// Initializes a new instance of the BlobMountHeaders class. + /// + public BlobMountHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobMountHeaders class. + /// + /// Provided location for blob + /// Identifies the docker upload uuid + /// for the current request. + /// Digest of the targeted content + /// for the request. + public BlobMountHeaders(string location = default(string), string dockerUploadUUID = default(string), string dockerContentDigest = default(string)) + { + Location = location; + DockerUploadUUID = dockerUploadUUID; + DockerContentDigest = dockerContentDigest; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provided location for blob + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets identifies the docker upload uuid for the current + /// request. + /// + [JsonProperty(PropertyName = "Docker-Upload-UUID")] + public string DockerUploadUUID { get; set; } + + /// + /// Gets or sets digest of the targeted content for the request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobStartUploadHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobStartUploadHeaders.cs new file mode 100644 index 000000000000..a3c3b80da9d2 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobStartUploadHeaders.cs @@ -0,0 +1,70 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for StartUpload operation. + /// + public partial class BlobStartUploadHeaders + { + /// + /// Initializes a new instance of the BlobStartUploadHeaders class. + /// + public BlobStartUploadHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobStartUploadHeaders class. + /// + /// Provided location for blob + /// Range indicating the current progress of the + /// upload. + /// Identifies the docker upload uuid + /// for the current request. + public BlobStartUploadHeaders(string location = default(string), string range = default(string), string dockerUploadUUID = default(string)) + { + Location = location; + Range = range; + DockerUploadUUID = dockerUploadUUID; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provided location for blob + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets range indicating the current progress of the upload. + /// + [JsonProperty(PropertyName = "Range")] + public string Range { get; set; } + + /// + /// Gets or sets identifies the docker upload uuid for the current + /// request. + /// + [JsonProperty(PropertyName = "Docker-Upload-UUID")] + public string DockerUploadUUID { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobUploadHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobUploadHeaders.cs new file mode 100644 index 000000000000..84bf4fa3fc89 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/BlobUploadHeaders.cs @@ -0,0 +1,70 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Upload operation. + /// + public partial class BlobUploadHeaders + { + /// + /// Initializes a new instance of the BlobUploadHeaders class. + /// + public BlobUploadHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BlobUploadHeaders class. + /// + /// Provided location for blob + /// Range indicating the current progress of the + /// upload. + /// Identifies the docker upload uuid + /// for the current request. + public BlobUploadHeaders(string location = default(string), string range = default(string), string dockerUploadUUID = default(string)) + { + Location = location; + Range = range; + DockerUploadUUID = dockerUploadUUID; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provided location for blob + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets range indicating the current progress of the upload. + /// + [JsonProperty(PropertyName = "Range")] + public string Range { get; set; } + + /// + /// Gets or sets identifies the docker upload uuid for the current + /// request. + /// + [JsonProperty(PropertyName = "Docker-Upload-UUID")] + public string DockerUploadUUID { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/DeletedRepository.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/DeletedRepository.cs new file mode 100644 index 000000000000..0da185fa785e --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/DeletedRepository.cs @@ -0,0 +1,61 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deleted repository + /// + public partial class DeletedRepository + { + /// + /// Initializes a new instance of the DeletedRepository class. + /// + public DeletedRepository() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeletedRepository class. + /// + /// SHA of the deleted image + /// Tag of the deleted image + public DeletedRepository(IList manifestsDeleted = default(IList), IList tagsDeleted = default(IList)) + { + ManifestsDeleted = manifestsDeleted; + TagsDeleted = tagsDeleted; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets SHA of the deleted image + /// + [JsonProperty(PropertyName = "manifestsDeleted")] + public IList ManifestsDeleted { get; set; } + + /// + /// Gets or sets tag of the deleted image + /// + [JsonProperty(PropertyName = "tagsDeleted")] + public IList TagsDeleted { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Descriptor.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Descriptor.cs new file mode 100644 index 000000000000..fd4605c839a0 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Descriptor.cs @@ -0,0 +1,85 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Docker V2 image layer descriptor including config and layers + /// + public partial class Descriptor + { + /// + /// Initializes a new instance of the Descriptor class. + /// + public Descriptor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Descriptor class. + /// + /// Layer media type + /// Layer size + /// Layer digest + /// Specifies a list of URIs from which this object + /// may be downloaded. + public Descriptor(string mediaType = default(string), long? size = default(long?), string digest = default(string), IList urls = default(IList), Annotations annotations = default(Annotations)) + { + MediaType = mediaType; + Size = size; + Digest = digest; + Urls = urls; + Annotations = annotations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets layer media type + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets layer size + /// + [JsonProperty(PropertyName = "size")] + public long? Size { get; set; } + + /// + /// Gets or sets layer digest + /// + [JsonProperty(PropertyName = "digest")] + public string Digest { get; set; } + + /// + /// Gets or sets specifies a list of URIs from which this object may be + /// downloaded. + /// + [JsonProperty(PropertyName = "urls")] + public IList Urls { get; set; } + + /// + /// + [JsonProperty(PropertyName = "annotations")] + public Annotations Annotations { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/FsLayer.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/FsLayer.cs new file mode 100644 index 000000000000..42aebaf83d66 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/FsLayer.cs @@ -0,0 +1,51 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Image layer information + /// + public partial class FsLayer + { + /// + /// Initializes a new instance of the FsLayer class. + /// + public FsLayer() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FsLayer class. + /// + /// SHA of an image layer + public FsLayer(string blobSum = default(string)) + { + BlobSum = blobSum; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets SHA of an image layer + /// + [JsonProperty(PropertyName = "blobSum")] + public string BlobSum { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/History.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/History.cs new file mode 100644 index 000000000000..89488ea1c5a1 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/History.cs @@ -0,0 +1,52 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A list of unstructured historical data for v1 compatibility + /// + public partial class History + { + /// + /// Initializes a new instance of the History class. + /// + public History() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the History class. + /// + /// The raw v1 compatibility + /// information + public History(string v1Compatibility = default(string)) + { + V1Compatibility = v1Compatibility; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the raw v1 compatibility information + /// + [JsonProperty(PropertyName = "v1Compatibility")] + public string V1Compatibility { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ImageSignature.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ImageSignature.cs new file mode 100644 index 000000000000..199089e0f527 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ImageSignature.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Signature of a signed manifest + /// + public partial class ImageSignature + { + /// + /// Initializes a new instance of the ImageSignature class. + /// + public ImageSignature() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ImageSignature class. + /// + /// A JSON web signature + /// A signature for the image manifest, signed + /// by a libtrust private key + /// The signed protected header + public ImageSignature(JWK header = default(JWK), string signature = default(string), string protectedProperty = default(string)) + { + Header = header; + Signature = signature; + ProtectedProperty = protectedProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a JSON web signature + /// + [JsonProperty(PropertyName = "header")] + public JWK Header { get; set; } + + /// + /// Gets or sets a signature for the image manifest, signed by a + /// libtrust private key + /// + [JsonProperty(PropertyName = "signature")] + public string Signature { get; set; } + + /// + /// Gets or sets the signed protected header + /// + [JsonProperty(PropertyName = "protected")] + public string ProtectedProperty { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWK.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWK.cs new file mode 100644 index 000000000000..0e326607a1d0 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWK.cs @@ -0,0 +1,58 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A JSON web signature + /// + public partial class JWK + { + /// + /// Initializes a new instance of the JWK class. + /// + public JWK() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the JWK class. + /// + /// The algorithm used to sign or encrypt the + /// JWT + public JWK(JWKHeader jwk = default(JWKHeader), string alg = default(string)) + { + Jwk = jwk; + Alg = alg; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "jwk")] + public JWKHeader Jwk { get; set; } + + /// + /// Gets or sets the algorithm used to sign or encrypt the JWT + /// + [JsonProperty(PropertyName = "alg")] + public string Alg { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWKHeader.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWKHeader.cs new file mode 100644 index 000000000000..8f60c98ba077 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/JWKHeader.cs @@ -0,0 +1,83 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// JSON web key parameter + /// + public partial class JWKHeader + { + /// + /// Initializes a new instance of the JWKHeader class. + /// + public JWKHeader() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the JWKHeader class. + /// + /// crv value + /// kid value + /// kty value + /// x value + /// y value + public JWKHeader(string crv = default(string), string kid = default(string), string kty = default(string), string x = default(string), string y = default(string)) + { + Crv = crv; + Kid = kid; + Kty = kty; + X = x; + Y = y; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets crv value + /// + [JsonProperty(PropertyName = "crv")] + public string Crv { get; set; } + + /// + /// Gets or sets kid value + /// + [JsonProperty(PropertyName = "kid")] + public string Kid { get; set; } + + /// + /// Gets or sets kty value + /// + [JsonProperty(PropertyName = "kty")] + public string Kty { get; set; } + + /// + /// Gets or sets x value + /// + [JsonProperty(PropertyName = "x")] + public string X { get; set; } + + /// + /// Gets or sets y value + /// + [JsonProperty(PropertyName = "y")] + public string Y { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Manifest.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Manifest.cs new file mode 100644 index 000000000000..7671532dc67d --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Manifest.cs @@ -0,0 +1,51 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Returns the requested manifest file + /// + public partial class Manifest + { + /// + /// Initializes a new instance of the Manifest class. + /// + public Manifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Manifest class. + /// + /// Schema version + public Manifest(int? schemaVersion = default(int?)) + { + SchemaVersion = schemaVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets schema version + /// + [JsonProperty(PropertyName = "schemaVersion")] + public int? SchemaVersion { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributes.cs new file mode 100644 index 000000000000..16f8c4c595d6 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributes.cs @@ -0,0 +1,67 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Manifest attributes details + /// + public partial class ManifestAttributes + { + /// + /// Initializes a new instance of the ManifestAttributes class. + /// + public ManifestAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestAttributes class. + /// + /// Registry name + /// Image name + /// Manifest attributes + public ManifestAttributes(string registry = default(string), string imageName = default(string), ManifestAttributesBase attributes = default(ManifestAttributesBase)) + { + Registry = registry; + ImageName = imageName; + Attributes = attributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets registry name + /// + [JsonProperty(PropertyName = "registry")] + public string Registry { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; set; } + + /// + /// Gets or sets manifest attributes + /// + [JsonProperty(PropertyName = "manifest")] + public ManifestAttributesBase Attributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesBase.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesBase.cs new file mode 100644 index 000000000000..2d11b6d47301 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesBase.cs @@ -0,0 +1,125 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Manifest details + /// + public partial class ManifestAttributesBase + { + /// + /// Initializes a new instance of the ManifestAttributesBase class. + /// + public ManifestAttributesBase() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestAttributesBase class. + /// + /// Manifest + /// Image size + /// Created time + /// Last update time + /// CPU architecture + /// Operating system + /// Media type + /// Config blob media type + /// List of tags + /// Changeable attributes + public ManifestAttributesBase(string digest = default(string), long? imageSize = default(long?), string createdTime = default(string), string lastUpdateTime = default(string), string architecture = default(string), string os = default(string), string mediaType = default(string), string configMediaType = default(string), IList tags = default(IList), ManifestChangeableAttributes changeableAttributes = default(ManifestChangeableAttributes)) + { + Digest = digest; + ImageSize = imageSize; + CreatedTime = createdTime; + LastUpdateTime = lastUpdateTime; + Architecture = architecture; + Os = os; + MediaType = mediaType; + ConfigMediaType = configMediaType; + Tags = tags; + ChangeableAttributes = changeableAttributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets manifest + /// + [JsonProperty(PropertyName = "digest")] + public string Digest { get; set; } + + /// + /// Gets or sets image size + /// + [JsonProperty(PropertyName = "imageSize")] + public long? ImageSize { get; set; } + + /// + /// Gets or sets created time + /// + [JsonProperty(PropertyName = "createdTime")] + public string CreatedTime { get; set; } + + /// + /// Gets or sets last update time + /// + [JsonProperty(PropertyName = "lastUpdateTime")] + public string LastUpdateTime { get; set; } + + /// + /// Gets or sets CPU architecture + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets operating system + /// + [JsonProperty(PropertyName = "os")] + public string Os { get; set; } + + /// + /// Gets or sets media type + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets config blob media type + /// + [JsonProperty(PropertyName = "configMediaType")] + public string ConfigMediaType { get; set; } + + /// + /// Gets or sets list of tags + /// + [JsonProperty(PropertyName = "tags")] + public IList Tags { get; set; } + + /// + /// Gets or sets changeable attributes + /// + [JsonProperty(PropertyName = "changeableAttributes")] + public ManifestChangeableAttributes ChangeableAttributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifest.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifest.cs new file mode 100644 index 000000000000..a2efbf59ca22 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifest.cs @@ -0,0 +1,62 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of manifest attributes + /// + public partial class ManifestAttributesManifest + { + /// + /// Initializes a new instance of the ManifestAttributesManifest class. + /// + public ManifestAttributesManifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestAttributesManifest class. + /// + /// List of manifest attributes + /// details + /// Quarantine tag name + public ManifestAttributesManifest(IList references = default(IList), string quarantineTag = default(string)) + { + References = references; + QuarantineTag = quarantineTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of manifest attributes details + /// + [JsonProperty(PropertyName = "references")] + public IList References { get; set; } + + /// + /// Gets or sets quarantine tag name + /// + [JsonProperty(PropertyName = "quarantineTag")] + public string QuarantineTag { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifestReferences.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifestReferences.cs new file mode 100644 index 000000000000..cd1e93f9413d --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestAttributesManifestReferences.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Manifest attributes details + /// + public partial class ManifestAttributesManifestReferences + { + /// + /// Initializes a new instance of the + /// ManifestAttributesManifestReferences class. + /// + public ManifestAttributesManifestReferences() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ManifestAttributesManifestReferences class. + /// + /// Manifest digest + /// CPU architecture + /// Operating system + public ManifestAttributesManifestReferences(string digest = default(string), string architecture = default(string), string os = default(string)) + { + Digest = digest; + Architecture = architecture; + Os = os; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets manifest digest + /// + [JsonProperty(PropertyName = "digest")] + public string Digest { get; set; } + + /// + /// Gets or sets CPU architecture + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets operating system + /// + [JsonProperty(PropertyName = "os")] + public string Os { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestChangeableAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestChangeableAttributes.cs new file mode 100644 index 000000000000..753156b0a562 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestChangeableAttributes.cs @@ -0,0 +1,93 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Changeable attributes + /// + public partial class ManifestChangeableAttributes + { + /// + /// Initializes a new instance of the ManifestChangeableAttributes + /// class. + /// + public ManifestChangeableAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestChangeableAttributes + /// class. + /// + /// Delete enabled + /// Write enabled + /// List enabled + /// Read enabled + /// Quarantine state + /// Quarantine details + public ManifestChangeableAttributes(bool? deleteEnabled = default(bool?), bool? writeEnabled = default(bool?), bool? listEnabled = default(bool?), bool? readEnabled = default(bool?), string quarantineState = default(string), string quarantineDetails = default(string)) + { + DeleteEnabled = deleteEnabled; + WriteEnabled = writeEnabled; + ListEnabled = listEnabled; + ReadEnabled = readEnabled; + QuarantineState = quarantineState; + QuarantineDetails = quarantineDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets delete enabled + /// + [JsonProperty(PropertyName = "deleteEnabled")] + public bool? DeleteEnabled { get; set; } + + /// + /// Gets or sets write enabled + /// + [JsonProperty(PropertyName = "writeEnabled")] + public bool? WriteEnabled { get; set; } + + /// + /// Gets or sets list enabled + /// + [JsonProperty(PropertyName = "listEnabled")] + public bool? ListEnabled { get; set; } + + /// + /// Gets or sets read enabled + /// + [JsonProperty(PropertyName = "readEnabled")] + public bool? ReadEnabled { get; set; } + + /// + /// Gets or sets quarantine state + /// + [JsonProperty(PropertyName = "quarantineState")] + public string QuarantineState { get; set; } + + /// + /// Gets or sets quarantine details + /// + [JsonProperty(PropertyName = "quarantineDetails")] + public string QuarantineDetails { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestList.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestList.cs new file mode 100644 index 000000000000..51654c34dd12 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestList.cs @@ -0,0 +1,63 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested Docker multi-arch-manifest file + /// + public partial class ManifestList : Manifest + { + /// + /// Initializes a new instance of the ManifestList class. + /// + public ManifestList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestList class. + /// + /// Schema version + /// Media type for this Manifest + /// List of V2 image layer information + public ManifestList(int? schemaVersion = default(int?), string mediaType = default(string), IList manifests = default(IList)) + : base(schemaVersion) + { + MediaType = mediaType; + Manifests = manifests; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets media type for this Manifest + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets list of V2 image layer information + /// + [JsonProperty(PropertyName = "manifests")] + public IList Manifests { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestListAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestListAttributes.cs new file mode 100644 index 000000000000..62b294d769ac --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestListAttributes.cs @@ -0,0 +1,77 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ManifestListAttributes + { + /// + /// Initializes a new instance of the ManifestListAttributes class. + /// + public ManifestListAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestListAttributes class. + /// + /// The MIME type of the referenced object. + /// This will generally be + /// application/vnd.docker.image.manifest.v2+json, but it could also be + /// application/vnd.docker.image.manifest.v1+json + /// The size in bytes of the object + /// The digest of the content, as defined by the + /// Registry V2 HTTP API Specification + public ManifestListAttributes(string mediaType = default(string), long? size = default(long?), string digest = default(string), Platform platform = default(Platform)) + { + MediaType = mediaType; + Size = size; + Digest = digest; + Platform = platform; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the MIME type of the referenced object. This will + /// generally be application/vnd.docker.image.manifest.v2+json, but it + /// could also be application/vnd.docker.image.manifest.v1+json + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets the size in bytes of the object + /// + [JsonProperty(PropertyName = "size")] + public long? Size { get; set; } + + /// + /// Gets or sets the digest of the content, as defined by the Registry + /// V2 HTTP API Specification + /// + [JsonProperty(PropertyName = "digest")] + public string Digest { get; set; } + + /// + /// + [JsonProperty(PropertyName = "platform")] + public Platform Platform { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestWrapper.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestWrapper.cs new file mode 100644 index 000000000000..de4dd05feca5 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestWrapper.cs @@ -0,0 +1,139 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested manifest file + /// + public partial class ManifestWrapper : Manifest + { + /// + /// Initializes a new instance of the ManifestWrapper class. + /// + public ManifestWrapper() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestWrapper class. + /// + /// Schema version + /// Media type for this Manifest + /// (ManifestList, OCIIndex) List of V2 image + /// layer information + /// (V2, OCI) Image config descriptor + /// (V2, OCI) List of V2 image layer + /// information + /// (OCI, OCIIndex) Additional + /// metadata + /// (V1) CPU architecture + /// (V1) Image name + /// (V1) Image tag + /// (V1) List of layer information + /// (V1) Image history + /// (V1) Image signature + public ManifestWrapper(int? schemaVersion = default(int?), string mediaType = default(string), IList manifests = default(IList), Descriptor config = default(Descriptor), IList layers = default(IList), Annotations annotations = default(Annotations), string architecture = default(string), string name = default(string), string tag = default(string), IList fsLayers = default(IList), IList history = default(IList), IList signatures = default(IList)) + : base(schemaVersion) + { + MediaType = mediaType; + Manifests = manifests; + Config = config; + Layers = layers; + Annotations = annotations; + Architecture = architecture; + Name = name; + Tag = tag; + FsLayers = fsLayers; + History = history; + Signatures = signatures; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets media type for this Manifest + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets (ManifestList, OCIIndex) List of V2 image layer + /// information + /// + [JsonProperty(PropertyName = "manifests")] + public IList Manifests { get; set; } + + /// + /// Gets or sets (V2, OCI) Image config descriptor + /// + [JsonProperty(PropertyName = "config")] + public Descriptor Config { get; set; } + + /// + /// Gets or sets (V2, OCI) List of V2 image layer information + /// + [JsonProperty(PropertyName = "layers")] + public IList Layers { get; set; } + + /// + /// Gets or sets (OCI, OCIIndex) Additional metadata + /// + [JsonProperty(PropertyName = "annotations")] + public Annotations Annotations { get; set; } + + /// + /// Gets or sets (V1) CPU architecture + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets (V1) Image name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets (V1) Image tag + /// + [JsonProperty(PropertyName = "tag")] + public string Tag { get; set; } + + /// + /// Gets or sets (V1) List of layer information + /// + [JsonProperty(PropertyName = "fsLayers")] + public IList FsLayers { get; set; } + + /// + /// Gets or sets (V1) Image history + /// + [JsonProperty(PropertyName = "history")] + public IList History { get; set; } + + /// + /// Gets or sets (V1) Image signature + /// + [JsonProperty(PropertyName = "signatures")] + public IList Signatures { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestsCreateHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestsCreateHeaders.cs new file mode 100644 index 000000000000..fd4b10d7166d --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/ManifestsCreateHeaders.cs @@ -0,0 +1,71 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Create operation. + /// + public partial class ManifestsCreateHeaders + { + /// + /// Initializes a new instance of the ManifestsCreateHeaders class. + /// + public ManifestsCreateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManifestsCreateHeaders class. + /// + /// Identifies the docker upload uuid + /// for the current request. + /// The canonical location url of the uploaded + /// manifest. + /// The length of the requested blob + /// content. + public ManifestsCreateHeaders(string dockerContentDigest = default(string), string location = default(string), long? contentLength = default(long?)) + { + DockerContentDigest = dockerContentDigest; + Location = location; + ContentLength = contentLength; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets identifies the docker upload uuid for the current + /// request. + /// + [JsonProperty(PropertyName = "Docker-Content-Digest")] + public string DockerContentDigest { get; set; } + + /// + /// Gets or sets the canonical location url of the uploaded manifest. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the length of the requested blob content. + /// + [JsonProperty(PropertyName = "Content-Length")] + public long? ContentLength { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIIndex.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIIndex.cs new file mode 100644 index 000000000000..ea59582fee29 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIIndex.cs @@ -0,0 +1,61 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested OCI index file + /// + public partial class OCIIndex : Manifest + { + /// + /// Initializes a new instance of the OCIIndex class. + /// + public OCIIndex() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OCIIndex class. + /// + /// Schema version + /// List of OCI image layer information + public OCIIndex(int? schemaVersion = default(int?), IList manifests = default(IList), Annotations annotations = default(Annotations)) + : base(schemaVersion) + { + Manifests = manifests; + Annotations = annotations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of OCI image layer information + /// + [JsonProperty(PropertyName = "manifests")] + public IList Manifests { get; set; } + + /// + /// + [JsonProperty(PropertyName = "annotations")] + public Annotations Annotations { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIManifest.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIManifest.cs new file mode 100644 index 000000000000..8720066a6360 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/OCIManifest.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested OCI Manifest file + /// + public partial class OCIManifest : Manifest + { + /// + /// Initializes a new instance of the OCIManifest class. + /// + public OCIManifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OCIManifest class. + /// + /// Schema version + /// V2 image config descriptor + /// List of V2 image layer information + public OCIManifest(int? schemaVersion = default(int?), Descriptor config = default(Descriptor), IList layers = default(IList), Annotations annotations = default(Annotations)) + : base(schemaVersion) + { + Config = config; + Layers = layers; + Annotations = annotations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets V2 image config descriptor + /// + [JsonProperty(PropertyName = "config")] + public Descriptor Config { get; set; } + + /// + /// Gets or sets list of V2 image layer information + /// + [JsonProperty(PropertyName = "layers")] + public IList Layers { get; set; } + + /// + /// + [JsonProperty(PropertyName = "annotations")] + public Annotations Annotations { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Platform.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Platform.cs new file mode 100644 index 000000000000..fa8d4120111c --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Platform.cs @@ -0,0 +1,114 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The platform object describes the platform which the image in the + /// manifest runs on. A full list of valid operating system and + /// architecture values are listed in the Go language documentation for + /// $GOOS and $GOARCH + /// + public partial class Platform + { + /// + /// Initializes a new instance of the Platform class. + /// + public Platform() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Platform class. + /// + /// Specifies the CPU architecture, for + /// example amd64 or ppc64le. + /// The os field specifies the operating system, for + /// example linux or windows. + /// The optional os.version field specifies the + /// operating system version, for example 10.0.10586. + /// The optional os.features field specifies + /// an array of strings, each listing a required OS feature (for + /// example on Windows win32k + /// The optional variant field specifies a + /// variant of the CPU, for example armv6l to specify a particular CPU + /// variant of the ARM CPU. + /// The optional features field specifies an + /// array of strings, each listing a required CPU feature (for example + /// sse4 or aes + public Platform(string architecture = default(string), string os = default(string), string osversion = default(string), IList osfeatures = default(IList), string variant = default(string), IList features = default(IList)) + { + Architecture = architecture; + Os = os; + Osversion = osversion; + Osfeatures = osfeatures; + Variant = variant; + Features = features; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets specifies the CPU architecture, for example amd64 or + /// ppc64le. + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets the os field specifies the operating system, for + /// example linux or windows. + /// + [JsonProperty(PropertyName = "os")] + public string Os { get; set; } + + /// + /// Gets or sets the optional os.version field specifies the operating + /// system version, for example 10.0.10586. + /// + [JsonProperty(PropertyName = "os.version")] + public string Osversion { get; set; } + + /// + /// Gets or sets the optional os.features field specifies an array of + /// strings, each listing a required OS feature (for example on Windows + /// win32k + /// + [JsonProperty(PropertyName = "os.features")] + public IList Osfeatures { get; set; } + + /// + /// Gets or sets the optional variant field specifies a variant of the + /// CPU, for example armv6l to specify a particular CPU variant of the + /// ARM CPU. + /// + [JsonProperty(PropertyName = "variant")] + public string Variant { get; set; } + + /// + /// Gets or sets the optional features field specifies an array of + /// strings, each listing a required CPU feature (for example sse4 or + /// aes + /// + [JsonProperty(PropertyName = "features")] + public IList Features { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RefreshToken.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RefreshToken.cs new file mode 100644 index 000000000000..711dca7ec122 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RefreshToken.cs @@ -0,0 +1,50 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class RefreshToken + { + /// + /// Initializes a new instance of the RefreshToken class. + /// + public RefreshToken() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RefreshToken class. + /// + /// The refresh token to be used for + /// generating access tokens + public RefreshToken(string refreshTokenProperty = default(string)) + { + RefreshTokenProperty = refreshTokenProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the refresh token to be used for generating access + /// tokens + /// + [JsonProperty(PropertyName = "refresh_token")] + public string RefreshTokenProperty { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Repositories.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Repositories.cs new file mode 100644 index 000000000000..6cb17968ee55 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/Repositories.cs @@ -0,0 +1,53 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of repositories + /// + public partial class Repositories + { + /// + /// Initializes a new instance of the Repositories class. + /// + public Repositories() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Repositories class. + /// + /// Repository names + public Repositories(IList names = default(IList)) + { + Names = names; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets repository names + /// + [JsonProperty(PropertyName = "repositories")] + public IList Names { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryAttributes.cs new file mode 100644 index 000000000000..076b0cdbf429 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryAttributes.cs @@ -0,0 +1,99 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Repository attributes + /// + public partial class RepositoryAttributes + { + /// + /// Initializes a new instance of the RepositoryAttributes class. + /// + public RepositoryAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RepositoryAttributes class. + /// + /// Registry name + /// Image name + /// Image created time + /// Image last update time + /// Number of the manifests + /// Number of the tags + /// Changeable attributes + public RepositoryAttributes(string registry = default(string), string imageName = default(string), string createdTime = default(string), string lastUpdateTime = default(string), int? manifestCount = default(int?), int? tagCount = default(int?), RepositoryChangeableAttributes changeableAttributes = default(RepositoryChangeableAttributes)) + { + Registry = registry; + ImageName = imageName; + CreatedTime = createdTime; + LastUpdateTime = lastUpdateTime; + ManifestCount = manifestCount; + TagCount = tagCount; + ChangeableAttributes = changeableAttributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets registry name + /// + [JsonProperty(PropertyName = "registry")] + public string Registry { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; set; } + + /// + /// Gets or sets image created time + /// + [JsonProperty(PropertyName = "createdTime")] + public string CreatedTime { get; set; } + + /// + /// Gets or sets image last update time + /// + [JsonProperty(PropertyName = "lastUpdateTime")] + public string LastUpdateTime { get; set; } + + /// + /// Gets or sets number of the manifests + /// + [JsonProperty(PropertyName = "manifestCount")] + public int? ManifestCount { get; set; } + + /// + /// Gets or sets number of the tags + /// + [JsonProperty(PropertyName = "tagCount")] + public int? TagCount { get; set; } + + /// + /// Gets or sets changeable attributes + /// + [JsonProperty(PropertyName = "changeableAttributes")] + public RepositoryChangeableAttributes ChangeableAttributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryChangeableAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryChangeableAttributes.cs new file mode 100644 index 000000000000..11ed4ab726a6 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryChangeableAttributes.cs @@ -0,0 +1,88 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Changeable attributes for Repository + /// + public partial class RepositoryChangeableAttributes + { + /// + /// Initializes a new instance of the RepositoryChangeableAttributes + /// class. + /// + public RepositoryChangeableAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RepositoryChangeableAttributes + /// class. + /// + /// Delete enabled + /// Write enabled + /// List enabled + /// Read enabled + /// Enables Teleport functionality on new + /// images in the repository improving Container startup + /// performance + public RepositoryChangeableAttributes(bool? deleteEnabled = default(bool?), bool? writeEnabled = default(bool?), bool? listEnabled = default(bool?), bool? readEnabled = default(bool?), bool? teleportEnabled = default(bool?)) + { + DeleteEnabled = deleteEnabled; + WriteEnabled = writeEnabled; + ListEnabled = listEnabled; + ReadEnabled = readEnabled; + TeleportEnabled = teleportEnabled; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets delete enabled + /// + [JsonProperty(PropertyName = "deleteEnabled")] + public bool? DeleteEnabled { get; set; } + + /// + /// Gets or sets write enabled + /// + [JsonProperty(PropertyName = "writeEnabled")] + public bool? WriteEnabled { get; set; } + + /// + /// Gets or sets list enabled + /// + [JsonProperty(PropertyName = "listEnabled")] + public bool? ListEnabled { get; set; } + + /// + /// Gets or sets read enabled + /// + [JsonProperty(PropertyName = "readEnabled")] + public bool? ReadEnabled { get; set; } + + /// + /// Gets or sets enables Teleport functionality on new images in the + /// repository improving Container startup performance + /// + [JsonProperty(PropertyName = "teleportEnabled")] + public bool? TeleportEnabled { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryGetListHeaders.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryGetListHeaders.cs new file mode 100644 index 000000000000..53501df0cfeb --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryGetListHeaders.cs @@ -0,0 +1,51 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetList operation. + /// + public partial class RepositoryGetListHeaders + { + /// + /// Initializes a new instance of the RepositoryGetListHeaders class. + /// + public RepositoryGetListHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RepositoryGetListHeaders class. + /// + /// next paginated result + public RepositoryGetListHeaders(string link = default(string)) + { + Link = link; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets next paginated result + /// + [JsonProperty(PropertyName = "Link")] + public string Link { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryTags.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryTags.cs new file mode 100644 index 000000000000..ed3571c3ec11 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/RepositoryTags.cs @@ -0,0 +1,61 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the request to list tags of the image + /// + public partial class RepositoryTags + { + /// + /// Initializes a new instance of the RepositoryTags class. + /// + public RepositoryTags() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RepositoryTags class. + /// + /// Name of the image + /// List of tags + public RepositoryTags(string name = default(string), IList tags = default(IList)) + { + Name = name; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the image + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets list of tags + /// + [JsonProperty(PropertyName = "tags")] + public IList Tags { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributes.cs new file mode 100644 index 000000000000..9be96e3c3cbf --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributes.cs @@ -0,0 +1,67 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tag attributes + /// + public partial class TagAttributes + { + /// + /// Initializes a new instance of the TagAttributes class. + /// + public TagAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagAttributes class. + /// + /// Registry name + /// Image name + /// List of tag attribute details + public TagAttributes(string registry = default(string), string imageName = default(string), TagAttributesBase attributes = default(TagAttributesBase)) + { + Registry = registry; + ImageName = imageName; + Attributes = attributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets registry name + /// + [JsonProperty(PropertyName = "registry")] + public string Registry { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; set; } + + /// + /// Gets or sets list of tag attribute details + /// + [JsonProperty(PropertyName = "tag")] + public TagAttributesBase Attributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesBase.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesBase.cs new file mode 100644 index 000000000000..6d5e66633e48 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesBase.cs @@ -0,0 +1,92 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tag attribute details + /// + public partial class TagAttributesBase + { + /// + /// Initializes a new instance of the TagAttributesBase class. + /// + public TagAttributesBase() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagAttributesBase class. + /// + /// Tag name + /// Tag digest + /// Tag created time + /// Tag last update time + /// Is signed + /// Tag Changeable + /// attributes + public TagAttributesBase(string name = default(string), string digest = default(string), string createdTime = default(string), string lastUpdateTime = default(string), bool? signed = default(bool?), TagChangeableAttributes changeableAttributes = default(TagChangeableAttributes)) + { + Name = name; + Digest = digest; + CreatedTime = createdTime; + LastUpdateTime = lastUpdateTime; + Signed = signed; + ChangeableAttributes = changeableAttributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tag name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets tag digest + /// + [JsonProperty(PropertyName = "digest")] + public string Digest { get; set; } + + /// + /// Gets or sets tag created time + /// + [JsonProperty(PropertyName = "createdTime")] + public string CreatedTime { get; set; } + + /// + /// Gets or sets tag last update time + /// + [JsonProperty(PropertyName = "lastUpdateTime")] + public string LastUpdateTime { get; set; } + + /// + /// Gets or sets is signed + /// + [JsonProperty(PropertyName = "signed")] + public bool? Signed { get; set; } + + /// + /// Gets or sets tag Changeable attributes + /// + [JsonProperty(PropertyName = "changeableAttributes")] + public TagChangeableAttributes ChangeableAttributes { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesTag.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesTag.cs new file mode 100644 index 000000000000..8599afbcae01 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagAttributesTag.cs @@ -0,0 +1,51 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tag + /// + public partial class TagAttributesTag + { + /// + /// Initializes a new instance of the TagAttributesTag class. + /// + public TagAttributesTag() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagAttributesTag class. + /// + /// SignatureRecord value + public TagAttributesTag(string signatureRecord = default(string)) + { + SignatureRecord = signatureRecord; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets signatureRecord value + /// + [JsonProperty(PropertyName = "signatureRecord")] + public string SignatureRecord { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagChangeableAttributes.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagChangeableAttributes.cs new file mode 100644 index 000000000000..39a4fae220e4 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagChangeableAttributes.cs @@ -0,0 +1,72 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class TagChangeableAttributes + { + /// + /// Initializes a new instance of the TagChangeableAttributes class. + /// + public TagChangeableAttributes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagChangeableAttributes class. + /// + /// Delete enabled + /// Write enabled + /// List enabled + /// Read enabled + public TagChangeableAttributes(bool? deleteEnabled = default(bool?), bool? writeEnabled = default(bool?), bool? listEnabled = default(bool?), bool? readEnabled = default(bool?)) + { + DeleteEnabled = deleteEnabled; + WriteEnabled = writeEnabled; + ListEnabled = listEnabled; + ReadEnabled = readEnabled; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets delete enabled + /// + [JsonProperty(PropertyName = "deleteEnabled")] + public bool? DeleteEnabled { get; set; } + + /// + /// Gets or sets write enabled + /// + [JsonProperty(PropertyName = "writeEnabled")] + public bool? WriteEnabled { get; set; } + + /// + /// Gets or sets list enabled + /// + [JsonProperty(PropertyName = "listEnabled")] + public bool? ListEnabled { get; set; } + + /// + /// Gets or sets read enabled + /// + [JsonProperty(PropertyName = "readEnabled")] + public bool? ReadEnabled { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagList.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagList.cs new file mode 100644 index 000000000000..7db23ba813ea --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/TagList.cs @@ -0,0 +1,69 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of tag details + /// + public partial class TagList + { + /// + /// Initializes a new instance of the TagList class. + /// + public TagList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagList class. + /// + /// Registry name + /// Image name + /// List of tag attribute details + public TagList(string registry = default(string), string imageName = default(string), IList tags = default(IList)) + { + Registry = registry; + ImageName = imageName; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets registry name + /// + [JsonProperty(PropertyName = "registry")] + public string Registry { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; set; } + + /// + /// Gets or sets list of tag attribute details + /// + [JsonProperty(PropertyName = "tags")] + public IList Tags { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V1Manifest.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V1Manifest.cs new file mode 100644 index 000000000000..5c9d2d7270b1 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V1Manifest.cs @@ -0,0 +1,95 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested V1 manifest file + /// + public partial class V1Manifest : Manifest + { + /// + /// Initializes a new instance of the V1Manifest class. + /// + public V1Manifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the V1Manifest class. + /// + /// Schema version + /// CPU architecture + /// Image name + /// Image tag + /// List of layer information + /// Image history + /// Image signature + public V1Manifest(int? schemaVersion = default(int?), string architecture = default(string), string name = default(string), string tag = default(string), IList fsLayers = default(IList), IList history = default(IList), IList signatures = default(IList)) + : base(schemaVersion) + { + Architecture = architecture; + Name = name; + Tag = tag; + FsLayers = fsLayers; + History = history; + Signatures = signatures; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets CPU architecture + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets image name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets image tag + /// + [JsonProperty(PropertyName = "tag")] + public string Tag { get; set; } + + /// + /// Gets or sets list of layer information + /// + [JsonProperty(PropertyName = "fsLayers")] + public IList FsLayers { get; set; } + + /// + /// Gets or sets image history + /// + [JsonProperty(PropertyName = "history")] + public IList History { get; set; } + + /// + /// Gets or sets image signature + /// + [JsonProperty(PropertyName = "signatures")] + public IList Signatures { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V2Manifest.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V2Manifest.cs new file mode 100644 index 000000000000..8e652269cd9a --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/Models/V2Manifest.cs @@ -0,0 +1,71 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Returns the requested Docker V2 Manifest file + /// + public partial class V2Manifest : Manifest + { + /// + /// Initializes a new instance of the V2Manifest class. + /// + public V2Manifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the V2Manifest class. + /// + /// Schema version + /// Media type for this Manifest + /// V2 image config descriptor + /// List of V2 image layer information + public V2Manifest(int? schemaVersion = default(int?), string mediaType = default(string), Descriptor config = default(Descriptor), IList layers = default(IList)) + : base(schemaVersion) + { + MediaType = mediaType; + Config = config; + Layers = layers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets media type for this Manifest + /// + [JsonProperty(PropertyName = "mediaType")] + public string MediaType { get; set; } + + /// + /// Gets or sets V2 image config descriptor + /// + [JsonProperty(PropertyName = "config")] + public Descriptor Config { get; set; } + + /// + /// Gets or sets list of V2 image layer information + /// + [JsonProperty(PropertyName = "layers")] + public IList Layers { get; set; } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperations.cs new file mode 100644 index 000000000000..f7de7f15a160 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperations.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 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; + + /// + /// RefreshTokensOperations operations. + /// + internal partial class RefreshTokensOperations : IServiceOperations, IRefreshTokensOperations + { + /// + /// Initializes a new instance of the RefreshTokensOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RefreshTokensOperations(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 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. + /// + /// + /// 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> GetFromExchangeWithHttpMessagesAsync(string grantType, string service, string tenant = default(string), string refreshToken = default(string), string accessToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.LoginUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri"); + } + if (grantType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "grantType"); + } + if (service == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "service"); + } + // 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("tenant", tenant); + tracingParameters.Add("refreshToken", refreshToken); + tracingParameters.Add("accessToken", accessToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetFromExchange", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "oauth2/exchange"; + _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(tenant != null) + { + values.Add(new KeyValuePair("tenant", tenant)); + } + if(refreshToken != null) + { + values.Add(new KeyValuePair("refresh_token", refreshToken)); + } + if(accessToken != null) + { + values.Add(new KeyValuePair("access_token", accessToken)); + } + 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; + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperationsExtensions.cs new file mode 100644 index 000000000000..2779a03bbb7e --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RefreshTokensOperationsExtensions.cs @@ -0,0 +1,61 @@ +// +// 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 RefreshTokensOperations. + /// + public static partial class RefreshTokensOperationsExtensions + { + /// + /// Exchange AAD tokens for an ACR refresh Token + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task GetFromExchangeAsync(this IRefreshTokensOperations operations, string grantType, string service, string tenant = default(string), string refreshToken = default(string), string accessToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFromExchangeWithHttpMessagesAsync(grantType, service, tenant, refreshToken, accessToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperations.cs new file mode 100644 index 000000000000..36e7c032585b --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperations.cs @@ -0,0 +1,761 @@ +// +// 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; + + /// + /// RepositoryOperations operations. + /// + internal partial class RepositoryOperations : IServiceOperations, IRepositoryOperations + { + /// + /// Initializes a new instance of the RepositoryOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RepositoryOperations(AzureContainerRegistryClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureContainerRegistryClient + /// + public AzureContainerRegistryClient Client { get; private set; } + + /// + /// 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 + /// + /// + /// 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> GetListWithHttpMessagesAsync(string last = default(string), int? n = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.LoginUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("last", last); + tracingParameters.Add("n", n); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetList", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/_catalog"; + _url = _url.Replace("{url}", Client.LoginUri); + List _queryParameters = new List(); + if (last != null) + { + _queryParameters.Add(string.Format("last={0}", System.Uri.EscapeDataString(last))); + } + if (n != null) + { + _queryParameters.Add(string.Format("n={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(n, Client.SerializationSettings).Trim('"')))); + } + 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); + } + } + 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; + } + + /// + /// Get repository attributes + /// + /// + /// 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 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> GetAttributesWithHttpMessagesAsync(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, "GetAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}"; + _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("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; + } + + /// + /// Delete the repository identified by `name` + /// + /// + /// 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 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, 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, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}"; + _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("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 != 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 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) + { + _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; + } + + /// + /// Update the attribute identified by `name` where `reference` is the name of + /// the repository. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Repository attribute value + /// + /// + /// 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 UpdateAttributesWithHttpMessagesAsync(string name, RepositoryChangeableAttributes value = default(RepositoryChangeableAttributes), 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("value", value); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}"; + _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("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) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(value, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperationsExtensions.cs new file mode 100644 index 000000000000..43600af2843c --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/RepositoryOperationsExtensions.cs @@ -0,0 +1,110 @@ +// +// 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 RepositoryOperations. + /// + public static partial class RepositoryOperationsExtensions + { + /// + /// List repositories + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task GetListAsync(this IRepositoryOperations operations, string last = default(string), int? n = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetListWithHttpMessagesAsync(last, n, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get repository attributes + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// The cancellation token. + /// + public static async Task GetAttributesAsync(this IRepositoryOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAttributesWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete the repository identified by `name` + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IRepositoryOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update the attribute identified by `name` where `reference` is the name of + /// the repository. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Repository attribute value + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAttributesAsync(this IRepositoryOperations operations, string name, RepositoryChangeableAttributes value = default(RepositoryChangeableAttributes), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateAttributesWithHttpMessagesAsync(name, value, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/SdkInfo_AzureContainerRegistry.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/SdkInfo_AzureContainerRegistry.cs new file mode 100644 index 000000000000..aa17cb6f4388 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/SdkInfo_AzureContainerRegistry.cs @@ -0,0 +1,33 @@ + +// +// 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 System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_AzureContainerRegistry + { + get + { + return new Tuple[] + { + new Tuple("AzureContainerRegistry", "AccessTokens", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "Blob", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "Manifests", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "RefreshTokens", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "Repository", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "Tag", "2019-08-15-preview"), + new Tuple("AzureContainerRegistry", "V2Support", "2019-08-15-preview"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperations.cs new file mode 100644 index 000000000000..85cd83423568 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperations.cs @@ -0,0 +1,778 @@ +// +// 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; + + /// + /// TagOperations operations. + /// + internal partial class TagOperations : IServiceOperations, ITagOperations + { + /// + /// Initializes a new instance of the TagOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TagOperations(AzureContainerRegistryClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureContainerRegistryClient + /// + public AzureContainerRegistryClient Client { get; private set; } + + /// + /// 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 + /// + /// + /// 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> 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)) + { + 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("last", last); + tracingParameters.Add("n", n); + tracingParameters.Add("orderby", orderby); + tracingParameters.Add("digest", digest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetList", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags"; + _url = _url.Replace("{url}", Client.LoginUri); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (last != null) + { + _queryParameters.Add(string.Format("last={0}", System.Uri.EscapeDataString(last))); + } + if (n != null) + { + _queryParameters.Add(string.Format("n={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(n, Client.SerializationSettings).Trim('"')))); + } + if (orderby != null) + { + _queryParameters.Add(string.Format("orderby={0}", System.Uri.EscapeDataString(orderby))); + } + 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("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; + } + + /// + /// Get tag attributes by tag + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// 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> GetAttributesWithHttpMessagesAsync(string name, string reference, 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{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 (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; + } + + /// + /// Update tag attributes + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// Tag attribute value + /// + /// + /// 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 UpdateAttributesWithHttpMessagesAsync(string name, string reference, TagChangeableAttributes value = default(TagChangeableAttributes), 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("value", value); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{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("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) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(value, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete tag + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string name, string reference, 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{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("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 != 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 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; + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperationsExtensions.cs new file mode 100644 index 000000000000..3c6b033e5081 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/TagOperationsExtensions.cs @@ -0,0 +1,124 @@ +// +// 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 TagOperations. + /// + public static partial class TagOperationsExtensions + { + /// + /// List tags of a repository + /// + /// + /// The operations group for this extension method. + /// + /// + /// 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 cancellation token. + /// + public static async Task GetListAsync(this ITagOperations operations, string name, string last = default(string), int? n = default(int?), string orderby = default(string), string digest = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetListWithHttpMessagesAsync(name, last, n, orderby, digest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get tag attributes by tag + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// The cancellation token. + /// + public static async Task GetAttributesAsync(this ITagOperations operations, string name, string reference, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAttributesWithHttpMessagesAsync(name, reference, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update tag attributes + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// Tag attribute value + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAttributesAsync(this ITagOperations operations, string name, string reference, TagChangeableAttributes value = default(TagChangeableAttributes), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateAttributesWithHttpMessagesAsync(name, reference, value, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Delete tag + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the image (including the namespace) + /// + /// + /// Tag name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ITagOperations operations, string name, string reference, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(name, reference, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperations.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperations.cs new file mode 100644 index 000000000000..15b7cda39014 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperations.cs @@ -0,0 +1,199 @@ +// +// 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; + + /// + /// V2SupportOperations operations. + /// + internal partial class V2SupportOperations : IServiceOperations, IV2SupportOperations + { + /// + /// Initializes a new instance of the V2SupportOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal V2SupportOperations(AzureContainerRegistryClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureContainerRegistryClient + /// + public AzureContainerRegistryClient Client { get; private set; } + + /// + /// Tells whether this Docker Registry instance supports Docker Registry HTTP + /// API v2 + /// + /// + /// 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(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.LoginUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Check", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "v2/"; + _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("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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperationsExtensions.cs b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperationsExtensions.cs new file mode 100644 index 000000000000..db5841ed72e9 --- /dev/null +++ b/sdk/ContainerRegistry/Microsoft.Azure.ContainerRegistry/src/Generated/V2SupportOperationsExtensions.cs @@ -0,0 +1,40 @@ +// +// 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 V2SupportOperations. + /// + public static partial class V2SupportOperationsExtensions + { + /// + /// Tells whether this Docker Registry instance supports Docker Registry HTTP + /// API v2 + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task CheckAsync(this IV2SupportOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CheckWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +}