< Summary

Class:Microsoft.Azure.Batch.Protocol.CertificateOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\CertificateOperations.cs
Covered lines:8
Uncovered lines:730
Coverable lines:738
Total lines:1554
Line coverage:1% (8 of 738)
Covered branches:3
Total branches:456
Branch coverage:0.6% (3 of 456)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
AddWithHttpMessagesAsync()-0%0%
ListWithHttpMessagesAsync()-0%0%
CancelDeletionWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-2.26%2.44%
ListNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\CertificateOperations.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.Batch.Protocol
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Microsoft.Rest.Serialization;
 16    using Models;
 17    using Newtonsoft.Json;
 18    using System.Collections;
 19    using System.Collections.Generic;
 20    using System.Linq;
 21    using System.Net;
 22    using System.Net.Http;
 23    using System.Threading;
 24    using System.Threading.Tasks;
 25
 26    /// <summary>
 27    /// CertificateOperations operations.
 28    /// </summary>
 29    internal partial class CertificateOperations : IServiceOperations<BatchServiceClient>, ICertificateOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the CertificateOperations class.
 33        /// </summary>
 34        /// <param name='client'>
 35        /// Reference to the service client.
 36        /// </param>
 37        /// <exception cref="System.ArgumentNullException">
 38        /// Thrown when a required parameter is null
 39        /// </exception>
 14840        internal CertificateOperations(BatchServiceClient client)
 41        {
 14842            if (client == null)
 43            {
 044                throw new System.ArgumentNullException("client");
 45            }
 14846            Client = client;
 14847        }
 48
 49        /// <summary>
 50        /// Gets a reference to the BatchServiceClient
 51        /// </summary>
 14152        public BatchServiceClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Adds a Certificate to the specified Account.
 56        /// </summary>
 57        /// <param name='certificate'>
 58        /// The Certificate to be added.
 59        /// </param>
 60        /// <param name='certificateAddOptions'>
 61        /// Additional parameters for the operation
 62        /// </param>
 63        /// <param name='customHeaders'>
 64        /// Headers that will be added to request.
 65        /// </param>
 66        /// <param name='cancellationToken'>
 67        /// The cancellation token.
 68        /// </param>
 69        /// <exception cref="BatchErrorException">
 70        /// Thrown when the operation returned an invalid status code
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationHeaderResponse<CertificateAddHeaders>> AddWithHttpMessagesAsync(CertificateAddPa
 82        {
 083            if (Client.BatchUrl == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 86            }
 087            if (certificate == null)
 88            {
 089                throw new ValidationException(ValidationRules.CannotBeNull, "certificate");
 90            }
 091            if (Client.ApiVersion == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 94            }
 095            int? timeout = default(int?);
 096            if (certificateAddOptions != null)
 97            {
 098                timeout = certificateAddOptions.Timeout;
 99            }
 0100            System.Guid? clientRequestId = default(System.Guid?);
 0101            if (certificateAddOptions != null)
 102            {
 0103                clientRequestId = certificateAddOptions.ClientRequestId;
 104            }
 0105            bool? returnClientRequestId = default(bool?);
 0106            if (certificateAddOptions != null)
 107            {
 0108                returnClientRequestId = certificateAddOptions.ReturnClientRequestId;
 109            }
 0110            System.DateTime? ocpDate = default(System.DateTime?);
 0111            if (certificateAddOptions != null)
 112            {
 0113                ocpDate = certificateAddOptions.OcpDate;
 114            }
 115            // Tracing
 0116            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0117            string _invocationId = null;
 0118            if (_shouldTrace)
 119            {
 0120                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0121                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0122                tracingParameters.Add("certificate", certificate);
 0123                tracingParameters.Add("timeout", timeout);
 0124                tracingParameters.Add("clientRequestId", clientRequestId);
 0125                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0126                tracingParameters.Add("ocpDate", ocpDate);
 0127                tracingParameters.Add("cancellationToken", cancellationToken);
 0128                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 129            }
 130            // Construct URL
 0131            var _baseUrl = Client.BaseUri;
 0132            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "certificates";
 0133            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0134            List<string> _queryParameters = new List<string>();
 0135            if (Client.ApiVersion != null)
 136            {
 0137                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 138            }
 0139            if (timeout != null)
 140            {
 0141                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 142            }
 0143            if (_queryParameters.Count > 0)
 144            {
 0145                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 146            }
 147            // Create HTTP transport objects
 0148            var _httpRequest = new HttpRequestMessage();
 0149            HttpResponseMessage _httpResponse = null;
 0150            _httpRequest.Method = new HttpMethod("POST");
 0151            _httpRequest.RequestUri = new System.Uri(_url);
 152            // Set Headers
 0153            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 154            {
 0155                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 156            }
 0157            if (Client.AcceptLanguage != null)
 158            {
 0159                if (_httpRequest.Headers.Contains("accept-language"))
 160                {
 0161                    _httpRequest.Headers.Remove("accept-language");
 162                }
 0163                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 164            }
 0165            if (clientRequestId != null)
 166            {
 0167                if (_httpRequest.Headers.Contains("client-request-id"))
 168                {
 0169                    _httpRequest.Headers.Remove("client-request-id");
 170                }
 0171                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 172            }
 0173            if (returnClientRequestId != null)
 174            {
 0175                if (_httpRequest.Headers.Contains("return-client-request-id"))
 176                {
 0177                    _httpRequest.Headers.Remove("return-client-request-id");
 178                }
 0179                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 180            }
 0181            if (ocpDate != null)
 182            {
 0183                if (_httpRequest.Headers.Contains("ocp-date"))
 184                {
 0185                    _httpRequest.Headers.Remove("ocp-date");
 186                }
 0187                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 188            }
 189
 190
 0191            if (customHeaders != null)
 192            {
 0193                foreach(var _header in customHeaders)
 194                {
 0195                    if (_httpRequest.Headers.Contains(_header.Key))
 196                    {
 0197                        _httpRequest.Headers.Remove(_header.Key);
 198                    }
 0199                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 200                }
 201            }
 202
 203            // Serialize Request
 0204            string _requestContent = null;
 0205            if(certificate != null)
 206            {
 0207                _requestContent = SafeJsonConvert.SerializeObject(certificate, Client.SerializationSettings);
 0208                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0209                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 210            }
 211            // Set Credentials
 0212            if (Client.Credentials != null)
 213            {
 0214                cancellationToken.ThrowIfCancellationRequested();
 0215                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 216            }
 217            // Send Request
 0218            if (_shouldTrace)
 219            {
 0220                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 221            }
 0222            cancellationToken.ThrowIfCancellationRequested();
 0223            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0224            if (_shouldTrace)
 225            {
 0226                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 227            }
 0228            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0229            cancellationToken.ThrowIfCancellationRequested();
 0230            string _responseContent = null;
 0231            if ((int)_statusCode != 201)
 232            {
 0233                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 234                try
 235                {
 0236                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0237                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0238                    if (_errorBody != null)
 239                    {
 0240                        ex.Body = _errorBody;
 241                    }
 0242                }
 0243                catch (JsonException)
 244                {
 245                    // Ignore the exception
 0246                }
 0247                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0248                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0249                if (_shouldTrace)
 250                {
 0251                    ServiceClientTracing.Error(_invocationId, ex);
 252                }
 0253                _httpRequest.Dispose();
 0254                if (_httpResponse != null)
 255                {
 0256                    _httpResponse.Dispose();
 257                }
 0258                throw ex;
 259            }
 260            // Create Result
 0261            var _result = new AzureOperationHeaderResponse<CertificateAddHeaders>();
 0262            _result.Request = _httpRequest;
 0263            _result.Response = _httpResponse;
 0264            if (_httpResponse.Headers.Contains("request-id"))
 265            {
 0266                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 267            }
 268            try
 269            {
 0270                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateAddHeaders>(JsonSerializer.Create
 0271            }
 0272            catch (JsonException ex)
 273            {
 0274                _httpRequest.Dispose();
 0275                if (_httpResponse != null)
 276                {
 0277                    _httpResponse.Dispose();
 278                }
 0279                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 280            }
 0281            if (_shouldTrace)
 282            {
 0283                ServiceClientTracing.Exit(_invocationId, _result);
 284            }
 0285            return _result;
 0286        }
 287
 288        /// <summary>
 289        /// Lists all of the Certificates that have been added to the specified
 290        /// Account.
 291        /// </summary>
 292        /// <param name='certificateListOptions'>
 293        /// Additional parameters for the operation
 294        /// </param>
 295        /// <param name='customHeaders'>
 296        /// Headers that will be added to request.
 297        /// </param>
 298        /// <param name='cancellationToken'>
 299        /// The cancellation token.
 300        /// </param>
 301        /// <exception cref="BatchErrorException">
 302        /// Thrown when the operation returned an invalid status code
 303        /// </exception>
 304        /// <exception cref="SerializationException">
 305        /// Thrown when unable to deserialize the response
 306        /// </exception>
 307        /// <exception cref="ValidationException">
 308        /// Thrown when a required parameter is null
 309        /// </exception>
 310        /// <exception cref="System.ArgumentNullException">
 311        /// Thrown when a required parameter is null
 312        /// </exception>
 313        /// <return>
 314        /// A response object containing the response body and response headers.
 315        /// </return>
 316        public async Task<AzureOperationResponse<IPage<Certificate>,CertificateListHeaders>> ListWithHttpMessagesAsync(C
 317        {
 0318            if (Client.BatchUrl == null)
 319            {
 0320                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 321            }
 0322            if (Client.ApiVersion == null)
 323            {
 0324                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 325            }
 0326            string filter = default(string);
 0327            if (certificateListOptions != null)
 328            {
 0329                filter = certificateListOptions.Filter;
 330            }
 0331            string select = default(string);
 0332            if (certificateListOptions != null)
 333            {
 0334                select = certificateListOptions.Select;
 335            }
 0336            int? maxResults = default(int?);
 0337            if (certificateListOptions != null)
 338            {
 0339                maxResults = certificateListOptions.MaxResults;
 340            }
 0341            int? timeout = default(int?);
 0342            if (certificateListOptions != null)
 343            {
 0344                timeout = certificateListOptions.Timeout;
 345            }
 0346            System.Guid? clientRequestId = default(System.Guid?);
 0347            if (certificateListOptions != null)
 348            {
 0349                clientRequestId = certificateListOptions.ClientRequestId;
 350            }
 0351            bool? returnClientRequestId = default(bool?);
 0352            if (certificateListOptions != null)
 353            {
 0354                returnClientRequestId = certificateListOptions.ReturnClientRequestId;
 355            }
 0356            System.DateTime? ocpDate = default(System.DateTime?);
 0357            if (certificateListOptions != null)
 358            {
 0359                ocpDate = certificateListOptions.OcpDate;
 360            }
 361            // Tracing
 0362            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0363            string _invocationId = null;
 0364            if (_shouldTrace)
 365            {
 0366                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0367                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0368                tracingParameters.Add("filter", filter);
 0369                tracingParameters.Add("select", select);
 0370                tracingParameters.Add("maxResults", maxResults);
 0371                tracingParameters.Add("timeout", timeout);
 0372                tracingParameters.Add("clientRequestId", clientRequestId);
 0373                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0374                tracingParameters.Add("ocpDate", ocpDate);
 0375                tracingParameters.Add("cancellationToken", cancellationToken);
 0376                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 377            }
 378            // Construct URL
 0379            var _baseUrl = Client.BaseUri;
 0380            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "certificates";
 0381            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0382            List<string> _queryParameters = new List<string>();
 0383            if (Client.ApiVersion != null)
 384            {
 0385                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 386            }
 0387            if (filter != null)
 388            {
 0389                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 390            }
 0391            if (select != null)
 392            {
 0393                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 394            }
 0395            if (maxResults != null)
 396            {
 0397                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 398            }
 0399            if (timeout != null)
 400            {
 0401                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 402            }
 0403            if (_queryParameters.Count > 0)
 404            {
 0405                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 406            }
 407            // Create HTTP transport objects
 0408            var _httpRequest = new HttpRequestMessage();
 0409            HttpResponseMessage _httpResponse = null;
 0410            _httpRequest.Method = new HttpMethod("GET");
 0411            _httpRequest.RequestUri = new System.Uri(_url);
 412            // Set Headers
 0413            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 414            {
 0415                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 416            }
 0417            if (Client.AcceptLanguage != null)
 418            {
 0419                if (_httpRequest.Headers.Contains("accept-language"))
 420                {
 0421                    _httpRequest.Headers.Remove("accept-language");
 422                }
 0423                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 424            }
 0425            if (clientRequestId != null)
 426            {
 0427                if (_httpRequest.Headers.Contains("client-request-id"))
 428                {
 0429                    _httpRequest.Headers.Remove("client-request-id");
 430                }
 0431                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 432            }
 0433            if (returnClientRequestId != null)
 434            {
 0435                if (_httpRequest.Headers.Contains("return-client-request-id"))
 436                {
 0437                    _httpRequest.Headers.Remove("return-client-request-id");
 438                }
 0439                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 440            }
 0441            if (ocpDate != null)
 442            {
 0443                if (_httpRequest.Headers.Contains("ocp-date"))
 444                {
 0445                    _httpRequest.Headers.Remove("ocp-date");
 446                }
 0447                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 448            }
 449
 450
 0451            if (customHeaders != null)
 452            {
 0453                foreach(var _header in customHeaders)
 454                {
 0455                    if (_httpRequest.Headers.Contains(_header.Key))
 456                    {
 0457                        _httpRequest.Headers.Remove(_header.Key);
 458                    }
 0459                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 460                }
 461            }
 462
 463            // Serialize Request
 0464            string _requestContent = null;
 465            // Set Credentials
 0466            if (Client.Credentials != null)
 467            {
 0468                cancellationToken.ThrowIfCancellationRequested();
 0469                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 470            }
 471            // Send Request
 0472            if (_shouldTrace)
 473            {
 0474                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 475            }
 0476            cancellationToken.ThrowIfCancellationRequested();
 0477            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0478            if (_shouldTrace)
 479            {
 0480                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 481            }
 0482            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0483            cancellationToken.ThrowIfCancellationRequested();
 0484            string _responseContent = null;
 0485            if ((int)_statusCode != 200)
 486            {
 0487                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 488                try
 489                {
 0490                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0491                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0492                    if (_errorBody != null)
 493                    {
 0494                        ex.Body = _errorBody;
 495                    }
 0496                }
 0497                catch (JsonException)
 498                {
 499                    // Ignore the exception
 0500                }
 0501                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0502                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0503                if (_shouldTrace)
 504                {
 0505                    ServiceClientTracing.Error(_invocationId, ex);
 506                }
 0507                _httpRequest.Dispose();
 0508                if (_httpResponse != null)
 509                {
 0510                    _httpResponse.Dispose();
 511                }
 0512                throw ex;
 513            }
 514            // Create Result
 0515            var _result = new AzureOperationResponse<IPage<Certificate>,CertificateListHeaders>();
 0516            _result.Request = _httpRequest;
 0517            _result.Response = _httpResponse;
 0518            if (_httpResponse.Headers.Contains("request-id"))
 519            {
 0520                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 521            }
 522            // Deserialize Response
 0523            if ((int)_statusCode == 200)
 524            {
 0525                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 526                try
 527                {
 0528                    _result.Body = SafeJsonConvert.DeserializeObject<Page<Certificate>>(_responseContent, Client.Deseria
 0529                }
 0530                catch (JsonException ex)
 531                {
 0532                    _httpRequest.Dispose();
 0533                    if (_httpResponse != null)
 534                    {
 0535                        _httpResponse.Dispose();
 536                    }
 0537                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 538                }
 539            }
 540            try
 541            {
 0542                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateListHeaders>(JsonSerializer.Creat
 0543            }
 0544            catch (JsonException ex)
 545            {
 0546                _httpRequest.Dispose();
 0547                if (_httpResponse != null)
 548                {
 0549                    _httpResponse.Dispose();
 550                }
 0551                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 552            }
 0553            if (_shouldTrace)
 554            {
 0555                ServiceClientTracing.Exit(_invocationId, _result);
 556            }
 0557            return _result;
 0558        }
 559
 560        /// <summary>
 561        /// Cancels a failed deletion of a Certificate from the specified Account.
 562        /// </summary>
 563        /// <remarks>
 564        /// If you try to delete a Certificate that is being used by a Pool or Compute
 565        /// Node, the status of the Certificate changes to deleteFailed. If you decide
 566        /// that you want to continue using the Certificate, you can use this operation
 567        /// to set the status of the Certificate back to active. If you intend to
 568        /// delete the Certificate, you do not need to run this operation after the
 569        /// deletion failed. You must make sure that the Certificate is not being used
 570        /// by any resources, and then you can try again to delete the Certificate.
 571        /// </remarks>
 572        /// <param name='thumbprintAlgorithm'>
 573        /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 574        /// </param>
 575        /// <param name='thumbprint'>
 576        /// The thumbprint of the Certificate being deleted.
 577        /// </param>
 578        /// <param name='certificateCancelDeletionOptions'>
 579        /// Additional parameters for the operation
 580        /// </param>
 581        /// <param name='customHeaders'>
 582        /// Headers that will be added to request.
 583        /// </param>
 584        /// <param name='cancellationToken'>
 585        /// The cancellation token.
 586        /// </param>
 587        /// <exception cref="BatchErrorException">
 588        /// Thrown when the operation returned an invalid status code
 589        /// </exception>
 590        /// <exception cref="ValidationException">
 591        /// Thrown when a required parameter is null
 592        /// </exception>
 593        /// <exception cref="System.ArgumentNullException">
 594        /// Thrown when a required parameter is null
 595        /// </exception>
 596        /// <return>
 597        /// A response object containing the response body and response headers.
 598        /// </return>
 599        public async Task<AzureOperationHeaderResponse<CertificateCancelDeletionHeaders>> CancelDeletionWithHttpMessages
 600        {
 0601            if (Client.BatchUrl == null)
 602            {
 0603                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 604            }
 0605            if (thumbprintAlgorithm == null)
 606            {
 0607                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprintAlgorithm");
 608            }
 0609            if (thumbprint == null)
 610            {
 0611                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprint");
 612            }
 0613            if (Client.ApiVersion == null)
 614            {
 0615                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 616            }
 0617            int? timeout = default(int?);
 0618            if (certificateCancelDeletionOptions != null)
 619            {
 0620                timeout = certificateCancelDeletionOptions.Timeout;
 621            }
 0622            System.Guid? clientRequestId = default(System.Guid?);
 0623            if (certificateCancelDeletionOptions != null)
 624            {
 0625                clientRequestId = certificateCancelDeletionOptions.ClientRequestId;
 626            }
 0627            bool? returnClientRequestId = default(bool?);
 0628            if (certificateCancelDeletionOptions != null)
 629            {
 0630                returnClientRequestId = certificateCancelDeletionOptions.ReturnClientRequestId;
 631            }
 0632            System.DateTime? ocpDate = default(System.DateTime?);
 0633            if (certificateCancelDeletionOptions != null)
 634            {
 0635                ocpDate = certificateCancelDeletionOptions.OcpDate;
 636            }
 637            // Tracing
 0638            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0639            string _invocationId = null;
 0640            if (_shouldTrace)
 641            {
 0642                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0643                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0644                tracingParameters.Add("thumbprintAlgorithm", thumbprintAlgorithm);
 0645                tracingParameters.Add("thumbprint", thumbprint);
 0646                tracingParameters.Add("timeout", timeout);
 0647                tracingParameters.Add("clientRequestId", clientRequestId);
 0648                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0649                tracingParameters.Add("ocpDate", ocpDate);
 0650                tracingParameters.Add("cancellationToken", cancellationToken);
 0651                ServiceClientTracing.Enter(_invocationId, this, "CancelDeletion", tracingParameters);
 652            }
 653            // Construct URL
 0654            var _baseUrl = Client.BaseUri;
 0655            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "certificates(thumbprintAlgorithm={thumbprintAlg
 0656            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0657            _url = _url.Replace("{thumbprintAlgorithm}", System.Uri.EscapeDataString(thumbprintAlgorithm));
 0658            _url = _url.Replace("{thumbprint}", System.Uri.EscapeDataString(thumbprint));
 0659            List<string> _queryParameters = new List<string>();
 0660            if (Client.ApiVersion != null)
 661            {
 0662                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 663            }
 0664            if (timeout != null)
 665            {
 0666                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 667            }
 0668            if (_queryParameters.Count > 0)
 669            {
 0670                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 671            }
 672            // Create HTTP transport objects
 0673            var _httpRequest = new HttpRequestMessage();
 0674            HttpResponseMessage _httpResponse = null;
 0675            _httpRequest.Method = new HttpMethod("POST");
 0676            _httpRequest.RequestUri = new System.Uri(_url);
 677            // Set Headers
 0678            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 679            {
 0680                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 681            }
 0682            if (Client.AcceptLanguage != null)
 683            {
 0684                if (_httpRequest.Headers.Contains("accept-language"))
 685                {
 0686                    _httpRequest.Headers.Remove("accept-language");
 687                }
 0688                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 689            }
 0690            if (clientRequestId != null)
 691            {
 0692                if (_httpRequest.Headers.Contains("client-request-id"))
 693                {
 0694                    _httpRequest.Headers.Remove("client-request-id");
 695                }
 0696                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 697            }
 0698            if (returnClientRequestId != null)
 699            {
 0700                if (_httpRequest.Headers.Contains("return-client-request-id"))
 701                {
 0702                    _httpRequest.Headers.Remove("return-client-request-id");
 703                }
 0704                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 705            }
 0706            if (ocpDate != null)
 707            {
 0708                if (_httpRequest.Headers.Contains("ocp-date"))
 709                {
 0710                    _httpRequest.Headers.Remove("ocp-date");
 711                }
 0712                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 713            }
 714
 715
 0716            if (customHeaders != null)
 717            {
 0718                foreach(var _header in customHeaders)
 719                {
 0720                    if (_httpRequest.Headers.Contains(_header.Key))
 721                    {
 0722                        _httpRequest.Headers.Remove(_header.Key);
 723                    }
 0724                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 725                }
 726            }
 727
 728            // Serialize Request
 0729            string _requestContent = null;
 730            // Set Credentials
 0731            if (Client.Credentials != null)
 732            {
 0733                cancellationToken.ThrowIfCancellationRequested();
 0734                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 735            }
 736            // Send Request
 0737            if (_shouldTrace)
 738            {
 0739                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 740            }
 0741            cancellationToken.ThrowIfCancellationRequested();
 0742            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0743            if (_shouldTrace)
 744            {
 0745                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 746            }
 0747            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0748            cancellationToken.ThrowIfCancellationRequested();
 0749            string _responseContent = null;
 0750            if ((int)_statusCode != 204)
 751            {
 0752                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 753                try
 754                {
 0755                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0756                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0757                    if (_errorBody != null)
 758                    {
 0759                        ex.Body = _errorBody;
 760                    }
 0761                }
 0762                catch (JsonException)
 763                {
 764                    // Ignore the exception
 0765                }
 0766                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0767                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0768                if (_shouldTrace)
 769                {
 0770                    ServiceClientTracing.Error(_invocationId, ex);
 771                }
 0772                _httpRequest.Dispose();
 0773                if (_httpResponse != null)
 774                {
 0775                    _httpResponse.Dispose();
 776                }
 0777                throw ex;
 778            }
 779            // Create Result
 0780            var _result = new AzureOperationHeaderResponse<CertificateCancelDeletionHeaders>();
 0781            _result.Request = _httpRequest;
 0782            _result.Response = _httpResponse;
 0783            if (_httpResponse.Headers.Contains("request-id"))
 784            {
 0785                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 786            }
 787            try
 788            {
 0789                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateCancelDeletionHeaders>(JsonSerial
 0790            }
 0791            catch (JsonException ex)
 792            {
 0793                _httpRequest.Dispose();
 0794                if (_httpResponse != null)
 795                {
 0796                    _httpResponse.Dispose();
 797                }
 0798                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 799            }
 0800            if (_shouldTrace)
 801            {
 0802                ServiceClientTracing.Exit(_invocationId, _result);
 803            }
 0804            return _result;
 0805        }
 806
 807        /// <summary>
 808        /// Deletes a Certificate from the specified Account.
 809        /// </summary>
 810        /// <remarks>
 811        /// You cannot delete a Certificate if a resource (Pool or Compute Node) is
 812        /// using it. Before you can delete a Certificate, you must therefore make sure
 813        /// that the Certificate is not associated with any existing Pools, the
 814        /// Certificate is not installed on any Nodes (even if you remove a Certificate
 815        /// from a Pool, it is not removed from existing Compute Nodes in that Pool
 816        /// until they restart), and no running Tasks depend on the Certificate. If you
 817        /// try to delete a Certificate that is in use, the deletion fails. The
 818        /// Certificate status changes to deleteFailed. You can use Cancel Delete
 819        /// Certificate to set the status back to active if you decide that you want to
 820        /// continue using the Certificate.
 821        /// </remarks>
 822        /// <param name='thumbprintAlgorithm'>
 823        /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 824        /// </param>
 825        /// <param name='thumbprint'>
 826        /// The thumbprint of the Certificate to be deleted.
 827        /// </param>
 828        /// <param name='certificateDeleteOptions'>
 829        /// Additional parameters for the operation
 830        /// </param>
 831        /// <param name='customHeaders'>
 832        /// Headers that will be added to request.
 833        /// </param>
 834        /// <param name='cancellationToken'>
 835        /// The cancellation token.
 836        /// </param>
 837        /// <exception cref="BatchErrorException">
 838        /// Thrown when the operation returned an invalid status code
 839        /// </exception>
 840        /// <exception cref="ValidationException">
 841        /// Thrown when a required parameter is null
 842        /// </exception>
 843        /// <exception cref="System.ArgumentNullException">
 844        /// Thrown when a required parameter is null
 845        /// </exception>
 846        /// <return>
 847        /// A response object containing the response body and response headers.
 848        /// </return>
 849        public async Task<AzureOperationHeaderResponse<CertificateDeleteHeaders>> DeleteWithHttpMessagesAsync(string thu
 850        {
 0851            if (Client.BatchUrl == null)
 852            {
 0853                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 854            }
 0855            if (thumbprintAlgorithm == null)
 856            {
 0857                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprintAlgorithm");
 858            }
 0859            if (thumbprint == null)
 860            {
 0861                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprint");
 862            }
 0863            if (Client.ApiVersion == null)
 864            {
 0865                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 866            }
 0867            int? timeout = default(int?);
 0868            if (certificateDeleteOptions != null)
 869            {
 0870                timeout = certificateDeleteOptions.Timeout;
 871            }
 0872            System.Guid? clientRequestId = default(System.Guid?);
 0873            if (certificateDeleteOptions != null)
 874            {
 0875                clientRequestId = certificateDeleteOptions.ClientRequestId;
 876            }
 0877            bool? returnClientRequestId = default(bool?);
 0878            if (certificateDeleteOptions != null)
 879            {
 0880                returnClientRequestId = certificateDeleteOptions.ReturnClientRequestId;
 881            }
 0882            System.DateTime? ocpDate = default(System.DateTime?);
 0883            if (certificateDeleteOptions != null)
 884            {
 0885                ocpDate = certificateDeleteOptions.OcpDate;
 886            }
 887            // Tracing
 0888            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0889            string _invocationId = null;
 0890            if (_shouldTrace)
 891            {
 0892                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0893                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0894                tracingParameters.Add("thumbprintAlgorithm", thumbprintAlgorithm);
 0895                tracingParameters.Add("thumbprint", thumbprint);
 0896                tracingParameters.Add("timeout", timeout);
 0897                tracingParameters.Add("clientRequestId", clientRequestId);
 0898                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0899                tracingParameters.Add("ocpDate", ocpDate);
 0900                tracingParameters.Add("cancellationToken", cancellationToken);
 0901                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 902            }
 903            // Construct URL
 0904            var _baseUrl = Client.BaseUri;
 0905            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "certificates(thumbprintAlgorithm={thumbprintAlg
 0906            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0907            _url = _url.Replace("{thumbprintAlgorithm}", System.Uri.EscapeDataString(thumbprintAlgorithm));
 0908            _url = _url.Replace("{thumbprint}", System.Uri.EscapeDataString(thumbprint));
 0909            List<string> _queryParameters = new List<string>();
 0910            if (Client.ApiVersion != null)
 911            {
 0912                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 913            }
 0914            if (timeout != null)
 915            {
 0916                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 917            }
 0918            if (_queryParameters.Count > 0)
 919            {
 0920                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 921            }
 922            // Create HTTP transport objects
 0923            var _httpRequest = new HttpRequestMessage();
 0924            HttpResponseMessage _httpResponse = null;
 0925            _httpRequest.Method = new HttpMethod("DELETE");
 0926            _httpRequest.RequestUri = new System.Uri(_url);
 927            // Set Headers
 0928            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 929            {
 0930                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 931            }
 0932            if (Client.AcceptLanguage != null)
 933            {
 0934                if (_httpRequest.Headers.Contains("accept-language"))
 935                {
 0936                    _httpRequest.Headers.Remove("accept-language");
 937                }
 0938                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 939            }
 0940            if (clientRequestId != null)
 941            {
 0942                if (_httpRequest.Headers.Contains("client-request-id"))
 943                {
 0944                    _httpRequest.Headers.Remove("client-request-id");
 945                }
 0946                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 947            }
 0948            if (returnClientRequestId != null)
 949            {
 0950                if (_httpRequest.Headers.Contains("return-client-request-id"))
 951                {
 0952                    _httpRequest.Headers.Remove("return-client-request-id");
 953                }
 0954                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 955            }
 0956            if (ocpDate != null)
 957            {
 0958                if (_httpRequest.Headers.Contains("ocp-date"))
 959                {
 0960                    _httpRequest.Headers.Remove("ocp-date");
 961                }
 0962                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 963            }
 964
 965
 0966            if (customHeaders != null)
 967            {
 0968                foreach(var _header in customHeaders)
 969                {
 0970                    if (_httpRequest.Headers.Contains(_header.Key))
 971                    {
 0972                        _httpRequest.Headers.Remove(_header.Key);
 973                    }
 0974                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 975                }
 976            }
 977
 978            // Serialize Request
 0979            string _requestContent = null;
 980            // Set Credentials
 0981            if (Client.Credentials != null)
 982            {
 0983                cancellationToken.ThrowIfCancellationRequested();
 0984                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 985            }
 986            // Send Request
 0987            if (_shouldTrace)
 988            {
 0989                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 990            }
 0991            cancellationToken.ThrowIfCancellationRequested();
 0992            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0993            if (_shouldTrace)
 994            {
 0995                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 996            }
 0997            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0998            cancellationToken.ThrowIfCancellationRequested();
 0999            string _responseContent = null;
 01000            if ((int)_statusCode != 202)
 1001            {
 01002                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1003                try
 1004                {
 01005                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01006                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01007                    if (_errorBody != null)
 1008                    {
 01009                        ex.Body = _errorBody;
 1010                    }
 01011                }
 01012                catch (JsonException)
 1013                {
 1014                    // Ignore the exception
 01015                }
 01016                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01017                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01018                if (_shouldTrace)
 1019                {
 01020                    ServiceClientTracing.Error(_invocationId, ex);
 1021                }
 01022                _httpRequest.Dispose();
 01023                if (_httpResponse != null)
 1024                {
 01025                    _httpResponse.Dispose();
 1026                }
 01027                throw ex;
 1028            }
 1029            // Create Result
 01030            var _result = new AzureOperationHeaderResponse<CertificateDeleteHeaders>();
 01031            _result.Request = _httpRequest;
 01032            _result.Response = _httpResponse;
 01033            if (_httpResponse.Headers.Contains("request-id"))
 1034            {
 01035                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1036            }
 1037            try
 1038            {
 01039                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateDeleteHeaders>(JsonSerializer.Cre
 01040            }
 01041            catch (JsonException ex)
 1042            {
 01043                _httpRequest.Dispose();
 01044                if (_httpResponse != null)
 1045                {
 01046                    _httpResponse.Dispose();
 1047                }
 01048                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1049            }
 01050            if (_shouldTrace)
 1051            {
 01052                ServiceClientTracing.Exit(_invocationId, _result);
 1053            }
 01054            return _result;
 01055        }
 1056
 1057        /// <summary>
 1058        /// Gets information about the specified Certificate.
 1059        /// </summary>
 1060        /// <param name='thumbprintAlgorithm'>
 1061        /// The algorithm used to derive the thumbprint parameter. This must be sha1.
 1062        /// </param>
 1063        /// <param name='thumbprint'>
 1064        /// The thumbprint of the Certificate to get.
 1065        /// </param>
 1066        /// <param name='certificateGetOptions'>
 1067        /// Additional parameters for the operation
 1068        /// </param>
 1069        /// <param name='customHeaders'>
 1070        /// Headers that will be added to request.
 1071        /// </param>
 1072        /// <param name='cancellationToken'>
 1073        /// The cancellation token.
 1074        /// </param>
 1075        /// <exception cref="BatchErrorException">
 1076        /// Thrown when the operation returned an invalid status code
 1077        /// </exception>
 1078        /// <exception cref="SerializationException">
 1079        /// Thrown when unable to deserialize the response
 1080        /// </exception>
 1081        /// <exception cref="ValidationException">
 1082        /// Thrown when a required parameter is null
 1083        /// </exception>
 1084        /// <exception cref="System.ArgumentNullException">
 1085        /// Thrown when a required parameter is null
 1086        /// </exception>
 1087        /// <return>
 1088        /// A response object containing the response body and response headers.
 1089        /// </return>
 1090        public async Task<AzureOperationResponse<Certificate,CertificateGetHeaders>> GetWithHttpMessagesAsync(string thu
 1091        {
 11092            if (Client.BatchUrl == null)
 1093            {
 01094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1095            }
 11096            if (thumbprintAlgorithm == null)
 1097            {
 11098                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprintAlgorithm");
 1099            }
 01100            if (thumbprint == null)
 1101            {
 01102                throw new ValidationException(ValidationRules.CannotBeNull, "thumbprint");
 1103            }
 01104            if (Client.ApiVersion == null)
 1105            {
 01106                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1107            }
 01108            string select = default(string);
 01109            if (certificateGetOptions != null)
 1110            {
 01111                select = certificateGetOptions.Select;
 1112            }
 01113            int? timeout = default(int?);
 01114            if (certificateGetOptions != null)
 1115            {
 01116                timeout = certificateGetOptions.Timeout;
 1117            }
 01118            System.Guid? clientRequestId = default(System.Guid?);
 01119            if (certificateGetOptions != null)
 1120            {
 01121                clientRequestId = certificateGetOptions.ClientRequestId;
 1122            }
 01123            bool? returnClientRequestId = default(bool?);
 01124            if (certificateGetOptions != null)
 1125            {
 01126                returnClientRequestId = certificateGetOptions.ReturnClientRequestId;
 1127            }
 01128            System.DateTime? ocpDate = default(System.DateTime?);
 01129            if (certificateGetOptions != null)
 1130            {
 01131                ocpDate = certificateGetOptions.OcpDate;
 1132            }
 1133            // Tracing
 01134            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01135            string _invocationId = null;
 01136            if (_shouldTrace)
 1137            {
 01138                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01139                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01140                tracingParameters.Add("thumbprintAlgorithm", thumbprintAlgorithm);
 01141                tracingParameters.Add("thumbprint", thumbprint);
 01142                tracingParameters.Add("select", select);
 01143                tracingParameters.Add("timeout", timeout);
 01144                tracingParameters.Add("clientRequestId", clientRequestId);
 01145                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01146                tracingParameters.Add("ocpDate", ocpDate);
 01147                tracingParameters.Add("cancellationToken", cancellationToken);
 01148                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 1149            }
 1150            // Construct URL
 01151            var _baseUrl = Client.BaseUri;
 01152            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "certificates(thumbprintAlgorithm={thumbprintAlg
 01153            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01154            _url = _url.Replace("{thumbprintAlgorithm}", System.Uri.EscapeDataString(thumbprintAlgorithm));
 01155            _url = _url.Replace("{thumbprint}", System.Uri.EscapeDataString(thumbprint));
 01156            List<string> _queryParameters = new List<string>();
 01157            if (Client.ApiVersion != null)
 1158            {
 01159                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1160            }
 01161            if (select != null)
 1162            {
 01163                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 1164            }
 01165            if (timeout != null)
 1166            {
 01167                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1168            }
 01169            if (_queryParameters.Count > 0)
 1170            {
 01171                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1172            }
 1173            // Create HTTP transport objects
 01174            var _httpRequest = new HttpRequestMessage();
 01175            HttpResponseMessage _httpResponse = null;
 01176            _httpRequest.Method = new HttpMethod("GET");
 01177            _httpRequest.RequestUri = new System.Uri(_url);
 1178            // Set Headers
 01179            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1180            {
 01181                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1182            }
 01183            if (Client.AcceptLanguage != null)
 1184            {
 01185                if (_httpRequest.Headers.Contains("accept-language"))
 1186                {
 01187                    _httpRequest.Headers.Remove("accept-language");
 1188                }
 01189                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1190            }
 01191            if (clientRequestId != null)
 1192            {
 01193                if (_httpRequest.Headers.Contains("client-request-id"))
 1194                {
 01195                    _httpRequest.Headers.Remove("client-request-id");
 1196                }
 01197                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1198            }
 01199            if (returnClientRequestId != null)
 1200            {
 01201                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1202                {
 01203                    _httpRequest.Headers.Remove("return-client-request-id");
 1204                }
 01205                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1206            }
 01207            if (ocpDate != null)
 1208            {
 01209                if (_httpRequest.Headers.Contains("ocp-date"))
 1210                {
 01211                    _httpRequest.Headers.Remove("ocp-date");
 1212                }
 01213                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1214            }
 1215
 1216
 01217            if (customHeaders != null)
 1218            {
 01219                foreach(var _header in customHeaders)
 1220                {
 01221                    if (_httpRequest.Headers.Contains(_header.Key))
 1222                    {
 01223                        _httpRequest.Headers.Remove(_header.Key);
 1224                    }
 01225                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1226                }
 1227            }
 1228
 1229            // Serialize Request
 01230            string _requestContent = null;
 1231            // Set Credentials
 01232            if (Client.Credentials != null)
 1233            {
 01234                cancellationToken.ThrowIfCancellationRequested();
 01235                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1236            }
 1237            // Send Request
 01238            if (_shouldTrace)
 1239            {
 01240                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1241            }
 01242            cancellationToken.ThrowIfCancellationRequested();
 01243            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01244            if (_shouldTrace)
 1245            {
 01246                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1247            }
 01248            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01249            cancellationToken.ThrowIfCancellationRequested();
 01250            string _responseContent = null;
 01251            if ((int)_statusCode != 200)
 1252            {
 01253                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1254                try
 1255                {
 01256                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01257                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01258                    if (_errorBody != null)
 1259                    {
 01260                        ex.Body = _errorBody;
 1261                    }
 01262                }
 01263                catch (JsonException)
 1264                {
 1265                    // Ignore the exception
 01266                }
 01267                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01268                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01269                if (_shouldTrace)
 1270                {
 01271                    ServiceClientTracing.Error(_invocationId, ex);
 1272                }
 01273                _httpRequest.Dispose();
 01274                if (_httpResponse != null)
 1275                {
 01276                    _httpResponse.Dispose();
 1277                }
 01278                throw ex;
 1279            }
 1280            // Create Result
 01281            var _result = new AzureOperationResponse<Certificate,CertificateGetHeaders>();
 01282            _result.Request = _httpRequest;
 01283            _result.Response = _httpResponse;
 01284            if (_httpResponse.Headers.Contains("request-id"))
 1285            {
 01286                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1287            }
 1288            // Deserialize Response
 01289            if ((int)_statusCode == 200)
 1290            {
 01291                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1292                try
 1293                {
 01294                    _result.Body = SafeJsonConvert.DeserializeObject<Certificate>(_responseContent, Client.Deserializati
 01295                }
 01296                catch (JsonException ex)
 1297                {
 01298                    _httpRequest.Dispose();
 01299                    if (_httpResponse != null)
 1300                    {
 01301                        _httpResponse.Dispose();
 1302                    }
 01303                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1304                }
 1305            }
 1306            try
 1307            {
 01308                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateGetHeaders>(JsonSerializer.Create
 01309            }
 01310            catch (JsonException ex)
 1311            {
 01312                _httpRequest.Dispose();
 01313                if (_httpResponse != null)
 1314                {
 01315                    _httpResponse.Dispose();
 1316                }
 01317                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1318            }
 01319            if (_shouldTrace)
 1320            {
 01321                ServiceClientTracing.Exit(_invocationId, _result);
 1322            }
 01323            return _result;
 01324        }
 1325
 1326        /// <summary>
 1327        /// Lists all of the Certificates that have been added to the specified
 1328        /// Account.
 1329        /// </summary>
 1330        /// <param name='nextPageLink'>
 1331        /// The NextLink from the previous successful call to List operation.
 1332        /// </param>
 1333        /// <param name='certificateListNextOptions'>
 1334        /// Additional parameters for the operation
 1335        /// </param>
 1336        /// <param name='customHeaders'>
 1337        /// Headers that will be added to request.
 1338        /// </param>
 1339        /// <param name='cancellationToken'>
 1340        /// The cancellation token.
 1341        /// </param>
 1342        /// <exception cref="BatchErrorException">
 1343        /// Thrown when the operation returned an invalid status code
 1344        /// </exception>
 1345        /// <exception cref="SerializationException">
 1346        /// Thrown when unable to deserialize the response
 1347        /// </exception>
 1348        /// <exception cref="ValidationException">
 1349        /// Thrown when a required parameter is null
 1350        /// </exception>
 1351        /// <exception cref="System.ArgumentNullException">
 1352        /// Thrown when a required parameter is null
 1353        /// </exception>
 1354        /// <return>
 1355        /// A response object containing the response body and response headers.
 1356        /// </return>
 1357        public async Task<AzureOperationResponse<IPage<Certificate>,CertificateListHeaders>> ListNextWithHttpMessagesAsy
 1358        {
 01359            if (nextPageLink == null)
 1360            {
 01361                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 1362            }
 01363            System.Guid? clientRequestId = default(System.Guid?);
 01364            if (certificateListNextOptions != null)
 1365            {
 01366                clientRequestId = certificateListNextOptions.ClientRequestId;
 1367            }
 01368            bool? returnClientRequestId = default(bool?);
 01369            if (certificateListNextOptions != null)
 1370            {
 01371                returnClientRequestId = certificateListNextOptions.ReturnClientRequestId;
 1372            }
 01373            System.DateTime? ocpDate = default(System.DateTime?);
 01374            if (certificateListNextOptions != null)
 1375            {
 01376                ocpDate = certificateListNextOptions.OcpDate;
 1377            }
 1378            // Tracing
 01379            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01380            string _invocationId = null;
 01381            if (_shouldTrace)
 1382            {
 01383                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01384                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01385                tracingParameters.Add("nextPageLink", nextPageLink);
 01386                tracingParameters.Add("clientRequestId", clientRequestId);
 01387                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01388                tracingParameters.Add("ocpDate", ocpDate);
 01389                tracingParameters.Add("cancellationToken", cancellationToken);
 01390                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 1391            }
 1392            // Construct URL
 01393            string _url = "{nextLink}";
 01394            _url = _url.Replace("{nextLink}", nextPageLink);
 01395            List<string> _queryParameters = new List<string>();
 01396            if (_queryParameters.Count > 0)
 1397            {
 01398                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1399            }
 1400            // Create HTTP transport objects
 01401            var _httpRequest = new HttpRequestMessage();
 01402            HttpResponseMessage _httpResponse = null;
 01403            _httpRequest.Method = new HttpMethod("GET");
 01404            _httpRequest.RequestUri = new System.Uri(_url);
 1405            // Set Headers
 01406            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1407            {
 01408                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1409            }
 01410            if (Client.AcceptLanguage != null)
 1411            {
 01412                if (_httpRequest.Headers.Contains("accept-language"))
 1413                {
 01414                    _httpRequest.Headers.Remove("accept-language");
 1415                }
 01416                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1417            }
 01418            if (clientRequestId != null)
 1419            {
 01420                if (_httpRequest.Headers.Contains("client-request-id"))
 1421                {
 01422                    _httpRequest.Headers.Remove("client-request-id");
 1423                }
 01424                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1425            }
 01426            if (returnClientRequestId != null)
 1427            {
 01428                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1429                {
 01430                    _httpRequest.Headers.Remove("return-client-request-id");
 1431                }
 01432                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1433            }
 01434            if (ocpDate != null)
 1435            {
 01436                if (_httpRequest.Headers.Contains("ocp-date"))
 1437                {
 01438                    _httpRequest.Headers.Remove("ocp-date");
 1439                }
 01440                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1441            }
 1442
 1443
 01444            if (customHeaders != null)
 1445            {
 01446                foreach(var _header in customHeaders)
 1447                {
 01448                    if (_httpRequest.Headers.Contains(_header.Key))
 1449                    {
 01450                        _httpRequest.Headers.Remove(_header.Key);
 1451                    }
 01452                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1453                }
 1454            }
 1455
 1456            // Serialize Request
 01457            string _requestContent = null;
 1458            // Set Credentials
 01459            if (Client.Credentials != null)
 1460            {
 01461                cancellationToken.ThrowIfCancellationRequested();
 01462                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1463            }
 1464            // Send Request
 01465            if (_shouldTrace)
 1466            {
 01467                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1468            }
 01469            cancellationToken.ThrowIfCancellationRequested();
 01470            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01471            if (_shouldTrace)
 1472            {
 01473                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1474            }
 01475            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01476            cancellationToken.ThrowIfCancellationRequested();
 01477            string _responseContent = null;
 01478            if ((int)_statusCode != 200)
 1479            {
 01480                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1481                try
 1482                {
 01483                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01484                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01485                    if (_errorBody != null)
 1486                    {
 01487                        ex.Body = _errorBody;
 1488                    }
 01489                }
 01490                catch (JsonException)
 1491                {
 1492                    // Ignore the exception
 01493                }
 01494                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01495                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01496                if (_shouldTrace)
 1497                {
 01498                    ServiceClientTracing.Error(_invocationId, ex);
 1499                }
 01500                _httpRequest.Dispose();
 01501                if (_httpResponse != null)
 1502                {
 01503                    _httpResponse.Dispose();
 1504                }
 01505                throw ex;
 1506            }
 1507            // Create Result
 01508            var _result = new AzureOperationResponse<IPage<Certificate>,CertificateListHeaders>();
 01509            _result.Request = _httpRequest;
 01510            _result.Response = _httpResponse;
 01511            if (_httpResponse.Headers.Contains("request-id"))
 1512            {
 01513                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1514            }
 1515            // Deserialize Response
 01516            if ((int)_statusCode == 200)
 1517            {
 01518                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1519                try
 1520                {
 01521                    _result.Body = SafeJsonConvert.DeserializeObject<Page<Certificate>>(_responseContent, Client.Deseria
 01522                }
 01523                catch (JsonException ex)
 1524                {
 01525                    _httpRequest.Dispose();
 01526                    if (_httpResponse != null)
 1527                    {
 01528                        _httpResponse.Dispose();
 1529                    }
 01530                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1531                }
 1532            }
 1533            try
 1534            {
 01535                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<CertificateListHeaders>(JsonSerializer.Creat
 01536            }
 01537            catch (JsonException ex)
 1538            {
 01539                _httpRequest.Dispose();
 01540                if (_httpResponse != null)
 1541                {
 01542                    _httpResponse.Dispose();
 1543                }
 01544                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1545            }
 01546            if (_shouldTrace)
 1547            {
 01548                ServiceClientTracing.Exit(_invocationId, _result);
 1549            }
 01550            return _result;
 01551        }
 1552
 1553    }
 1554}