< Summary

Class:Microsoft.Azure.Batch.Protocol.AccountOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\AccountOperations.cs
Covered lines:4
Uncovered lines:482
Coverable lines:486
Total lines:1029
Line coverage:0.8% (4 of 486)
Covered branches:1
Total branches:294
Branch coverage:0.3% (1 of 294)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
ListSupportedImagesWithHttpMessagesAsync()-0%0%
ListPoolNodeCountsWithHttpMessagesAsync()-0%0%
ListSupportedImagesNextWithHttpMessagesAsync()-0%0%
ListPoolNodeCountsNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\AccountOperations.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    /// AccountOperations operations.
 28    /// </summary>
 29    internal partial class AccountOperations : IServiceOperations<BatchServiceClient>, IAccountOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the AccountOperations 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 AccountOperations(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>
 052        public BatchServiceClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Lists all Virtual Machine Images supported by the Azure Batch service.
 56        /// </summary>
 57        /// <param name='accountListSupportedImagesOptions'>
 58        /// Additional parameters for the operation
 59        /// </param>
 60        /// <param name='customHeaders'>
 61        /// Headers that will be added to request.
 62        /// </param>
 63        /// <param name='cancellationToken'>
 64        /// The cancellation token.
 65        /// </param>
 66        /// <exception cref="BatchErrorException">
 67        /// Thrown when the operation returned an invalid status code
 68        /// </exception>
 69        /// <exception cref="SerializationException">
 70        /// Thrown when unable to deserialize the response
 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<AzureOperationResponse<IPage<ImageInformation>,AccountListSupportedImagesHeaders>> ListSupport
 82        {
 083            if (Client.BatchUrl == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 86            }
 087            if (Client.ApiVersion == null)
 88            {
 089                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 90            }
 091            string filter = default(string);
 092            if (accountListSupportedImagesOptions != null)
 93            {
 094                filter = accountListSupportedImagesOptions.Filter;
 95            }
 096            int? maxResults = default(int?);
 097            if (accountListSupportedImagesOptions != null)
 98            {
 099                maxResults = accountListSupportedImagesOptions.MaxResults;
 100            }
 0101            int? timeout = default(int?);
 0102            if (accountListSupportedImagesOptions != null)
 103            {
 0104                timeout = accountListSupportedImagesOptions.Timeout;
 105            }
 0106            System.Guid? clientRequestId = default(System.Guid?);
 0107            if (accountListSupportedImagesOptions != null)
 108            {
 0109                clientRequestId = accountListSupportedImagesOptions.ClientRequestId;
 110            }
 0111            bool? returnClientRequestId = default(bool?);
 0112            if (accountListSupportedImagesOptions != null)
 113            {
 0114                returnClientRequestId = accountListSupportedImagesOptions.ReturnClientRequestId;
 115            }
 0116            System.DateTime? ocpDate = default(System.DateTime?);
 0117            if (accountListSupportedImagesOptions != null)
 118            {
 0119                ocpDate = accountListSupportedImagesOptions.OcpDate;
 120            }
 121            // Tracing
 0122            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0123            string _invocationId = null;
 0124            if (_shouldTrace)
 125            {
 0126                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0127                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0128                tracingParameters.Add("filter", filter);
 0129                tracingParameters.Add("maxResults", maxResults);
 0130                tracingParameters.Add("timeout", timeout);
 0131                tracingParameters.Add("clientRequestId", clientRequestId);
 0132                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0133                tracingParameters.Add("ocpDate", ocpDate);
 0134                tracingParameters.Add("cancellationToken", cancellationToken);
 0135                ServiceClientTracing.Enter(_invocationId, this, "ListSupportedImages", tracingParameters);
 136            }
 137            // Construct URL
 0138            var _baseUrl = Client.BaseUri;
 0139            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "supportedimages";
 0140            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0141            List<string> _queryParameters = new List<string>();
 0142            if (Client.ApiVersion != null)
 143            {
 0144                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 145            }
 0146            if (filter != null)
 147            {
 0148                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 149            }
 0150            if (maxResults != null)
 151            {
 0152                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 153            }
 0154            if (timeout != null)
 155            {
 0156                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 157            }
 0158            if (_queryParameters.Count > 0)
 159            {
 0160                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 161            }
 162            // Create HTTP transport objects
 0163            var _httpRequest = new HttpRequestMessage();
 0164            HttpResponseMessage _httpResponse = null;
 0165            _httpRequest.Method = new HttpMethod("GET");
 0166            _httpRequest.RequestUri = new System.Uri(_url);
 167            // Set Headers
 0168            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 169            {
 0170                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 171            }
 0172            if (Client.AcceptLanguage != null)
 173            {
 0174                if (_httpRequest.Headers.Contains("accept-language"))
 175                {
 0176                    _httpRequest.Headers.Remove("accept-language");
 177                }
 0178                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 179            }
 0180            if (clientRequestId != null)
 181            {
 0182                if (_httpRequest.Headers.Contains("client-request-id"))
 183                {
 0184                    _httpRequest.Headers.Remove("client-request-id");
 185                }
 0186                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 187            }
 0188            if (returnClientRequestId != null)
 189            {
 0190                if (_httpRequest.Headers.Contains("return-client-request-id"))
 191                {
 0192                    _httpRequest.Headers.Remove("return-client-request-id");
 193                }
 0194                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 195            }
 0196            if (ocpDate != null)
 197            {
 0198                if (_httpRequest.Headers.Contains("ocp-date"))
 199                {
 0200                    _httpRequest.Headers.Remove("ocp-date");
 201                }
 0202                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 203            }
 204
 205
 0206            if (customHeaders != null)
 207            {
 0208                foreach(var _header in customHeaders)
 209                {
 0210                    if (_httpRequest.Headers.Contains(_header.Key))
 211                    {
 0212                        _httpRequest.Headers.Remove(_header.Key);
 213                    }
 0214                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 215                }
 216            }
 217
 218            // Serialize Request
 0219            string _requestContent = null;
 220            // Set Credentials
 0221            if (Client.Credentials != null)
 222            {
 0223                cancellationToken.ThrowIfCancellationRequested();
 0224                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 225            }
 226            // Send Request
 0227            if (_shouldTrace)
 228            {
 0229                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 230            }
 0231            cancellationToken.ThrowIfCancellationRequested();
 0232            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0233            if (_shouldTrace)
 234            {
 0235                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 236            }
 0237            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0238            cancellationToken.ThrowIfCancellationRequested();
 0239            string _responseContent = null;
 0240            if ((int)_statusCode != 200)
 241            {
 0242                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 243                try
 244                {
 0245                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0246                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0247                    if (_errorBody != null)
 248                    {
 0249                        ex.Body = _errorBody;
 250                    }
 0251                }
 0252                catch (JsonException)
 253                {
 254                    // Ignore the exception
 0255                }
 0256                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0257                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0258                if (_shouldTrace)
 259                {
 0260                    ServiceClientTracing.Error(_invocationId, ex);
 261                }
 0262                _httpRequest.Dispose();
 0263                if (_httpResponse != null)
 264                {
 0265                    _httpResponse.Dispose();
 266                }
 0267                throw ex;
 268            }
 269            // Create Result
 0270            var _result = new AzureOperationResponse<IPage<ImageInformation>,AccountListSupportedImagesHeaders>();
 0271            _result.Request = _httpRequest;
 0272            _result.Response = _httpResponse;
 0273            if (_httpResponse.Headers.Contains("request-id"))
 274            {
 0275                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 276            }
 277            // Deserialize Response
 0278            if ((int)_statusCode == 200)
 279            {
 0280                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 281                try
 282                {
 0283                    _result.Body = SafeJsonConvert.DeserializeObject<Page<ImageInformation>>(_responseContent, Client.De
 0284                }
 0285                catch (JsonException ex)
 286                {
 0287                    _httpRequest.Dispose();
 0288                    if (_httpResponse != null)
 289                    {
 0290                        _httpResponse.Dispose();
 291                    }
 0292                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 293                }
 294            }
 295            try
 296            {
 0297                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<AccountListSupportedImagesHeaders>(JsonSeria
 0298            }
 0299            catch (JsonException ex)
 300            {
 0301                _httpRequest.Dispose();
 0302                if (_httpResponse != null)
 303                {
 0304                    _httpResponse.Dispose();
 305                }
 0306                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 307            }
 0308            if (_shouldTrace)
 309            {
 0310                ServiceClientTracing.Exit(_invocationId, _result);
 311            }
 0312            return _result;
 0313        }
 314
 315        /// <summary>
 316        /// Gets the number of Compute Nodes in each state, grouped by Pool.
 317        /// </summary>
 318        /// <param name='accountListPoolNodeCountsOptions'>
 319        /// Additional parameters for the operation
 320        /// </param>
 321        /// <param name='customHeaders'>
 322        /// Headers that will be added to request.
 323        /// </param>
 324        /// <param name='cancellationToken'>
 325        /// The cancellation token.
 326        /// </param>
 327        /// <exception cref="BatchErrorException">
 328        /// Thrown when the operation returned an invalid status code
 329        /// </exception>
 330        /// <exception cref="SerializationException">
 331        /// Thrown when unable to deserialize the response
 332        /// </exception>
 333        /// <exception cref="ValidationException">
 334        /// Thrown when a required parameter is null
 335        /// </exception>
 336        /// <exception cref="System.ArgumentNullException">
 337        /// Thrown when a required parameter is null
 338        /// </exception>
 339        /// <return>
 340        /// A response object containing the response body and response headers.
 341        /// </return>
 342        public async Task<AzureOperationResponse<IPage<PoolNodeCounts>,AccountListPoolNodeCountsHeaders>> ListPoolNodeCo
 343        {
 0344            if (Client.BatchUrl == null)
 345            {
 0346                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 347            }
 0348            if (Client.ApiVersion == null)
 349            {
 0350                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 351            }
 0352            string filter = default(string);
 0353            if (accountListPoolNodeCountsOptions != null)
 354            {
 0355                filter = accountListPoolNodeCountsOptions.Filter;
 356            }
 0357            int? maxResults = default(int?);
 0358            if (accountListPoolNodeCountsOptions != null)
 359            {
 0360                maxResults = accountListPoolNodeCountsOptions.MaxResults;
 361            }
 0362            int? timeout = default(int?);
 0363            if (accountListPoolNodeCountsOptions != null)
 364            {
 0365                timeout = accountListPoolNodeCountsOptions.Timeout;
 366            }
 0367            System.Guid? clientRequestId = default(System.Guid?);
 0368            if (accountListPoolNodeCountsOptions != null)
 369            {
 0370                clientRequestId = accountListPoolNodeCountsOptions.ClientRequestId;
 371            }
 0372            bool? returnClientRequestId = default(bool?);
 0373            if (accountListPoolNodeCountsOptions != null)
 374            {
 0375                returnClientRequestId = accountListPoolNodeCountsOptions.ReturnClientRequestId;
 376            }
 0377            System.DateTime? ocpDate = default(System.DateTime?);
 0378            if (accountListPoolNodeCountsOptions != null)
 379            {
 0380                ocpDate = accountListPoolNodeCountsOptions.OcpDate;
 381            }
 382            // Tracing
 0383            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0384            string _invocationId = null;
 0385            if (_shouldTrace)
 386            {
 0387                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0388                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0389                tracingParameters.Add("filter", filter);
 0390                tracingParameters.Add("maxResults", maxResults);
 0391                tracingParameters.Add("timeout", timeout);
 0392                tracingParameters.Add("clientRequestId", clientRequestId);
 0393                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0394                tracingParameters.Add("ocpDate", ocpDate);
 0395                tracingParameters.Add("cancellationToken", cancellationToken);
 0396                ServiceClientTracing.Enter(_invocationId, this, "ListPoolNodeCounts", tracingParameters);
 397            }
 398            // Construct URL
 0399            var _baseUrl = Client.BaseUri;
 0400            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "nodecounts";
 0401            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0402            List<string> _queryParameters = new List<string>();
 0403            if (Client.ApiVersion != null)
 404            {
 0405                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 406            }
 0407            if (filter != null)
 408            {
 0409                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 410            }
 0411            if (maxResults != null)
 412            {
 0413                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 414            }
 0415            if (timeout != null)
 416            {
 0417                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 418            }
 0419            if (_queryParameters.Count > 0)
 420            {
 0421                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 422            }
 423            // Create HTTP transport objects
 0424            var _httpRequest = new HttpRequestMessage();
 0425            HttpResponseMessage _httpResponse = null;
 0426            _httpRequest.Method = new HttpMethod("GET");
 0427            _httpRequest.RequestUri = new System.Uri(_url);
 428            // Set Headers
 0429            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 430            {
 0431                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 432            }
 0433            if (Client.AcceptLanguage != null)
 434            {
 0435                if (_httpRequest.Headers.Contains("accept-language"))
 436                {
 0437                    _httpRequest.Headers.Remove("accept-language");
 438                }
 0439                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 440            }
 0441            if (clientRequestId != null)
 442            {
 0443                if (_httpRequest.Headers.Contains("client-request-id"))
 444                {
 0445                    _httpRequest.Headers.Remove("client-request-id");
 446                }
 0447                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 448            }
 0449            if (returnClientRequestId != null)
 450            {
 0451                if (_httpRequest.Headers.Contains("return-client-request-id"))
 452                {
 0453                    _httpRequest.Headers.Remove("return-client-request-id");
 454                }
 0455                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 456            }
 0457            if (ocpDate != null)
 458            {
 0459                if (_httpRequest.Headers.Contains("ocp-date"))
 460                {
 0461                    _httpRequest.Headers.Remove("ocp-date");
 462                }
 0463                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 464            }
 465
 466
 0467            if (customHeaders != null)
 468            {
 0469                foreach(var _header in customHeaders)
 470                {
 0471                    if (_httpRequest.Headers.Contains(_header.Key))
 472                    {
 0473                        _httpRequest.Headers.Remove(_header.Key);
 474                    }
 0475                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 476                }
 477            }
 478
 479            // Serialize Request
 0480            string _requestContent = null;
 481            // Set Credentials
 0482            if (Client.Credentials != null)
 483            {
 0484                cancellationToken.ThrowIfCancellationRequested();
 0485                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 486            }
 487            // Send Request
 0488            if (_shouldTrace)
 489            {
 0490                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 491            }
 0492            cancellationToken.ThrowIfCancellationRequested();
 0493            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0494            if (_shouldTrace)
 495            {
 0496                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 497            }
 0498            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0499            cancellationToken.ThrowIfCancellationRequested();
 0500            string _responseContent = null;
 0501            if ((int)_statusCode != 200)
 502            {
 0503                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 504                try
 505                {
 0506                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0507                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0508                    if (_errorBody != null)
 509                    {
 0510                        ex.Body = _errorBody;
 511                    }
 0512                }
 0513                catch (JsonException)
 514                {
 515                    // Ignore the exception
 0516                }
 0517                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0518                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0519                if (_shouldTrace)
 520                {
 0521                    ServiceClientTracing.Error(_invocationId, ex);
 522                }
 0523                _httpRequest.Dispose();
 0524                if (_httpResponse != null)
 525                {
 0526                    _httpResponse.Dispose();
 527                }
 0528                throw ex;
 529            }
 530            // Create Result
 0531            var _result = new AzureOperationResponse<IPage<PoolNodeCounts>,AccountListPoolNodeCountsHeaders>();
 0532            _result.Request = _httpRequest;
 0533            _result.Response = _httpResponse;
 0534            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 535            {
 0536                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 537            }
 538            // Deserialize Response
 0539            if ((int)_statusCode == 200)
 540            {
 0541                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 542                try
 543                {
 0544                    _result.Body = SafeJsonConvert.DeserializeObject<Page<PoolNodeCounts>>(_responseContent, Client.Dese
 0545                }
 0546                catch (JsonException ex)
 547                {
 0548                    _httpRequest.Dispose();
 0549                    if (_httpResponse != null)
 550                    {
 0551                        _httpResponse.Dispose();
 552                    }
 0553                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 554                }
 555            }
 556            try
 557            {
 0558                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<AccountListPoolNodeCountsHeaders>(JsonSerial
 0559            }
 0560            catch (JsonException ex)
 561            {
 0562                _httpRequest.Dispose();
 0563                if (_httpResponse != null)
 564                {
 0565                    _httpResponse.Dispose();
 566                }
 0567                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 568            }
 0569            if (_shouldTrace)
 570            {
 0571                ServiceClientTracing.Exit(_invocationId, _result);
 572            }
 0573            return _result;
 0574        }
 575
 576        /// <summary>
 577        /// Lists all Virtual Machine Images supported by the Azure Batch service.
 578        /// </summary>
 579        /// <param name='nextPageLink'>
 580        /// The NextLink from the previous successful call to List operation.
 581        /// </param>
 582        /// <param name='accountListSupportedImagesNextOptions'>
 583        /// Additional parameters for the operation
 584        /// </param>
 585        /// <param name='customHeaders'>
 586        /// Headers that will be added to request.
 587        /// </param>
 588        /// <param name='cancellationToken'>
 589        /// The cancellation token.
 590        /// </param>
 591        /// <exception cref="BatchErrorException">
 592        /// Thrown when the operation returned an invalid status code
 593        /// </exception>
 594        /// <exception cref="SerializationException">
 595        /// Thrown when unable to deserialize the response
 596        /// </exception>
 597        /// <exception cref="ValidationException">
 598        /// Thrown when a required parameter is null
 599        /// </exception>
 600        /// <exception cref="System.ArgumentNullException">
 601        /// Thrown when a required parameter is null
 602        /// </exception>
 603        /// <return>
 604        /// A response object containing the response body and response headers.
 605        /// </return>
 606        public async Task<AzureOperationResponse<IPage<ImageInformation>,AccountListSupportedImagesHeaders>> ListSupport
 607        {
 0608            if (nextPageLink == null)
 609            {
 0610                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 611            }
 0612            System.Guid? clientRequestId = default(System.Guid?);
 0613            if (accountListSupportedImagesNextOptions != null)
 614            {
 0615                clientRequestId = accountListSupportedImagesNextOptions.ClientRequestId;
 616            }
 0617            bool? returnClientRequestId = default(bool?);
 0618            if (accountListSupportedImagesNextOptions != null)
 619            {
 0620                returnClientRequestId = accountListSupportedImagesNextOptions.ReturnClientRequestId;
 621            }
 0622            System.DateTime? ocpDate = default(System.DateTime?);
 0623            if (accountListSupportedImagesNextOptions != null)
 624            {
 0625                ocpDate = accountListSupportedImagesNextOptions.OcpDate;
 626            }
 627            // Tracing
 0628            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0629            string _invocationId = null;
 0630            if (_shouldTrace)
 631            {
 0632                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0633                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0634                tracingParameters.Add("nextPageLink", nextPageLink);
 0635                tracingParameters.Add("clientRequestId", clientRequestId);
 0636                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0637                tracingParameters.Add("ocpDate", ocpDate);
 0638                tracingParameters.Add("cancellationToken", cancellationToken);
 0639                ServiceClientTracing.Enter(_invocationId, this, "ListSupportedImagesNext", tracingParameters);
 640            }
 641            // Construct URL
 0642            string _url = "{nextLink}";
 0643            _url = _url.Replace("{nextLink}", nextPageLink);
 0644            List<string> _queryParameters = new List<string>();
 0645            if (_queryParameters.Count > 0)
 646            {
 0647                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 648            }
 649            // Create HTTP transport objects
 0650            var _httpRequest = new HttpRequestMessage();
 0651            HttpResponseMessage _httpResponse = null;
 0652            _httpRequest.Method = new HttpMethod("GET");
 0653            _httpRequest.RequestUri = new System.Uri(_url);
 654            // Set Headers
 0655            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 656            {
 0657                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 658            }
 0659            if (Client.AcceptLanguage != null)
 660            {
 0661                if (_httpRequest.Headers.Contains("accept-language"))
 662                {
 0663                    _httpRequest.Headers.Remove("accept-language");
 664                }
 0665                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 666            }
 0667            if (clientRequestId != null)
 668            {
 0669                if (_httpRequest.Headers.Contains("client-request-id"))
 670                {
 0671                    _httpRequest.Headers.Remove("client-request-id");
 672                }
 0673                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 674            }
 0675            if (returnClientRequestId != null)
 676            {
 0677                if (_httpRequest.Headers.Contains("return-client-request-id"))
 678                {
 0679                    _httpRequest.Headers.Remove("return-client-request-id");
 680                }
 0681                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 682            }
 0683            if (ocpDate != null)
 684            {
 0685                if (_httpRequest.Headers.Contains("ocp-date"))
 686                {
 0687                    _httpRequest.Headers.Remove("ocp-date");
 688                }
 0689                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 690            }
 691
 692
 0693            if (customHeaders != null)
 694            {
 0695                foreach(var _header in customHeaders)
 696                {
 0697                    if (_httpRequest.Headers.Contains(_header.Key))
 698                    {
 0699                        _httpRequest.Headers.Remove(_header.Key);
 700                    }
 0701                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 702                }
 703            }
 704
 705            // Serialize Request
 0706            string _requestContent = null;
 707            // Set Credentials
 0708            if (Client.Credentials != null)
 709            {
 0710                cancellationToken.ThrowIfCancellationRequested();
 0711                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 712            }
 713            // Send Request
 0714            if (_shouldTrace)
 715            {
 0716                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 717            }
 0718            cancellationToken.ThrowIfCancellationRequested();
 0719            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0720            if (_shouldTrace)
 721            {
 0722                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 723            }
 0724            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0725            cancellationToken.ThrowIfCancellationRequested();
 0726            string _responseContent = null;
 0727            if ((int)_statusCode != 200)
 728            {
 0729                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 730                try
 731                {
 0732                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0733                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0734                    if (_errorBody != null)
 735                    {
 0736                        ex.Body = _errorBody;
 737                    }
 0738                }
 0739                catch (JsonException)
 740                {
 741                    // Ignore the exception
 0742                }
 0743                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0744                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0745                if (_shouldTrace)
 746                {
 0747                    ServiceClientTracing.Error(_invocationId, ex);
 748                }
 0749                _httpRequest.Dispose();
 0750                if (_httpResponse != null)
 751                {
 0752                    _httpResponse.Dispose();
 753                }
 0754                throw ex;
 755            }
 756            // Create Result
 0757            var _result = new AzureOperationResponse<IPage<ImageInformation>,AccountListSupportedImagesHeaders>();
 0758            _result.Request = _httpRequest;
 0759            _result.Response = _httpResponse;
 0760            if (_httpResponse.Headers.Contains("request-id"))
 761            {
 0762                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 763            }
 764            // Deserialize Response
 0765            if ((int)_statusCode == 200)
 766            {
 0767                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 768                try
 769                {
 0770                    _result.Body = SafeJsonConvert.DeserializeObject<Page<ImageInformation>>(_responseContent, Client.De
 0771                }
 0772                catch (JsonException ex)
 773                {
 0774                    _httpRequest.Dispose();
 0775                    if (_httpResponse != null)
 776                    {
 0777                        _httpResponse.Dispose();
 778                    }
 0779                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 780                }
 781            }
 782            try
 783            {
 0784                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<AccountListSupportedImagesHeaders>(JsonSeria
 0785            }
 0786            catch (JsonException ex)
 787            {
 0788                _httpRequest.Dispose();
 0789                if (_httpResponse != null)
 790                {
 0791                    _httpResponse.Dispose();
 792                }
 0793                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 794            }
 0795            if (_shouldTrace)
 796            {
 0797                ServiceClientTracing.Exit(_invocationId, _result);
 798            }
 0799            return _result;
 0800        }
 801
 802        /// <summary>
 803        /// Gets the number of Compute Nodes in each state, grouped by Pool.
 804        /// </summary>
 805        /// <param name='nextPageLink'>
 806        /// The NextLink from the previous successful call to List operation.
 807        /// </param>
 808        /// <param name='accountListPoolNodeCountsNextOptions'>
 809        /// Additional parameters for the operation
 810        /// </param>
 811        /// <param name='customHeaders'>
 812        /// Headers that will be added to request.
 813        /// </param>
 814        /// <param name='cancellationToken'>
 815        /// The cancellation token.
 816        /// </param>
 817        /// <exception cref="BatchErrorException">
 818        /// Thrown when the operation returned an invalid status code
 819        /// </exception>
 820        /// <exception cref="SerializationException">
 821        /// Thrown when unable to deserialize the response
 822        /// </exception>
 823        /// <exception cref="ValidationException">
 824        /// Thrown when a required parameter is null
 825        /// </exception>
 826        /// <exception cref="System.ArgumentNullException">
 827        /// Thrown when a required parameter is null
 828        /// </exception>
 829        /// <return>
 830        /// A response object containing the response body and response headers.
 831        /// </return>
 832        public async Task<AzureOperationResponse<IPage<PoolNodeCounts>,AccountListPoolNodeCountsHeaders>> ListPoolNodeCo
 833        {
 0834            if (nextPageLink == null)
 835            {
 0836                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 837            }
 0838            System.Guid? clientRequestId = default(System.Guid?);
 0839            if (accountListPoolNodeCountsNextOptions != null)
 840            {
 0841                clientRequestId = accountListPoolNodeCountsNextOptions.ClientRequestId;
 842            }
 0843            bool? returnClientRequestId = default(bool?);
 0844            if (accountListPoolNodeCountsNextOptions != null)
 845            {
 0846                returnClientRequestId = accountListPoolNodeCountsNextOptions.ReturnClientRequestId;
 847            }
 0848            System.DateTime? ocpDate = default(System.DateTime?);
 0849            if (accountListPoolNodeCountsNextOptions != null)
 850            {
 0851                ocpDate = accountListPoolNodeCountsNextOptions.OcpDate;
 852            }
 853            // Tracing
 0854            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0855            string _invocationId = null;
 0856            if (_shouldTrace)
 857            {
 0858                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0859                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0860                tracingParameters.Add("nextPageLink", nextPageLink);
 0861                tracingParameters.Add("clientRequestId", clientRequestId);
 0862                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0863                tracingParameters.Add("ocpDate", ocpDate);
 0864                tracingParameters.Add("cancellationToken", cancellationToken);
 0865                ServiceClientTracing.Enter(_invocationId, this, "ListPoolNodeCountsNext", tracingParameters);
 866            }
 867            // Construct URL
 0868            string _url = "{nextLink}";
 0869            _url = _url.Replace("{nextLink}", nextPageLink);
 0870            List<string> _queryParameters = new List<string>();
 0871            if (_queryParameters.Count > 0)
 872            {
 0873                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 874            }
 875            // Create HTTP transport objects
 0876            var _httpRequest = new HttpRequestMessage();
 0877            HttpResponseMessage _httpResponse = null;
 0878            _httpRequest.Method = new HttpMethod("GET");
 0879            _httpRequest.RequestUri = new System.Uri(_url);
 880            // Set Headers
 0881            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 882            {
 0883                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 884            }
 0885            if (Client.AcceptLanguage != null)
 886            {
 0887                if (_httpRequest.Headers.Contains("accept-language"))
 888                {
 0889                    _httpRequest.Headers.Remove("accept-language");
 890                }
 0891                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 892            }
 0893            if (clientRequestId != null)
 894            {
 0895                if (_httpRequest.Headers.Contains("client-request-id"))
 896                {
 0897                    _httpRequest.Headers.Remove("client-request-id");
 898                }
 0899                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 900            }
 0901            if (returnClientRequestId != null)
 902            {
 0903                if (_httpRequest.Headers.Contains("return-client-request-id"))
 904                {
 0905                    _httpRequest.Headers.Remove("return-client-request-id");
 906                }
 0907                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 908            }
 0909            if (ocpDate != null)
 910            {
 0911                if (_httpRequest.Headers.Contains("ocp-date"))
 912                {
 0913                    _httpRequest.Headers.Remove("ocp-date");
 914                }
 0915                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 916            }
 917
 918
 0919            if (customHeaders != null)
 920            {
 0921                foreach(var _header in customHeaders)
 922                {
 0923                    if (_httpRequest.Headers.Contains(_header.Key))
 924                    {
 0925                        _httpRequest.Headers.Remove(_header.Key);
 926                    }
 0927                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 928                }
 929            }
 930
 931            // Serialize Request
 0932            string _requestContent = null;
 933            // Set Credentials
 0934            if (Client.Credentials != null)
 935            {
 0936                cancellationToken.ThrowIfCancellationRequested();
 0937                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 938            }
 939            // Send Request
 0940            if (_shouldTrace)
 941            {
 0942                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 943            }
 0944            cancellationToken.ThrowIfCancellationRequested();
 0945            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0946            if (_shouldTrace)
 947            {
 0948                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 949            }
 0950            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0951            cancellationToken.ThrowIfCancellationRequested();
 0952            string _responseContent = null;
 0953            if ((int)_statusCode != 200)
 954            {
 0955                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 956                try
 957                {
 0958                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0959                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0960                    if (_errorBody != null)
 961                    {
 0962                        ex.Body = _errorBody;
 963                    }
 0964                }
 0965                catch (JsonException)
 966                {
 967                    // Ignore the exception
 0968                }
 0969                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0970                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0971                if (_shouldTrace)
 972                {
 0973                    ServiceClientTracing.Error(_invocationId, ex);
 974                }
 0975                _httpRequest.Dispose();
 0976                if (_httpResponse != null)
 977                {
 0978                    _httpResponse.Dispose();
 979                }
 0980                throw ex;
 981            }
 982            // Create Result
 0983            var _result = new AzureOperationResponse<IPage<PoolNodeCounts>,AccountListPoolNodeCountsHeaders>();
 0984            _result.Request = _httpRequest;
 0985            _result.Response = _httpResponse;
 0986            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 987            {
 0988                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 989            }
 990            // Deserialize Response
 0991            if ((int)_statusCode == 200)
 992            {
 0993                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 994                try
 995                {
 0996                    _result.Body = SafeJsonConvert.DeserializeObject<Page<PoolNodeCounts>>(_responseContent, Client.Dese
 0997                }
 0998                catch (JsonException ex)
 999                {
 01000                    _httpRequest.Dispose();
 01001                    if (_httpResponse != null)
 1002                    {
 01003                        _httpResponse.Dispose();
 1004                    }
 01005                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1006                }
 1007            }
 1008            try
 1009            {
 01010                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<AccountListPoolNodeCountsHeaders>(JsonSerial
 01011            }
 01012            catch (JsonException ex)
 1013            {
 01014                _httpRequest.Dispose();
 01015                if (_httpResponse != null)
 1016                {
 01017                    _httpResponse.Dispose();
 1018                }
 01019                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1020            }
 01021            if (_shouldTrace)
 1022            {
 01023                ServiceClientTracing.Exit(_invocationId, _result);
 1024            }
 01025            return _result;
 01026        }
 1027
 1028    }
 1029}