< Summary

Class:Microsoft.Azure.ContainerRegistry.TagOperations
Assembly:Microsoft.Azure.ContainerRegistry
File(s):C:\Git\azure-sdk-for-net\sdk\containerregistry\Microsoft.Azure.ContainerRegistry\src\Generated\TagOperations.cs
Covered lines:188
Uncovered lines:157
Coverable lines:345
Total lines:778
Line coverage:54.4% (188 of 345)
Covered branches:95
Total branches:202
Branch coverage:47% (95 of 202)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
GetListWithHttpMessagesAsync()-51.06%46.43%
GetAttributesWithHttpMessagesAsync()-53.49%46%
UpdateAttributesWithHttpMessagesAsync()-56.1%47.92%
DeleteWithHttpMessagesAsync()-55.84%47.83%

File(s)

C:\Git\azure-sdk-for-net\sdk\containerregistry\Microsoft.Azure.ContainerRegistry\src\Generated\TagOperations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.ContainerRegistry
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Models;
 16    using Newtonsoft.Json;
 17    using System.Collections;
 18    using System.Collections.Generic;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// TagOperations operations.
 27    /// </summary>
 28    internal partial class TagOperations : IServiceOperations<AzureContainerRegistryClient>, ITagOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the TagOperations class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 6039        internal TagOperations(AzureContainerRegistryClient client)
 40        {
 6041            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 6045            Client = client;
 6046        }
 47
 48        /// <summary>
 49        /// Gets a reference to the AzureContainerRegistryClient
 50        /// </summary>
 30051        public AzureContainerRegistryClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// List tags of a repository
 55        /// </summary>
 56        /// <param name='name'>
 57        /// Name of the image (including the namespace)
 58        /// </param>
 59        /// <param name='last'>
 60        /// Query parameter for the last item in previous query. Result set will
 61        /// include values lexically after last.
 62        /// </param>
 63        /// <param name='n'>
 64        /// query parameter for max number of items
 65        /// </param>
 66        /// <param name='orderby'>
 67        /// orderby query parameter
 68        /// </param>
 69        /// <param name='digest'>
 70        /// filter by digest
 71        /// </param>
 72        /// <param name='customHeaders'>
 73        /// Headers that will be added to request.
 74        /// </param>
 75        /// <param name='cancellationToken'>
 76        /// The cancellation token.
 77        /// </param>
 78        /// <exception cref="AcrErrorsException">
 79        /// Thrown when the operation returned an invalid status code
 80        /// </exception>
 81        /// <exception cref="SerializationException">
 82        /// Thrown when unable to deserialize the response
 83        /// </exception>
 84        /// <exception cref="ValidationException">
 85        /// Thrown when a required parameter is null
 86        /// </exception>
 87        /// <exception cref="System.ArgumentNullException">
 88        /// Thrown when a required parameter is null
 89        /// </exception>
 90        /// <return>
 91        /// A response object containing the response body and response headers.
 92        /// </return>
 93        public async Task<AzureOperationResponse<TagList>> GetListWithHttpMessagesAsync(string name, string last = defau
 94        {
 895            if (Client.LoginUri == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
 98            }
 899            if (name == null)
 100            {
 0101                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 102            }
 103            // Tracing
 8104            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 8105            string _invocationId = null;
 8106            if (_shouldTrace)
 107            {
 0108                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0109                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0110                tracingParameters.Add("name", name);
 0111                tracingParameters.Add("last", last);
 0112                tracingParameters.Add("n", n);
 0113                tracingParameters.Add("orderby", orderby);
 0114                tracingParameters.Add("digest", digest);
 0115                tracingParameters.Add("cancellationToken", cancellationToken);
 0116                ServiceClientTracing.Enter(_invocationId, this, "GetList", tracingParameters);
 117            }
 118            // Construct URL
 8119            var _baseUrl = Client.BaseUri;
 8120            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags";
 8121            _url = _url.Replace("{url}", Client.LoginUri);
 8122            _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
 8123            List<string> _queryParameters = new List<string>();
 8124            if (last != null)
 125            {
 0126                _queryParameters.Add(string.Format("last={0}", System.Uri.EscapeDataString(last)));
 127            }
 8128            if (n != null)
 129            {
 0130                _queryParameters.Add(string.Format("n={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConve
 131            }
 8132            if (orderby != null)
 133            {
 0134                _queryParameters.Add(string.Format("orderby={0}", System.Uri.EscapeDataString(orderby)));
 135            }
 8136            if (digest != null)
 137            {
 0138                _queryParameters.Add(string.Format("digest={0}", System.Uri.EscapeDataString(digest)));
 139            }
 8140            if (_queryParameters.Count > 0)
 141            {
 0142                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 143            }
 144            // Create HTTP transport objects
 8145            var _httpRequest = new HttpRequestMessage();
 8146            HttpResponseMessage _httpResponse = null;
 8147            _httpRequest.Method = new HttpMethod("GET");
 8148            _httpRequest.RequestUri = new System.Uri(_url);
 149            // Set Headers
 8150            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 151            {
 8152                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 153            }
 8154            if (Client.AcceptLanguage != null)
 155            {
 8156                if (_httpRequest.Headers.Contains("accept-language"))
 157                {
 0158                    _httpRequest.Headers.Remove("accept-language");
 159                }
 8160                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 161            }
 162
 163
 8164            if (customHeaders != null)
 165            {
 0166                foreach(var _header in customHeaders)
 167                {
 0168                    if (_httpRequest.Headers.Contains(_header.Key))
 169                    {
 0170                        _httpRequest.Headers.Remove(_header.Key);
 171                    }
 0172                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 173                }
 174            }
 175
 176            // Serialize Request
 8177            string _requestContent = null;
 178            // Set Credentials
 8179            if (Client.Credentials != null)
 180            {
 8181                cancellationToken.ThrowIfCancellationRequested();
 8182                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 183            }
 184            // Send Request
 8185            if (_shouldTrace)
 186            {
 0187                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 188            }
 8189            cancellationToken.ThrowIfCancellationRequested();
 8190            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8191            if (_shouldTrace)
 192            {
 0193                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 194            }
 8195            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 8196            cancellationToken.ThrowIfCancellationRequested();
 8197            string _responseContent = null;
 8198            if ((int)_statusCode != 200)
 199            {
 0200                var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _status
 201                try
 202                {
 0203                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0204                    AcrErrors _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<AcrErrors>(_responseCon
 0205                    if (_errorBody != null)
 206                    {
 0207                        ex.Body = _errorBody;
 208                    }
 0209                }
 0210                catch (JsonException)
 211                {
 212                    // Ignore the exception
 0213                }
 0214                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0215                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0216                if (_shouldTrace)
 217                {
 0218                    ServiceClientTracing.Error(_invocationId, ex);
 219                }
 0220                _httpRequest.Dispose();
 0221                if (_httpResponse != null)
 222                {
 0223                    _httpResponse.Dispose();
 224                }
 0225                throw ex;
 226            }
 227            // Create Result
 8228            var _result = new AzureOperationResponse<TagList>();
 8229            _result.Request = _httpRequest;
 8230            _result.Response = _httpResponse;
 8231            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 232            {
 0233                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 234            }
 235            // Deserialize Response
 8236            if ((int)_statusCode == 200)
 237            {
 8238                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 239                try
 240                {
 8241                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<TagList>(_responseContent, Clien
 8242                }
 0243                catch (JsonException ex)
 244                {
 0245                    _httpRequest.Dispose();
 0246                    if (_httpResponse != null)
 247                    {
 0248                        _httpResponse.Dispose();
 249                    }
 0250                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 251                }
 252            }
 8253            if (_shouldTrace)
 254            {
 0255                ServiceClientTracing.Exit(_invocationId, _result);
 256            }
 8257            return _result;
 8258        }
 259
 260        /// <summary>
 261        /// Get tag attributes by tag
 262        /// </summary>
 263        /// <param name='name'>
 264        /// Name of the image (including the namespace)
 265        /// </param>
 266        /// <param name='reference'>
 267        /// Tag name
 268        /// </param>
 269        /// <param name='customHeaders'>
 270        /// Headers that will be added to request.
 271        /// </param>
 272        /// <param name='cancellationToken'>
 273        /// The cancellation token.
 274        /// </param>
 275        /// <exception cref="AcrErrorsException">
 276        /// Thrown when the operation returned an invalid status code
 277        /// </exception>
 278        /// <exception cref="SerializationException">
 279        /// Thrown when unable to deserialize the response
 280        /// </exception>
 281        /// <exception cref="ValidationException">
 282        /// Thrown when a required parameter is null
 283        /// </exception>
 284        /// <exception cref="System.ArgumentNullException">
 285        /// Thrown when a required parameter is null
 286        /// </exception>
 287        /// <return>
 288        /// A response object containing the response body and response headers.
 289        /// </return>
 290        public async Task<AzureOperationResponse<TagAttributes>> GetAttributesWithHttpMessagesAsync(string name, string 
 291        {
 8292            if (Client.LoginUri == null)
 293            {
 0294                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
 295            }
 8296            if (name == null)
 297            {
 0298                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 299            }
 8300            if (reference == null)
 301            {
 0302                throw new ValidationException(ValidationRules.CannotBeNull, "reference");
 303            }
 304            // Tracing
 8305            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 8306            string _invocationId = null;
 8307            if (_shouldTrace)
 308            {
 0309                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0310                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0311                tracingParameters.Add("name", name);
 0312                tracingParameters.Add("reference", reference);
 0313                tracingParameters.Add("cancellationToken", cancellationToken);
 0314                ServiceClientTracing.Enter(_invocationId, this, "GetAttributes", tracingParameters);
 315            }
 316            // Construct URL
 8317            var _baseUrl = Client.BaseUri;
 8318            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{reference}";
 8319            _url = _url.Replace("{url}", Client.LoginUri);
 8320            _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
 8321            _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
 8322            List<string> _queryParameters = new List<string>();
 8323            if (_queryParameters.Count > 0)
 324            {
 0325                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 326            }
 327            // Create HTTP transport objects
 8328            var _httpRequest = new HttpRequestMessage();
 8329            HttpResponseMessage _httpResponse = null;
 8330            _httpRequest.Method = new HttpMethod("GET");
 8331            _httpRequest.RequestUri = new System.Uri(_url);
 332            // Set Headers
 8333            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 334            {
 8335                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 336            }
 8337            if (Client.AcceptLanguage != null)
 338            {
 8339                if (_httpRequest.Headers.Contains("accept-language"))
 340                {
 0341                    _httpRequest.Headers.Remove("accept-language");
 342                }
 8343                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 344            }
 345
 346
 8347            if (customHeaders != null)
 348            {
 0349                foreach(var _header in customHeaders)
 350                {
 0351                    if (_httpRequest.Headers.Contains(_header.Key))
 352                    {
 0353                        _httpRequest.Headers.Remove(_header.Key);
 354                    }
 0355                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 356                }
 357            }
 358
 359            // Serialize Request
 8360            string _requestContent = null;
 361            // Set Credentials
 8362            if (Client.Credentials != null)
 363            {
 8364                cancellationToken.ThrowIfCancellationRequested();
 8365                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 366            }
 367            // Send Request
 8368            if (_shouldTrace)
 369            {
 0370                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 371            }
 8372            cancellationToken.ThrowIfCancellationRequested();
 8373            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8374            if (_shouldTrace)
 375            {
 0376                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 377            }
 8378            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 8379            cancellationToken.ThrowIfCancellationRequested();
 8380            string _responseContent = null;
 8381            if ((int)_statusCode != 200)
 382            {
 0383                var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _status
 384                try
 385                {
 0386                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0387                    AcrErrors _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<AcrErrors>(_responseCon
 0388                    if (_errorBody != null)
 389                    {
 0390                        ex.Body = _errorBody;
 391                    }
 0392                }
 0393                catch (JsonException)
 394                {
 395                    // Ignore the exception
 0396                }
 0397                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0398                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0399                if (_shouldTrace)
 400                {
 0401                    ServiceClientTracing.Error(_invocationId, ex);
 402                }
 0403                _httpRequest.Dispose();
 0404                if (_httpResponse != null)
 405                {
 0406                    _httpResponse.Dispose();
 407                }
 0408                throw ex;
 409            }
 410            // Create Result
 8411            var _result = new AzureOperationResponse<TagAttributes>();
 8412            _result.Request = _httpRequest;
 8413            _result.Response = _httpResponse;
 8414            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 415            {
 0416                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 417            }
 418            // Deserialize Response
 8419            if ((int)_statusCode == 200)
 420            {
 8421                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 422                try
 423                {
 8424                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<TagAttributes>(_responseContent,
 8425                }
 0426                catch (JsonException ex)
 427                {
 0428                    _httpRequest.Dispose();
 0429                    if (_httpResponse != null)
 430                    {
 0431                        _httpResponse.Dispose();
 432                    }
 0433                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 434                }
 435            }
 8436            if (_shouldTrace)
 437            {
 0438                ServiceClientTracing.Exit(_invocationId, _result);
 439            }
 8440            return _result;
 8441        }
 442
 443        /// <summary>
 444        /// Update tag attributes
 445        /// </summary>
 446        /// <param name='name'>
 447        /// Name of the image (including the namespace)
 448        /// </param>
 449        /// <param name='reference'>
 450        /// Tag name
 451        /// </param>
 452        /// <param name='value'>
 453        /// Repository attribute value
 454        /// </param>
 455        /// <param name='customHeaders'>
 456        /// Headers that will be added to request.
 457        /// </param>
 458        /// <param name='cancellationToken'>
 459        /// The cancellation token.
 460        /// </param>
 461        /// <exception cref="AcrErrorsException">
 462        /// Thrown when the operation returned an invalid status code
 463        /// </exception>
 464        /// <exception cref="ValidationException">
 465        /// Thrown when a required parameter is null
 466        /// </exception>
 467        /// <exception cref="System.ArgumentNullException">
 468        /// Thrown when a required parameter is null
 469        /// </exception>
 470        /// <return>
 471        /// A response object containing the response body and response headers.
 472        /// </return>
 473        public async Task<AzureOperationResponse> UpdateAttributesWithHttpMessagesAsync(string name, string reference, C
 474        {
 4475            if (Client.LoginUri == null)
 476            {
 0477                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
 478            }
 4479            if (name == null)
 480            {
 0481                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 482            }
 4483            if (reference == null)
 484            {
 0485                throw new ValidationException(ValidationRules.CannotBeNull, "reference");
 486            }
 487            // Tracing
 4488            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4489            string _invocationId = null;
 4490            if (_shouldTrace)
 491            {
 0492                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0493                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0494                tracingParameters.Add("name", name);
 0495                tracingParameters.Add("reference", reference);
 0496                tracingParameters.Add("value", value);
 0497                tracingParameters.Add("cancellationToken", cancellationToken);
 0498                ServiceClientTracing.Enter(_invocationId, this, "UpdateAttributes", tracingParameters);
 499            }
 500            // Construct URL
 4501            var _baseUrl = Client.BaseUri;
 4502            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{reference}";
 4503            _url = _url.Replace("{url}", Client.LoginUri);
 4504            _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
 4505            _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
 4506            List<string> _queryParameters = new List<string>();
 4507            if (_queryParameters.Count > 0)
 508            {
 0509                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 510            }
 511            // Create HTTP transport objects
 4512            var _httpRequest = new HttpRequestMessage();
 4513            HttpResponseMessage _httpResponse = null;
 4514            _httpRequest.Method = new HttpMethod("PATCH");
 4515            _httpRequest.RequestUri = new System.Uri(_url);
 516            // Set Headers
 4517            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 518            {
 4519                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 520            }
 4521            if (Client.AcceptLanguage != null)
 522            {
 4523                if (_httpRequest.Headers.Contains("accept-language"))
 524                {
 0525                    _httpRequest.Headers.Remove("accept-language");
 526                }
 4527                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 528            }
 529
 530
 4531            if (customHeaders != null)
 532            {
 0533                foreach(var _header in customHeaders)
 534                {
 0535                    if (_httpRequest.Headers.Contains(_header.Key))
 536                    {
 0537                        _httpRequest.Headers.Remove(_header.Key);
 538                    }
 0539                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 540                }
 541            }
 542
 543            // Serialize Request
 4544            string _requestContent = null;
 4545            if(value != null)
 546            {
 4547                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(value, Client.SerializationSettings
 4548                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 4549                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 550            }
 551            // Set Credentials
 4552            if (Client.Credentials != null)
 553            {
 4554                cancellationToken.ThrowIfCancellationRequested();
 4555                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 556            }
 557            // Send Request
 4558            if (_shouldTrace)
 559            {
 0560                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 561            }
 4562            cancellationToken.ThrowIfCancellationRequested();
 4563            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4564            if (_shouldTrace)
 565            {
 0566                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 567            }
 4568            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4569            cancellationToken.ThrowIfCancellationRequested();
 4570            string _responseContent = null;
 4571            if ((int)_statusCode != 200)
 572            {
 0573                var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _status
 574                try
 575                {
 0576                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0577                    AcrErrors _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<AcrErrors>(_responseCon
 0578                    if (_errorBody != null)
 579                    {
 0580                        ex.Body = _errorBody;
 581                    }
 0582                }
 0583                catch (JsonException)
 584                {
 585                    // Ignore the exception
 0586                }
 0587                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0588                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0589                if (_shouldTrace)
 590                {
 0591                    ServiceClientTracing.Error(_invocationId, ex);
 592                }
 0593                _httpRequest.Dispose();
 0594                if (_httpResponse != null)
 595                {
 0596                    _httpResponse.Dispose();
 597                }
 0598                throw ex;
 599            }
 600            // Create Result
 4601            var _result = new AzureOperationResponse();
 4602            _result.Request = _httpRequest;
 4603            _result.Response = _httpResponse;
 4604            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 605            {
 0606                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 607            }
 4608            if (_shouldTrace)
 609            {
 0610                ServiceClientTracing.Exit(_invocationId, _result);
 611            }
 4612            return _result;
 4613        }
 614
 615        /// <summary>
 616        /// Delete tag
 617        /// </summary>
 618        /// <param name='name'>
 619        /// Name of the image (including the namespace)
 620        /// </param>
 621        /// <param name='reference'>
 622        /// Tag name
 623        /// </param>
 624        /// <param name='customHeaders'>
 625        /// Headers that will be added to request.
 626        /// </param>
 627        /// <param name='cancellationToken'>
 628        /// The cancellation token.
 629        /// </param>
 630        /// <exception cref="AcrErrorsException">
 631        /// Thrown when the operation returned an invalid status code
 632        /// </exception>
 633        /// <exception cref="ValidationException">
 634        /// Thrown when a required parameter is null
 635        /// </exception>
 636        /// <exception cref="System.ArgumentNullException">
 637        /// Thrown when a required parameter is null
 638        /// </exception>
 639        /// <return>
 640        /// A response object containing the response body and response headers.
 641        /// </return>
 642        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string name, string reference, Dictionary<
 643        {
 2644            if (Client.LoginUri == null)
 645            {
 0646                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.LoginUri");
 647            }
 2648            if (name == null)
 649            {
 0650                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 651            }
 2652            if (reference == null)
 653            {
 0654                throw new ValidationException(ValidationRules.CannotBeNull, "reference");
 655            }
 656            // Tracing
 2657            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2658            string _invocationId = null;
 2659            if (_shouldTrace)
 660            {
 0661                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0662                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0663                tracingParameters.Add("name", name);
 0664                tracingParameters.Add("reference", reference);
 0665                tracingParameters.Add("cancellationToken", cancellationToken);
 0666                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 667            }
 668            // Construct URL
 2669            var _baseUrl = Client.BaseUri;
 2670            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "acr/v1/{name}/_tags/{reference}";
 2671            _url = _url.Replace("{url}", Client.LoginUri);
 2672            _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
 2673            _url = _url.Replace("{reference}", System.Uri.EscapeDataString(reference));
 2674            List<string> _queryParameters = new List<string>();
 2675            if (_queryParameters.Count > 0)
 676            {
 0677                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 678            }
 679            // Create HTTP transport objects
 2680            var _httpRequest = new HttpRequestMessage();
 2681            HttpResponseMessage _httpResponse = null;
 2682            _httpRequest.Method = new HttpMethod("DELETE");
 2683            _httpRequest.RequestUri = new System.Uri(_url);
 684            // Set Headers
 2685            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 686            {
 2687                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 688            }
 2689            if (Client.AcceptLanguage != null)
 690            {
 2691                if (_httpRequest.Headers.Contains("accept-language"))
 692                {
 0693                    _httpRequest.Headers.Remove("accept-language");
 694                }
 2695                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 696            }
 697
 698
 2699            if (customHeaders != null)
 700            {
 0701                foreach(var _header in customHeaders)
 702                {
 0703                    if (_httpRequest.Headers.Contains(_header.Key))
 704                    {
 0705                        _httpRequest.Headers.Remove(_header.Key);
 706                    }
 0707                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 708                }
 709            }
 710
 711            // Serialize Request
 2712            string _requestContent = null;
 713            // Set Credentials
 2714            if (Client.Credentials != null)
 715            {
 2716                cancellationToken.ThrowIfCancellationRequested();
 2717                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 718            }
 719            // Send Request
 2720            if (_shouldTrace)
 721            {
 0722                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 723            }
 2724            cancellationToken.ThrowIfCancellationRequested();
 2725            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2726            if (_shouldTrace)
 727            {
 0728                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 729            }
 2730            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2731            cancellationToken.ThrowIfCancellationRequested();
 2732            string _responseContent = null;
 2733            if ((int)_statusCode != 202)
 734            {
 0735                var ex = new AcrErrorsException(string.Format("Operation returned an invalid status code '{0}'", _status
 736                try
 737                {
 0738                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0739                    AcrErrors _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<AcrErrors>(_responseCon
 0740                    if (_errorBody != null)
 741                    {
 0742                        ex.Body = _errorBody;
 743                    }
 0744                }
 0745                catch (JsonException)
 746                {
 747                    // Ignore the exception
 0748                }
 0749                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0750                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0751                if (_shouldTrace)
 752                {
 0753                    ServiceClientTracing.Error(_invocationId, ex);
 754                }
 0755                _httpRequest.Dispose();
 0756                if (_httpResponse != null)
 757                {
 0758                    _httpResponse.Dispose();
 759                }
 0760                throw ex;
 761            }
 762            // Create Result
 2763            var _result = new AzureOperationResponse();
 2764            _result.Request = _httpRequest;
 2765            _result.Response = _httpResponse;
 2766            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 767            {
 2768                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 769            }
 2770            if (_shouldTrace)
 771            {
 0772                ServiceClientTracing.Exit(_invocationId, _result);
 773            }
 2774            return _result;
 2775        }
 776
 777    }
 778}