< Summary

Class:Microsoft.Azure.Batch.Protocol.ComputeNodeOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\ComputeNodeOperations.cs
Covered lines:4
Uncovered lines:1641
Coverable lines:1645
Total lines:3428
Line coverage:0.2% (4 of 1645)
Covered branches:1
Total branches:1014
Branch coverage:0% (1 of 1014)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
AddUserWithHttpMessagesAsync()-0%0%
DeleteUserWithHttpMessagesAsync()-0%0%
UpdateUserWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-0%0%
RebootWithHttpMessagesAsync()-0%0%
ReimageWithHttpMessagesAsync()-0%0%
DisableSchedulingWithHttpMessagesAsync()-0%0%
EnableSchedulingWithHttpMessagesAsync()-0%0%
GetRemoteLoginSettingsWithHttpMessagesAsync()-0%0%
GetRemoteDesktopWithHttpMessagesAsync()-0%0%
UploadBatchServiceLogsWithHttpMessagesAsync()-0%0%
ListWithHttpMessagesAsync()-0%0%
ListNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\ComputeNodeOperations.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.IO;
 21    using System.Linq;
 22    using System.Net;
 23    using System.Net.Http;
 24    using System.Threading;
 25    using System.Threading.Tasks;
 26
 27    /// <summary>
 28    /// ComputeNodeOperations operations.
 29    /// </summary>
 30    internal partial class ComputeNodeOperations : IServiceOperations<BatchServiceClient>, IComputeNodeOperations
 31    {
 32        /// <summary>
 33        /// Initializes a new instance of the ComputeNodeOperations class.
 34        /// </summary>
 35        /// <param name='client'>
 36        /// Reference to the service client.
 37        /// </param>
 38        /// <exception cref="System.ArgumentNullException">
 39        /// Thrown when a required parameter is null
 40        /// </exception>
 14841        internal ComputeNodeOperations(BatchServiceClient client)
 42        {
 14843            if (client == null)
 44            {
 045                throw new System.ArgumentNullException("client");
 46            }
 14847            Client = client;
 14848        }
 49
 50        /// <summary>
 51        /// Gets a reference to the BatchServiceClient
 52        /// </summary>
 053        public BatchServiceClient Client { get; private set; }
 54
 55        /// <summary>
 56        /// Adds a user Account to the specified Compute Node.
 57        /// </summary>
 58        /// <remarks>
 59        /// You can add a user Account to a Compute Node only when it is in the idle or
 60        /// running state.
 61        /// </remarks>
 62        /// <param name='poolId'>
 63        /// The ID of the Pool that contains the Compute Node.
 64        /// </param>
 65        /// <param name='nodeId'>
 66        /// The ID of the machine on which you want to create a user Account.
 67        /// </param>
 68        /// <param name='user'>
 69        /// The user Account to be created.
 70        /// </param>
 71        /// <param name='computeNodeAddUserOptions'>
 72        /// Additional parameters for the operation
 73        /// </param>
 74        /// <param name='customHeaders'>
 75        /// Headers that will be added to request.
 76        /// </param>
 77        /// <param name='cancellationToken'>
 78        /// The cancellation token.
 79        /// </param>
 80        /// <exception cref="BatchErrorException">
 81        /// Thrown when the operation returned an invalid status code
 82        /// </exception>
 83        /// <exception cref="ValidationException">
 84        /// Thrown when a required parameter is null
 85        /// </exception>
 86        /// <exception cref="System.ArgumentNullException">
 87        /// Thrown when a required parameter is null
 88        /// </exception>
 89        /// <return>
 90        /// A response object containing the response body and response headers.
 91        /// </return>
 92        public async Task<AzureOperationHeaderResponse<ComputeNodeAddUserHeaders>> AddUserWithHttpMessagesAsync(string p
 93        {
 094            if (Client.BatchUrl == null)
 95            {
 096                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 97            }
 098            if (poolId == null)
 99            {
 0100                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 101            }
 0102            if (nodeId == null)
 103            {
 0104                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 105            }
 0106            if (user == null)
 107            {
 0108                throw new ValidationException(ValidationRules.CannotBeNull, "user");
 109            }
 0110            if (Client.ApiVersion == null)
 111            {
 0112                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 113            }
 0114            int? timeout = default(int?);
 0115            if (computeNodeAddUserOptions != null)
 116            {
 0117                timeout = computeNodeAddUserOptions.Timeout;
 118            }
 0119            System.Guid? clientRequestId = default(System.Guid?);
 0120            if (computeNodeAddUserOptions != null)
 121            {
 0122                clientRequestId = computeNodeAddUserOptions.ClientRequestId;
 123            }
 0124            bool? returnClientRequestId = default(bool?);
 0125            if (computeNodeAddUserOptions != null)
 126            {
 0127                returnClientRequestId = computeNodeAddUserOptions.ReturnClientRequestId;
 128            }
 0129            System.DateTime? ocpDate = default(System.DateTime?);
 0130            if (computeNodeAddUserOptions != null)
 131            {
 0132                ocpDate = computeNodeAddUserOptions.OcpDate;
 133            }
 134            // Tracing
 0135            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0136            string _invocationId = null;
 0137            if (_shouldTrace)
 138            {
 0139                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0140                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0141                tracingParameters.Add("poolId", poolId);
 0142                tracingParameters.Add("nodeId", nodeId);
 0143                tracingParameters.Add("user", user);
 0144                tracingParameters.Add("timeout", timeout);
 0145                tracingParameters.Add("clientRequestId", clientRequestId);
 0146                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0147                tracingParameters.Add("ocpDate", ocpDate);
 0148                tracingParameters.Add("cancellationToken", cancellationToken);
 0149                ServiceClientTracing.Enter(_invocationId, this, "AddUser", tracingParameters);
 150            }
 151            // Construct URL
 0152            var _baseUrl = Client.BaseUri;
 0153            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/users";
 0154            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0155            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 0156            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 0157            List<string> _queryParameters = new List<string>();
 0158            if (Client.ApiVersion != null)
 159            {
 0160                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 161            }
 0162            if (timeout != null)
 163            {
 0164                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 165            }
 0166            if (_queryParameters.Count > 0)
 167            {
 0168                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 169            }
 170            // Create HTTP transport objects
 0171            var _httpRequest = new HttpRequestMessage();
 0172            HttpResponseMessage _httpResponse = null;
 0173            _httpRequest.Method = new HttpMethod("POST");
 0174            _httpRequest.RequestUri = new System.Uri(_url);
 175            // Set Headers
 0176            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 177            {
 0178                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 179            }
 0180            if (Client.AcceptLanguage != null)
 181            {
 0182                if (_httpRequest.Headers.Contains("accept-language"))
 183                {
 0184                    _httpRequest.Headers.Remove("accept-language");
 185                }
 0186                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 187            }
 0188            if (clientRequestId != null)
 189            {
 0190                if (_httpRequest.Headers.Contains("client-request-id"))
 191                {
 0192                    _httpRequest.Headers.Remove("client-request-id");
 193                }
 0194                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 195            }
 0196            if (returnClientRequestId != null)
 197            {
 0198                if (_httpRequest.Headers.Contains("return-client-request-id"))
 199                {
 0200                    _httpRequest.Headers.Remove("return-client-request-id");
 201                }
 0202                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 203            }
 0204            if (ocpDate != null)
 205            {
 0206                if (_httpRequest.Headers.Contains("ocp-date"))
 207                {
 0208                    _httpRequest.Headers.Remove("ocp-date");
 209                }
 0210                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 211            }
 212
 213
 0214            if (customHeaders != null)
 215            {
 0216                foreach(var _header in customHeaders)
 217                {
 0218                    if (_httpRequest.Headers.Contains(_header.Key))
 219                    {
 0220                        _httpRequest.Headers.Remove(_header.Key);
 221                    }
 0222                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 223                }
 224            }
 225
 226            // Serialize Request
 0227            string _requestContent = null;
 0228            if(user != null)
 229            {
 0230                _requestContent = SafeJsonConvert.SerializeObject(user, Client.SerializationSettings);
 0231                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0232                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 233            }
 234            // Set Credentials
 0235            if (Client.Credentials != null)
 236            {
 0237                cancellationToken.ThrowIfCancellationRequested();
 0238                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 239            }
 240            // Send Request
 0241            if (_shouldTrace)
 242            {
 0243                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 244            }
 0245            cancellationToken.ThrowIfCancellationRequested();
 0246            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0247            if (_shouldTrace)
 248            {
 0249                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 250            }
 0251            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0252            cancellationToken.ThrowIfCancellationRequested();
 0253            string _responseContent = null;
 0254            if ((int)_statusCode != 201)
 255            {
 0256                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 257                try
 258                {
 0259                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0260                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0261                    if (_errorBody != null)
 262                    {
 0263                        ex.Body = _errorBody;
 264                    }
 0265                }
 0266                catch (JsonException)
 267                {
 268                    // Ignore the exception
 0269                }
 0270                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0271                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0272                if (_shouldTrace)
 273                {
 0274                    ServiceClientTracing.Error(_invocationId, ex);
 275                }
 0276                _httpRequest.Dispose();
 0277                if (_httpResponse != null)
 278                {
 0279                    _httpResponse.Dispose();
 280                }
 0281                throw ex;
 282            }
 283            // Create Result
 0284            var _result = new AzureOperationHeaderResponse<ComputeNodeAddUserHeaders>();
 0285            _result.Request = _httpRequest;
 0286            _result.Response = _httpResponse;
 0287            if (_httpResponse.Headers.Contains("request-id"))
 288            {
 0289                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 290            }
 291            try
 292            {
 0293                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeAddUserHeaders>(JsonSerializer.Cr
 0294            }
 0295            catch (JsonException ex)
 296            {
 0297                _httpRequest.Dispose();
 0298                if (_httpResponse != null)
 299                {
 0300                    _httpResponse.Dispose();
 301                }
 0302                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 303            }
 0304            if (_shouldTrace)
 305            {
 0306                ServiceClientTracing.Exit(_invocationId, _result);
 307            }
 0308            return _result;
 0309        }
 310
 311        /// <summary>
 312        /// Deletes a user Account from the specified Compute Node.
 313        /// </summary>
 314        /// <remarks>
 315        /// You can delete a user Account to a Compute Node only when it is in the idle
 316        /// or running state.
 317        /// </remarks>
 318        /// <param name='poolId'>
 319        /// The ID of the Pool that contains the Compute Node.
 320        /// </param>
 321        /// <param name='nodeId'>
 322        /// The ID of the machine on which you want to delete a user Account.
 323        /// </param>
 324        /// <param name='userName'>
 325        /// The name of the user Account to delete.
 326        /// </param>
 327        /// <param name='computeNodeDeleteUserOptions'>
 328        /// Additional parameters for the operation
 329        /// </param>
 330        /// <param name='customHeaders'>
 331        /// Headers that will be added to request.
 332        /// </param>
 333        /// <param name='cancellationToken'>
 334        /// The cancellation token.
 335        /// </param>
 336        /// <exception cref="BatchErrorException">
 337        /// Thrown when the operation returned an invalid status code
 338        /// </exception>
 339        /// <exception cref="ValidationException">
 340        /// Thrown when a required parameter is null
 341        /// </exception>
 342        /// <exception cref="System.ArgumentNullException">
 343        /// Thrown when a required parameter is null
 344        /// </exception>
 345        /// <return>
 346        /// A response object containing the response body and response headers.
 347        /// </return>
 348        public async Task<AzureOperationHeaderResponse<ComputeNodeDeleteUserHeaders>> DeleteUserWithHttpMessagesAsync(st
 349        {
 0350            if (Client.BatchUrl == null)
 351            {
 0352                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 353            }
 0354            if (poolId == null)
 355            {
 0356                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 357            }
 0358            if (nodeId == null)
 359            {
 0360                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 361            }
 0362            if (userName == null)
 363            {
 0364                throw new ValidationException(ValidationRules.CannotBeNull, "userName");
 365            }
 0366            if (Client.ApiVersion == null)
 367            {
 0368                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 369            }
 0370            int? timeout = default(int?);
 0371            if (computeNodeDeleteUserOptions != null)
 372            {
 0373                timeout = computeNodeDeleteUserOptions.Timeout;
 374            }
 0375            System.Guid? clientRequestId = default(System.Guid?);
 0376            if (computeNodeDeleteUserOptions != null)
 377            {
 0378                clientRequestId = computeNodeDeleteUserOptions.ClientRequestId;
 379            }
 0380            bool? returnClientRequestId = default(bool?);
 0381            if (computeNodeDeleteUserOptions != null)
 382            {
 0383                returnClientRequestId = computeNodeDeleteUserOptions.ReturnClientRequestId;
 384            }
 0385            System.DateTime? ocpDate = default(System.DateTime?);
 0386            if (computeNodeDeleteUserOptions != null)
 387            {
 0388                ocpDate = computeNodeDeleteUserOptions.OcpDate;
 389            }
 390            // Tracing
 0391            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0392            string _invocationId = null;
 0393            if (_shouldTrace)
 394            {
 0395                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0396                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0397                tracingParameters.Add("poolId", poolId);
 0398                tracingParameters.Add("nodeId", nodeId);
 0399                tracingParameters.Add("userName", userName);
 0400                tracingParameters.Add("timeout", timeout);
 0401                tracingParameters.Add("clientRequestId", clientRequestId);
 0402                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0403                tracingParameters.Add("ocpDate", ocpDate);
 0404                tracingParameters.Add("cancellationToken", cancellationToken);
 0405                ServiceClientTracing.Enter(_invocationId, this, "DeleteUser", tracingParameters);
 406            }
 407            // Construct URL
 0408            var _baseUrl = Client.BaseUri;
 0409            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/users/{userName}"
 0410            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0411            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 0412            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 0413            _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName));
 0414            List<string> _queryParameters = new List<string>();
 0415            if (Client.ApiVersion != null)
 416            {
 0417                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 418            }
 0419            if (timeout != null)
 420            {
 0421                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 422            }
 0423            if (_queryParameters.Count > 0)
 424            {
 0425                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 426            }
 427            // Create HTTP transport objects
 0428            var _httpRequest = new HttpRequestMessage();
 0429            HttpResponseMessage _httpResponse = null;
 0430            _httpRequest.Method = new HttpMethod("DELETE");
 0431            _httpRequest.RequestUri = new System.Uri(_url);
 432            // Set Headers
 0433            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 434            {
 0435                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 436            }
 0437            if (Client.AcceptLanguage != null)
 438            {
 0439                if (_httpRequest.Headers.Contains("accept-language"))
 440                {
 0441                    _httpRequest.Headers.Remove("accept-language");
 442                }
 0443                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 444            }
 0445            if (clientRequestId != null)
 446            {
 0447                if (_httpRequest.Headers.Contains("client-request-id"))
 448                {
 0449                    _httpRequest.Headers.Remove("client-request-id");
 450                }
 0451                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 452            }
 0453            if (returnClientRequestId != null)
 454            {
 0455                if (_httpRequest.Headers.Contains("return-client-request-id"))
 456                {
 0457                    _httpRequest.Headers.Remove("return-client-request-id");
 458                }
 0459                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 460            }
 0461            if (ocpDate != null)
 462            {
 0463                if (_httpRequest.Headers.Contains("ocp-date"))
 464                {
 0465                    _httpRequest.Headers.Remove("ocp-date");
 466                }
 0467                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 468            }
 469
 470
 0471            if (customHeaders != null)
 472            {
 0473                foreach(var _header in customHeaders)
 474                {
 0475                    if (_httpRequest.Headers.Contains(_header.Key))
 476                    {
 0477                        _httpRequest.Headers.Remove(_header.Key);
 478                    }
 0479                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 480                }
 481            }
 482
 483            // Serialize Request
 0484            string _requestContent = null;
 485            // Set Credentials
 0486            if (Client.Credentials != null)
 487            {
 0488                cancellationToken.ThrowIfCancellationRequested();
 0489                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 490            }
 491            // Send Request
 0492            if (_shouldTrace)
 493            {
 0494                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 495            }
 0496            cancellationToken.ThrowIfCancellationRequested();
 0497            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0498            if (_shouldTrace)
 499            {
 0500                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 501            }
 0502            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0503            cancellationToken.ThrowIfCancellationRequested();
 0504            string _responseContent = null;
 0505            if ((int)_statusCode != 200)
 506            {
 0507                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 508                try
 509                {
 0510                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0511                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0512                    if (_errorBody != null)
 513                    {
 0514                        ex.Body = _errorBody;
 515                    }
 0516                }
 0517                catch (JsonException)
 518                {
 519                    // Ignore the exception
 0520                }
 0521                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0522                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0523                if (_shouldTrace)
 524                {
 0525                    ServiceClientTracing.Error(_invocationId, ex);
 526                }
 0527                _httpRequest.Dispose();
 0528                if (_httpResponse != null)
 529                {
 0530                    _httpResponse.Dispose();
 531                }
 0532                throw ex;
 533            }
 534            // Create Result
 0535            var _result = new AzureOperationHeaderResponse<ComputeNodeDeleteUserHeaders>();
 0536            _result.Request = _httpRequest;
 0537            _result.Response = _httpResponse;
 0538            if (_httpResponse.Headers.Contains("request-id"))
 539            {
 0540                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 541            }
 542            try
 543            {
 0544                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeDeleteUserHeaders>(JsonSerializer
 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 headers.", _httpResponse.GetHeadersAsJson().
 554            }
 0555            if (_shouldTrace)
 556            {
 0557                ServiceClientTracing.Exit(_invocationId, _result);
 558            }
 0559            return _result;
 0560        }
 561
 562        /// <summary>
 563        /// Updates the password and expiration time of a user Account on the specified
 564        /// Compute Node.
 565        /// </summary>
 566        /// <remarks>
 567        /// This operation replaces of all the updatable properties of the Account. For
 568        /// example, if the expiryTime element is not specified, the current value is
 569        /// replaced with the default value, not left unmodified. You can update a user
 570        /// Account on a Compute Node only when it is in the idle or running state.
 571        /// </remarks>
 572        /// <param name='poolId'>
 573        /// The ID of the Pool that contains the Compute Node.
 574        /// </param>
 575        /// <param name='nodeId'>
 576        /// The ID of the machine on which you want to update a user Account.
 577        /// </param>
 578        /// <param name='userName'>
 579        /// The name of the user Account to update.
 580        /// </param>
 581        /// <param name='nodeUpdateUserParameter'>
 582        /// The parameters for the request.
 583        /// </param>
 584        /// <param name='computeNodeUpdateUserOptions'>
 585        /// Additional parameters for the operation
 586        /// </param>
 587        /// <param name='customHeaders'>
 588        /// Headers that will be added to request.
 589        /// </param>
 590        /// <param name='cancellationToken'>
 591        /// The cancellation token.
 592        /// </param>
 593        /// <exception cref="BatchErrorException">
 594        /// Thrown when the operation returned an invalid status code
 595        /// </exception>
 596        /// <exception cref="ValidationException">
 597        /// Thrown when a required parameter is null
 598        /// </exception>
 599        /// <exception cref="System.ArgumentNullException">
 600        /// Thrown when a required parameter is null
 601        /// </exception>
 602        /// <return>
 603        /// A response object containing the response body and response headers.
 604        /// </return>
 605        public async Task<AzureOperationHeaderResponse<ComputeNodeUpdateUserHeaders>> UpdateUserWithHttpMessagesAsync(st
 606        {
 0607            if (Client.BatchUrl == null)
 608            {
 0609                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 610            }
 0611            if (poolId == null)
 612            {
 0613                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 614            }
 0615            if (nodeId == null)
 616            {
 0617                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 618            }
 0619            if (userName == null)
 620            {
 0621                throw new ValidationException(ValidationRules.CannotBeNull, "userName");
 622            }
 0623            if (nodeUpdateUserParameter == null)
 624            {
 0625                throw new ValidationException(ValidationRules.CannotBeNull, "nodeUpdateUserParameter");
 626            }
 0627            if (Client.ApiVersion == null)
 628            {
 0629                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 630            }
 0631            int? timeout = default(int?);
 0632            if (computeNodeUpdateUserOptions != null)
 633            {
 0634                timeout = computeNodeUpdateUserOptions.Timeout;
 635            }
 0636            System.Guid? clientRequestId = default(System.Guid?);
 0637            if (computeNodeUpdateUserOptions != null)
 638            {
 0639                clientRequestId = computeNodeUpdateUserOptions.ClientRequestId;
 640            }
 0641            bool? returnClientRequestId = default(bool?);
 0642            if (computeNodeUpdateUserOptions != null)
 643            {
 0644                returnClientRequestId = computeNodeUpdateUserOptions.ReturnClientRequestId;
 645            }
 0646            System.DateTime? ocpDate = default(System.DateTime?);
 0647            if (computeNodeUpdateUserOptions != null)
 648            {
 0649                ocpDate = computeNodeUpdateUserOptions.OcpDate;
 650            }
 651            // Tracing
 0652            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0653            string _invocationId = null;
 0654            if (_shouldTrace)
 655            {
 0656                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0657                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0658                tracingParameters.Add("poolId", poolId);
 0659                tracingParameters.Add("nodeId", nodeId);
 0660                tracingParameters.Add("userName", userName);
 0661                tracingParameters.Add("nodeUpdateUserParameter", nodeUpdateUserParameter);
 0662                tracingParameters.Add("timeout", timeout);
 0663                tracingParameters.Add("clientRequestId", clientRequestId);
 0664                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0665                tracingParameters.Add("ocpDate", ocpDate);
 0666                tracingParameters.Add("cancellationToken", cancellationToken);
 0667                ServiceClientTracing.Enter(_invocationId, this, "UpdateUser", tracingParameters);
 668            }
 669            // Construct URL
 0670            var _baseUrl = Client.BaseUri;
 0671            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/users/{userName}"
 0672            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0673            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 0674            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 0675            _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName));
 0676            List<string> _queryParameters = new List<string>();
 0677            if (Client.ApiVersion != null)
 678            {
 0679                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 680            }
 0681            if (timeout != null)
 682            {
 0683                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 684            }
 0685            if (_queryParameters.Count > 0)
 686            {
 0687                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 688            }
 689            // Create HTTP transport objects
 0690            var _httpRequest = new HttpRequestMessage();
 0691            HttpResponseMessage _httpResponse = null;
 0692            _httpRequest.Method = new HttpMethod("PUT");
 0693            _httpRequest.RequestUri = new System.Uri(_url);
 694            // Set Headers
 0695            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 696            {
 0697                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 698            }
 0699            if (Client.AcceptLanguage != null)
 700            {
 0701                if (_httpRequest.Headers.Contains("accept-language"))
 702                {
 0703                    _httpRequest.Headers.Remove("accept-language");
 704                }
 0705                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 706            }
 0707            if (clientRequestId != null)
 708            {
 0709                if (_httpRequest.Headers.Contains("client-request-id"))
 710                {
 0711                    _httpRequest.Headers.Remove("client-request-id");
 712                }
 0713                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 714            }
 0715            if (returnClientRequestId != null)
 716            {
 0717                if (_httpRequest.Headers.Contains("return-client-request-id"))
 718                {
 0719                    _httpRequest.Headers.Remove("return-client-request-id");
 720                }
 0721                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 722            }
 0723            if (ocpDate != null)
 724            {
 0725                if (_httpRequest.Headers.Contains("ocp-date"))
 726                {
 0727                    _httpRequest.Headers.Remove("ocp-date");
 728                }
 0729                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 730            }
 731
 732
 0733            if (customHeaders != null)
 734            {
 0735                foreach(var _header in customHeaders)
 736                {
 0737                    if (_httpRequest.Headers.Contains(_header.Key))
 738                    {
 0739                        _httpRequest.Headers.Remove(_header.Key);
 740                    }
 0741                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 742                }
 743            }
 744
 745            // Serialize Request
 0746            string _requestContent = null;
 0747            if(nodeUpdateUserParameter != null)
 748            {
 0749                _requestContent = SafeJsonConvert.SerializeObject(nodeUpdateUserParameter, Client.SerializationSettings)
 0750                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0751                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 752            }
 753            // Set Credentials
 0754            if (Client.Credentials != null)
 755            {
 0756                cancellationToken.ThrowIfCancellationRequested();
 0757                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 758            }
 759            // Send Request
 0760            if (_shouldTrace)
 761            {
 0762                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 763            }
 0764            cancellationToken.ThrowIfCancellationRequested();
 0765            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0766            if (_shouldTrace)
 767            {
 0768                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 769            }
 0770            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0771            cancellationToken.ThrowIfCancellationRequested();
 0772            string _responseContent = null;
 0773            if ((int)_statusCode != 200)
 774            {
 0775                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 776                try
 777                {
 0778                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0779                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0780                    if (_errorBody != null)
 781                    {
 0782                        ex.Body = _errorBody;
 783                    }
 0784                }
 0785                catch (JsonException)
 786                {
 787                    // Ignore the exception
 0788                }
 0789                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0790                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0791                if (_shouldTrace)
 792                {
 0793                    ServiceClientTracing.Error(_invocationId, ex);
 794                }
 0795                _httpRequest.Dispose();
 0796                if (_httpResponse != null)
 797                {
 0798                    _httpResponse.Dispose();
 799                }
 0800                throw ex;
 801            }
 802            // Create Result
 0803            var _result = new AzureOperationHeaderResponse<ComputeNodeUpdateUserHeaders>();
 0804            _result.Request = _httpRequest;
 0805            _result.Response = _httpResponse;
 0806            if (_httpResponse.Headers.Contains("request-id"))
 807            {
 0808                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 809            }
 810            try
 811            {
 0812                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeUpdateUserHeaders>(JsonSerializer
 0813            }
 0814            catch (JsonException ex)
 815            {
 0816                _httpRequest.Dispose();
 0817                if (_httpResponse != null)
 818                {
 0819                    _httpResponse.Dispose();
 820                }
 0821                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 822            }
 0823            if (_shouldTrace)
 824            {
 0825                ServiceClientTracing.Exit(_invocationId, _result);
 826            }
 0827            return _result;
 0828        }
 829
 830        /// <summary>
 831        /// Gets information about the specified Compute Node.
 832        /// </summary>
 833        /// <param name='poolId'>
 834        /// The ID of the Pool that contains the Compute Node.
 835        /// </param>
 836        /// <param name='nodeId'>
 837        /// The ID of the Compute Node that you want to get information about.
 838        /// </param>
 839        /// <param name='computeNodeGetOptions'>
 840        /// Additional parameters for the operation
 841        /// </param>
 842        /// <param name='customHeaders'>
 843        /// Headers that will be added to request.
 844        /// </param>
 845        /// <param name='cancellationToken'>
 846        /// The cancellation token.
 847        /// </param>
 848        /// <exception cref="BatchErrorException">
 849        /// Thrown when the operation returned an invalid status code
 850        /// </exception>
 851        /// <exception cref="SerializationException">
 852        /// Thrown when unable to deserialize the response
 853        /// </exception>
 854        /// <exception cref="ValidationException">
 855        /// Thrown when a required parameter is null
 856        /// </exception>
 857        /// <exception cref="System.ArgumentNullException">
 858        /// Thrown when a required parameter is null
 859        /// </exception>
 860        /// <return>
 861        /// A response object containing the response body and response headers.
 862        /// </return>
 863        public async Task<AzureOperationResponse<ComputeNode,ComputeNodeGetHeaders>> GetWithHttpMessagesAsync(string poo
 864        {
 0865            if (Client.BatchUrl == null)
 866            {
 0867                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 868            }
 0869            if (poolId == null)
 870            {
 0871                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 872            }
 0873            if (nodeId == null)
 874            {
 0875                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 876            }
 0877            if (Client.ApiVersion == null)
 878            {
 0879                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 880            }
 0881            string select = default(string);
 0882            if (computeNodeGetOptions != null)
 883            {
 0884                select = computeNodeGetOptions.Select;
 885            }
 0886            int? timeout = default(int?);
 0887            if (computeNodeGetOptions != null)
 888            {
 0889                timeout = computeNodeGetOptions.Timeout;
 890            }
 0891            System.Guid? clientRequestId = default(System.Guid?);
 0892            if (computeNodeGetOptions != null)
 893            {
 0894                clientRequestId = computeNodeGetOptions.ClientRequestId;
 895            }
 0896            bool? returnClientRequestId = default(bool?);
 0897            if (computeNodeGetOptions != null)
 898            {
 0899                returnClientRequestId = computeNodeGetOptions.ReturnClientRequestId;
 900            }
 0901            System.DateTime? ocpDate = default(System.DateTime?);
 0902            if (computeNodeGetOptions != null)
 903            {
 0904                ocpDate = computeNodeGetOptions.OcpDate;
 905            }
 906            // Tracing
 0907            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0908            string _invocationId = null;
 0909            if (_shouldTrace)
 910            {
 0911                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0912                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0913                tracingParameters.Add("poolId", poolId);
 0914                tracingParameters.Add("nodeId", nodeId);
 0915                tracingParameters.Add("select", select);
 0916                tracingParameters.Add("timeout", timeout);
 0917                tracingParameters.Add("clientRequestId", clientRequestId);
 0918                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0919                tracingParameters.Add("ocpDate", ocpDate);
 0920                tracingParameters.Add("cancellationToken", cancellationToken);
 0921                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 922            }
 923            // Construct URL
 0924            var _baseUrl = Client.BaseUri;
 0925            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}";
 0926            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0927            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 0928            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 0929            List<string> _queryParameters = new List<string>();
 0930            if (Client.ApiVersion != null)
 931            {
 0932                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 933            }
 0934            if (select != null)
 935            {
 0936                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 937            }
 0938            if (timeout != null)
 939            {
 0940                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 941            }
 0942            if (_queryParameters.Count > 0)
 943            {
 0944                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 945            }
 946            // Create HTTP transport objects
 0947            var _httpRequest = new HttpRequestMessage();
 0948            HttpResponseMessage _httpResponse = null;
 0949            _httpRequest.Method = new HttpMethod("GET");
 0950            _httpRequest.RequestUri = new System.Uri(_url);
 951            // Set Headers
 0952            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 953            {
 0954                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 955            }
 0956            if (Client.AcceptLanguage != null)
 957            {
 0958                if (_httpRequest.Headers.Contains("accept-language"))
 959                {
 0960                    _httpRequest.Headers.Remove("accept-language");
 961                }
 0962                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 963            }
 0964            if (clientRequestId != null)
 965            {
 0966                if (_httpRequest.Headers.Contains("client-request-id"))
 967                {
 0968                    _httpRequest.Headers.Remove("client-request-id");
 969                }
 0970                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 971            }
 0972            if (returnClientRequestId != null)
 973            {
 0974                if (_httpRequest.Headers.Contains("return-client-request-id"))
 975                {
 0976                    _httpRequest.Headers.Remove("return-client-request-id");
 977                }
 0978                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 979            }
 0980            if (ocpDate != null)
 981            {
 0982                if (_httpRequest.Headers.Contains("ocp-date"))
 983                {
 0984                    _httpRequest.Headers.Remove("ocp-date");
 985                }
 0986                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 987            }
 988
 989
 0990            if (customHeaders != null)
 991            {
 0992                foreach(var _header in customHeaders)
 993                {
 0994                    if (_httpRequest.Headers.Contains(_header.Key))
 995                    {
 0996                        _httpRequest.Headers.Remove(_header.Key);
 997                    }
 0998                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 999                }
 1000            }
 1001
 1002            // Serialize Request
 01003            string _requestContent = null;
 1004            // Set Credentials
 01005            if (Client.Credentials != null)
 1006            {
 01007                cancellationToken.ThrowIfCancellationRequested();
 01008                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1009            }
 1010            // Send Request
 01011            if (_shouldTrace)
 1012            {
 01013                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1014            }
 01015            cancellationToken.ThrowIfCancellationRequested();
 01016            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01017            if (_shouldTrace)
 1018            {
 01019                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1020            }
 01021            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01022            cancellationToken.ThrowIfCancellationRequested();
 01023            string _responseContent = null;
 01024            if ((int)_statusCode != 200)
 1025            {
 01026                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1027                try
 1028                {
 01029                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01030                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01031                    if (_errorBody != null)
 1032                    {
 01033                        ex.Body = _errorBody;
 1034                    }
 01035                }
 01036                catch (JsonException)
 1037                {
 1038                    // Ignore the exception
 01039                }
 01040                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01041                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01042                if (_shouldTrace)
 1043                {
 01044                    ServiceClientTracing.Error(_invocationId, ex);
 1045                }
 01046                _httpRequest.Dispose();
 01047                if (_httpResponse != null)
 1048                {
 01049                    _httpResponse.Dispose();
 1050                }
 01051                throw ex;
 1052            }
 1053            // Create Result
 01054            var _result = new AzureOperationResponse<ComputeNode,ComputeNodeGetHeaders>();
 01055            _result.Request = _httpRequest;
 01056            _result.Response = _httpResponse;
 01057            if (_httpResponse.Headers.Contains("request-id"))
 1058            {
 01059                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1060            }
 1061            // Deserialize Response
 01062            if ((int)_statusCode == 200)
 1063            {
 01064                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1065                try
 1066                {
 01067                    _result.Body = SafeJsonConvert.DeserializeObject<ComputeNode>(_responseContent, Client.Deserializati
 01068                }
 01069                catch (JsonException ex)
 1070                {
 01071                    _httpRequest.Dispose();
 01072                    if (_httpResponse != null)
 1073                    {
 01074                        _httpResponse.Dispose();
 1075                    }
 01076                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1077                }
 1078            }
 1079            try
 1080            {
 01081                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeGetHeaders>(JsonSerializer.Create
 01082            }
 01083            catch (JsonException ex)
 1084            {
 01085                _httpRequest.Dispose();
 01086                if (_httpResponse != null)
 1087                {
 01088                    _httpResponse.Dispose();
 1089                }
 01090                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1091            }
 01092            if (_shouldTrace)
 1093            {
 01094                ServiceClientTracing.Exit(_invocationId, _result);
 1095            }
 01096            return _result;
 01097        }
 1098
 1099        /// <summary>
 1100        /// Restarts the specified Compute Node.
 1101        /// </summary>
 1102        /// <remarks>
 1103        /// You can restart a Compute Node only if it is in an idle or running state.
 1104        /// </remarks>
 1105        /// <param name='poolId'>
 1106        /// The ID of the Pool that contains the Compute Node.
 1107        /// </param>
 1108        /// <param name='nodeId'>
 1109        /// The ID of the Compute Node that you want to restart.
 1110        /// </param>
 1111        /// <param name='nodeRebootOption'>
 1112        /// When to reboot the Compute Node and what to do with currently running
 1113        /// Tasks. The default value is requeue. Possible values include: 'requeue',
 1114        /// 'terminate', 'taskCompletion', 'retainedData'
 1115        /// </param>
 1116        /// <param name='computeNodeRebootOptions'>
 1117        /// Additional parameters for the operation
 1118        /// </param>
 1119        /// <param name='customHeaders'>
 1120        /// Headers that will be added to request.
 1121        /// </param>
 1122        /// <param name='cancellationToken'>
 1123        /// The cancellation token.
 1124        /// </param>
 1125        /// <exception cref="BatchErrorException">
 1126        /// Thrown when the operation returned an invalid status code
 1127        /// </exception>
 1128        /// <exception cref="ValidationException">
 1129        /// Thrown when a required parameter is null
 1130        /// </exception>
 1131        /// <exception cref="System.ArgumentNullException">
 1132        /// Thrown when a required parameter is null
 1133        /// </exception>
 1134        /// <return>
 1135        /// A response object containing the response body and response headers.
 1136        /// </return>
 1137        public async Task<AzureOperationHeaderResponse<ComputeNodeRebootHeaders>> RebootWithHttpMessagesAsync(string poo
 1138        {
 01139            if (Client.BatchUrl == null)
 1140            {
 01141                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1142            }
 01143            if (poolId == null)
 1144            {
 01145                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1146            }
 01147            if (nodeId == null)
 1148            {
 01149                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1150            }
 01151            if (Client.ApiVersion == null)
 1152            {
 01153                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1154            }
 01155            int? timeout = default(int?);
 01156            if (computeNodeRebootOptions != null)
 1157            {
 01158                timeout = computeNodeRebootOptions.Timeout;
 1159            }
 01160            System.Guid? clientRequestId = default(System.Guid?);
 01161            if (computeNodeRebootOptions != null)
 1162            {
 01163                clientRequestId = computeNodeRebootOptions.ClientRequestId;
 1164            }
 01165            bool? returnClientRequestId = default(bool?);
 01166            if (computeNodeRebootOptions != null)
 1167            {
 01168                returnClientRequestId = computeNodeRebootOptions.ReturnClientRequestId;
 1169            }
 01170            System.DateTime? ocpDate = default(System.DateTime?);
 01171            if (computeNodeRebootOptions != null)
 1172            {
 01173                ocpDate = computeNodeRebootOptions.OcpDate;
 1174            }
 01175            NodeRebootParameter nodeRebootParameter = default(NodeRebootParameter);
 01176            if (nodeRebootOption != null)
 1177            {
 01178                nodeRebootParameter = new NodeRebootParameter();
 01179                nodeRebootParameter.NodeRebootOption = nodeRebootOption;
 1180            }
 1181            // Tracing
 01182            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01183            string _invocationId = null;
 01184            if (_shouldTrace)
 1185            {
 01186                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01187                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01188                tracingParameters.Add("poolId", poolId);
 01189                tracingParameters.Add("nodeId", nodeId);
 01190                tracingParameters.Add("timeout", timeout);
 01191                tracingParameters.Add("clientRequestId", clientRequestId);
 01192                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01193                tracingParameters.Add("ocpDate", ocpDate);
 01194                tracingParameters.Add("nodeRebootParameter", nodeRebootParameter);
 01195                tracingParameters.Add("cancellationToken", cancellationToken);
 01196                ServiceClientTracing.Enter(_invocationId, this, "Reboot", tracingParameters);
 1197            }
 1198            // Construct URL
 01199            var _baseUrl = Client.BaseUri;
 01200            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/reboot";
 01201            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01202            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 01203            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 01204            List<string> _queryParameters = new List<string>();
 01205            if (Client.ApiVersion != null)
 1206            {
 01207                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1208            }
 01209            if (timeout != null)
 1210            {
 01211                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1212            }
 01213            if (_queryParameters.Count > 0)
 1214            {
 01215                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1216            }
 1217            // Create HTTP transport objects
 01218            var _httpRequest = new HttpRequestMessage();
 01219            HttpResponseMessage _httpResponse = null;
 01220            _httpRequest.Method = new HttpMethod("POST");
 01221            _httpRequest.RequestUri = new System.Uri(_url);
 1222            // Set Headers
 01223            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1224            {
 01225                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1226            }
 01227            if (Client.AcceptLanguage != null)
 1228            {
 01229                if (_httpRequest.Headers.Contains("accept-language"))
 1230                {
 01231                    _httpRequest.Headers.Remove("accept-language");
 1232                }
 01233                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1234            }
 01235            if (clientRequestId != null)
 1236            {
 01237                if (_httpRequest.Headers.Contains("client-request-id"))
 1238                {
 01239                    _httpRequest.Headers.Remove("client-request-id");
 1240                }
 01241                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1242            }
 01243            if (returnClientRequestId != null)
 1244            {
 01245                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1246                {
 01247                    _httpRequest.Headers.Remove("return-client-request-id");
 1248                }
 01249                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1250            }
 01251            if (ocpDate != null)
 1252            {
 01253                if (_httpRequest.Headers.Contains("ocp-date"))
 1254                {
 01255                    _httpRequest.Headers.Remove("ocp-date");
 1256                }
 01257                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1258            }
 1259
 1260
 01261            if (customHeaders != null)
 1262            {
 01263                foreach(var _header in customHeaders)
 1264                {
 01265                    if (_httpRequest.Headers.Contains(_header.Key))
 1266                    {
 01267                        _httpRequest.Headers.Remove(_header.Key);
 1268                    }
 01269                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1270                }
 1271            }
 1272
 1273            // Serialize Request
 01274            string _requestContent = null;
 01275            if(nodeRebootParameter != null)
 1276            {
 01277                _requestContent = SafeJsonConvert.SerializeObject(nodeRebootParameter, Client.SerializationSettings);
 01278                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01279                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1280            }
 1281            // Set Credentials
 01282            if (Client.Credentials != null)
 1283            {
 01284                cancellationToken.ThrowIfCancellationRequested();
 01285                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1286            }
 1287            // Send Request
 01288            if (_shouldTrace)
 1289            {
 01290                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1291            }
 01292            cancellationToken.ThrowIfCancellationRequested();
 01293            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01294            if (_shouldTrace)
 1295            {
 01296                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1297            }
 01298            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01299            cancellationToken.ThrowIfCancellationRequested();
 01300            string _responseContent = null;
 01301            if ((int)_statusCode != 202)
 1302            {
 01303                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1304                try
 1305                {
 01306                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01307                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01308                    if (_errorBody != null)
 1309                    {
 01310                        ex.Body = _errorBody;
 1311                    }
 01312                }
 01313                catch (JsonException)
 1314                {
 1315                    // Ignore the exception
 01316                }
 01317                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01318                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01319                if (_shouldTrace)
 1320                {
 01321                    ServiceClientTracing.Error(_invocationId, ex);
 1322                }
 01323                _httpRequest.Dispose();
 01324                if (_httpResponse != null)
 1325                {
 01326                    _httpResponse.Dispose();
 1327                }
 01328                throw ex;
 1329            }
 1330            // Create Result
 01331            var _result = new AzureOperationHeaderResponse<ComputeNodeRebootHeaders>();
 01332            _result.Request = _httpRequest;
 01333            _result.Response = _httpResponse;
 01334            if (_httpResponse.Headers.Contains("request-id"))
 1335            {
 01336                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1337            }
 1338            try
 1339            {
 01340                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeRebootHeaders>(JsonSerializer.Cre
 01341            }
 01342            catch (JsonException ex)
 1343            {
 01344                _httpRequest.Dispose();
 01345                if (_httpResponse != null)
 1346                {
 01347                    _httpResponse.Dispose();
 1348                }
 01349                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1350            }
 01351            if (_shouldTrace)
 1352            {
 01353                ServiceClientTracing.Exit(_invocationId, _result);
 1354            }
 01355            return _result;
 01356        }
 1357
 1358        /// <summary>
 1359        /// Reinstalls the operating system on the specified Compute Node.
 1360        /// </summary>
 1361        /// <remarks>
 1362        /// You can reinstall the operating system on a Compute Node only if it is in
 1363        /// an idle or running state. This API can be invoked only on Pools created
 1364        /// with the cloud service configuration property.
 1365        /// </remarks>
 1366        /// <param name='poolId'>
 1367        /// The ID of the Pool that contains the Compute Node.
 1368        /// </param>
 1369        /// <param name='nodeId'>
 1370        /// The ID of the Compute Node that you want to restart.
 1371        /// </param>
 1372        /// <param name='nodeReimageOption'>
 1373        /// When to reimage the Compute Node and what to do with currently running
 1374        /// Tasks. The default value is requeue. Possible values include: 'requeue',
 1375        /// 'terminate', 'taskCompletion', 'retainedData'
 1376        /// </param>
 1377        /// <param name='computeNodeReimageOptions'>
 1378        /// Additional parameters for the operation
 1379        /// </param>
 1380        /// <param name='customHeaders'>
 1381        /// Headers that will be added to request.
 1382        /// </param>
 1383        /// <param name='cancellationToken'>
 1384        /// The cancellation token.
 1385        /// </param>
 1386        /// <exception cref="BatchErrorException">
 1387        /// Thrown when the operation returned an invalid status code
 1388        /// </exception>
 1389        /// <exception cref="ValidationException">
 1390        /// Thrown when a required parameter is null
 1391        /// </exception>
 1392        /// <exception cref="System.ArgumentNullException">
 1393        /// Thrown when a required parameter is null
 1394        /// </exception>
 1395        /// <return>
 1396        /// A response object containing the response body and response headers.
 1397        /// </return>
 1398        public async Task<AzureOperationHeaderResponse<ComputeNodeReimageHeaders>> ReimageWithHttpMessagesAsync(string p
 1399        {
 01400            if (Client.BatchUrl == null)
 1401            {
 01402                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1403            }
 01404            if (poolId == null)
 1405            {
 01406                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1407            }
 01408            if (nodeId == null)
 1409            {
 01410                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1411            }
 01412            if (Client.ApiVersion == null)
 1413            {
 01414                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1415            }
 01416            int? timeout = default(int?);
 01417            if (computeNodeReimageOptions != null)
 1418            {
 01419                timeout = computeNodeReimageOptions.Timeout;
 1420            }
 01421            System.Guid? clientRequestId = default(System.Guid?);
 01422            if (computeNodeReimageOptions != null)
 1423            {
 01424                clientRequestId = computeNodeReimageOptions.ClientRequestId;
 1425            }
 01426            bool? returnClientRequestId = default(bool?);
 01427            if (computeNodeReimageOptions != null)
 1428            {
 01429                returnClientRequestId = computeNodeReimageOptions.ReturnClientRequestId;
 1430            }
 01431            System.DateTime? ocpDate = default(System.DateTime?);
 01432            if (computeNodeReimageOptions != null)
 1433            {
 01434                ocpDate = computeNodeReimageOptions.OcpDate;
 1435            }
 01436            NodeReimageParameter nodeReimageParameter = default(NodeReimageParameter);
 01437            if (nodeReimageOption != null)
 1438            {
 01439                nodeReimageParameter = new NodeReimageParameter();
 01440                nodeReimageParameter.NodeReimageOption = nodeReimageOption;
 1441            }
 1442            // Tracing
 01443            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01444            string _invocationId = null;
 01445            if (_shouldTrace)
 1446            {
 01447                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01448                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01449                tracingParameters.Add("poolId", poolId);
 01450                tracingParameters.Add("nodeId", nodeId);
 01451                tracingParameters.Add("timeout", timeout);
 01452                tracingParameters.Add("clientRequestId", clientRequestId);
 01453                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01454                tracingParameters.Add("ocpDate", ocpDate);
 01455                tracingParameters.Add("nodeReimageParameter", nodeReimageParameter);
 01456                tracingParameters.Add("cancellationToken", cancellationToken);
 01457                ServiceClientTracing.Enter(_invocationId, this, "Reimage", tracingParameters);
 1458            }
 1459            // Construct URL
 01460            var _baseUrl = Client.BaseUri;
 01461            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/reimage";
 01462            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01463            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 01464            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 01465            List<string> _queryParameters = new List<string>();
 01466            if (Client.ApiVersion != null)
 1467            {
 01468                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1469            }
 01470            if (timeout != null)
 1471            {
 01472                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1473            }
 01474            if (_queryParameters.Count > 0)
 1475            {
 01476                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1477            }
 1478            // Create HTTP transport objects
 01479            var _httpRequest = new HttpRequestMessage();
 01480            HttpResponseMessage _httpResponse = null;
 01481            _httpRequest.Method = new HttpMethod("POST");
 01482            _httpRequest.RequestUri = new System.Uri(_url);
 1483            // Set Headers
 01484            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1485            {
 01486                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1487            }
 01488            if (Client.AcceptLanguage != null)
 1489            {
 01490                if (_httpRequest.Headers.Contains("accept-language"))
 1491                {
 01492                    _httpRequest.Headers.Remove("accept-language");
 1493                }
 01494                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1495            }
 01496            if (clientRequestId != null)
 1497            {
 01498                if (_httpRequest.Headers.Contains("client-request-id"))
 1499                {
 01500                    _httpRequest.Headers.Remove("client-request-id");
 1501                }
 01502                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1503            }
 01504            if (returnClientRequestId != null)
 1505            {
 01506                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1507                {
 01508                    _httpRequest.Headers.Remove("return-client-request-id");
 1509                }
 01510                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1511            }
 01512            if (ocpDate != null)
 1513            {
 01514                if (_httpRequest.Headers.Contains("ocp-date"))
 1515                {
 01516                    _httpRequest.Headers.Remove("ocp-date");
 1517                }
 01518                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1519            }
 1520
 1521
 01522            if (customHeaders != null)
 1523            {
 01524                foreach(var _header in customHeaders)
 1525                {
 01526                    if (_httpRequest.Headers.Contains(_header.Key))
 1527                    {
 01528                        _httpRequest.Headers.Remove(_header.Key);
 1529                    }
 01530                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1531                }
 1532            }
 1533
 1534            // Serialize Request
 01535            string _requestContent = null;
 01536            if(nodeReimageParameter != null)
 1537            {
 01538                _requestContent = SafeJsonConvert.SerializeObject(nodeReimageParameter, Client.SerializationSettings);
 01539                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01540                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1541            }
 1542            // Set Credentials
 01543            if (Client.Credentials != null)
 1544            {
 01545                cancellationToken.ThrowIfCancellationRequested();
 01546                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1547            }
 1548            // Send Request
 01549            if (_shouldTrace)
 1550            {
 01551                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1552            }
 01553            cancellationToken.ThrowIfCancellationRequested();
 01554            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01555            if (_shouldTrace)
 1556            {
 01557                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1558            }
 01559            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01560            cancellationToken.ThrowIfCancellationRequested();
 01561            string _responseContent = null;
 01562            if ((int)_statusCode != 202)
 1563            {
 01564                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1565                try
 1566                {
 01567                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01568                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01569                    if (_errorBody != null)
 1570                    {
 01571                        ex.Body = _errorBody;
 1572                    }
 01573                }
 01574                catch (JsonException)
 1575                {
 1576                    // Ignore the exception
 01577                }
 01578                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01579                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01580                if (_shouldTrace)
 1581                {
 01582                    ServiceClientTracing.Error(_invocationId, ex);
 1583                }
 01584                _httpRequest.Dispose();
 01585                if (_httpResponse != null)
 1586                {
 01587                    _httpResponse.Dispose();
 1588                }
 01589                throw ex;
 1590            }
 1591            // Create Result
 01592            var _result = new AzureOperationHeaderResponse<ComputeNodeReimageHeaders>();
 01593            _result.Request = _httpRequest;
 01594            _result.Response = _httpResponse;
 01595            if (_httpResponse.Headers.Contains("request-id"))
 1596            {
 01597                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1598            }
 1599            try
 1600            {
 01601                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeReimageHeaders>(JsonSerializer.Cr
 01602            }
 01603            catch (JsonException ex)
 1604            {
 01605                _httpRequest.Dispose();
 01606                if (_httpResponse != null)
 1607                {
 01608                    _httpResponse.Dispose();
 1609                }
 01610                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1611            }
 01612            if (_shouldTrace)
 1613            {
 01614                ServiceClientTracing.Exit(_invocationId, _result);
 1615            }
 01616            return _result;
 01617        }
 1618
 1619        /// <summary>
 1620        /// Disables Task scheduling on the specified Compute Node.
 1621        /// </summary>
 1622        /// <remarks>
 1623        /// You can disable Task scheduling on a Compute Node only if its current
 1624        /// scheduling state is enabled.
 1625        /// </remarks>
 1626        /// <param name='poolId'>
 1627        /// The ID of the Pool that contains the Compute Node.
 1628        /// </param>
 1629        /// <param name='nodeId'>
 1630        /// The ID of the Compute Node on which you want to disable Task scheduling.
 1631        /// </param>
 1632        /// <param name='nodeDisableSchedulingOption'>
 1633        /// What to do with currently running Tasks when disabling Task scheduling on
 1634        /// the Compute Node. The default value is requeue. Possible values include:
 1635        /// 'requeue', 'terminate', 'taskCompletion'
 1636        /// </param>
 1637        /// <param name='computeNodeDisableSchedulingOptions'>
 1638        /// Additional parameters for the operation
 1639        /// </param>
 1640        /// <param name='customHeaders'>
 1641        /// Headers that will be added to request.
 1642        /// </param>
 1643        /// <param name='cancellationToken'>
 1644        /// The cancellation token.
 1645        /// </param>
 1646        /// <exception cref="BatchErrorException">
 1647        /// Thrown when the operation returned an invalid status code
 1648        /// </exception>
 1649        /// <exception cref="ValidationException">
 1650        /// Thrown when a required parameter is null
 1651        /// </exception>
 1652        /// <exception cref="System.ArgumentNullException">
 1653        /// Thrown when a required parameter is null
 1654        /// </exception>
 1655        /// <return>
 1656        /// A response object containing the response body and response headers.
 1657        /// </return>
 1658        public async Task<AzureOperationHeaderResponse<ComputeNodeDisableSchedulingHeaders>> DisableSchedulingWithHttpMe
 1659        {
 01660            if (Client.BatchUrl == null)
 1661            {
 01662                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1663            }
 01664            if (poolId == null)
 1665            {
 01666                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1667            }
 01668            if (nodeId == null)
 1669            {
 01670                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1671            }
 01672            if (Client.ApiVersion == null)
 1673            {
 01674                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1675            }
 01676            int? timeout = default(int?);
 01677            if (computeNodeDisableSchedulingOptions != null)
 1678            {
 01679                timeout = computeNodeDisableSchedulingOptions.Timeout;
 1680            }
 01681            System.Guid? clientRequestId = default(System.Guid?);
 01682            if (computeNodeDisableSchedulingOptions != null)
 1683            {
 01684                clientRequestId = computeNodeDisableSchedulingOptions.ClientRequestId;
 1685            }
 01686            bool? returnClientRequestId = default(bool?);
 01687            if (computeNodeDisableSchedulingOptions != null)
 1688            {
 01689                returnClientRequestId = computeNodeDisableSchedulingOptions.ReturnClientRequestId;
 1690            }
 01691            System.DateTime? ocpDate = default(System.DateTime?);
 01692            if (computeNodeDisableSchedulingOptions != null)
 1693            {
 01694                ocpDate = computeNodeDisableSchedulingOptions.OcpDate;
 1695            }
 01696            NodeDisableSchedulingParameter nodeDisableSchedulingParameter = default(NodeDisableSchedulingParameter);
 01697            if (nodeDisableSchedulingOption != null)
 1698            {
 01699                nodeDisableSchedulingParameter = new NodeDisableSchedulingParameter();
 01700                nodeDisableSchedulingParameter.NodeDisableSchedulingOption = nodeDisableSchedulingOption;
 1701            }
 1702            // Tracing
 01703            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01704            string _invocationId = null;
 01705            if (_shouldTrace)
 1706            {
 01707                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01708                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01709                tracingParameters.Add("poolId", poolId);
 01710                tracingParameters.Add("nodeId", nodeId);
 01711                tracingParameters.Add("timeout", timeout);
 01712                tracingParameters.Add("clientRequestId", clientRequestId);
 01713                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01714                tracingParameters.Add("ocpDate", ocpDate);
 01715                tracingParameters.Add("nodeDisableSchedulingParameter", nodeDisableSchedulingParameter);
 01716                tracingParameters.Add("cancellationToken", cancellationToken);
 01717                ServiceClientTracing.Enter(_invocationId, this, "DisableScheduling", tracingParameters);
 1718            }
 1719            // Construct URL
 01720            var _baseUrl = Client.BaseUri;
 01721            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/disablescheduling
 01722            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01723            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 01724            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 01725            List<string> _queryParameters = new List<string>();
 01726            if (Client.ApiVersion != null)
 1727            {
 01728                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1729            }
 01730            if (timeout != null)
 1731            {
 01732                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1733            }
 01734            if (_queryParameters.Count > 0)
 1735            {
 01736                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1737            }
 1738            // Create HTTP transport objects
 01739            var _httpRequest = new HttpRequestMessage();
 01740            HttpResponseMessage _httpResponse = null;
 01741            _httpRequest.Method = new HttpMethod("POST");
 01742            _httpRequest.RequestUri = new System.Uri(_url);
 1743            // Set Headers
 01744            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1745            {
 01746                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1747            }
 01748            if (Client.AcceptLanguage != null)
 1749            {
 01750                if (_httpRequest.Headers.Contains("accept-language"))
 1751                {
 01752                    _httpRequest.Headers.Remove("accept-language");
 1753                }
 01754                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1755            }
 01756            if (clientRequestId != null)
 1757            {
 01758                if (_httpRequest.Headers.Contains("client-request-id"))
 1759                {
 01760                    _httpRequest.Headers.Remove("client-request-id");
 1761                }
 01762                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1763            }
 01764            if (returnClientRequestId != null)
 1765            {
 01766                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1767                {
 01768                    _httpRequest.Headers.Remove("return-client-request-id");
 1769                }
 01770                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1771            }
 01772            if (ocpDate != null)
 1773            {
 01774                if (_httpRequest.Headers.Contains("ocp-date"))
 1775                {
 01776                    _httpRequest.Headers.Remove("ocp-date");
 1777                }
 01778                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1779            }
 1780
 1781
 01782            if (customHeaders != null)
 1783            {
 01784                foreach(var _header in customHeaders)
 1785                {
 01786                    if (_httpRequest.Headers.Contains(_header.Key))
 1787                    {
 01788                        _httpRequest.Headers.Remove(_header.Key);
 1789                    }
 01790                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1791                }
 1792            }
 1793
 1794            // Serialize Request
 01795            string _requestContent = null;
 01796            if(nodeDisableSchedulingParameter != null)
 1797            {
 01798                _requestContent = SafeJsonConvert.SerializeObject(nodeDisableSchedulingParameter, Client.SerializationSe
 01799                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01800                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1801            }
 1802            // Set Credentials
 01803            if (Client.Credentials != null)
 1804            {
 01805                cancellationToken.ThrowIfCancellationRequested();
 01806                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1807            }
 1808            // Send Request
 01809            if (_shouldTrace)
 1810            {
 01811                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1812            }
 01813            cancellationToken.ThrowIfCancellationRequested();
 01814            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01815            if (_shouldTrace)
 1816            {
 01817                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1818            }
 01819            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01820            cancellationToken.ThrowIfCancellationRequested();
 01821            string _responseContent = null;
 01822            if ((int)_statusCode != 200)
 1823            {
 01824                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1825                try
 1826                {
 01827                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01828                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01829                    if (_errorBody != null)
 1830                    {
 01831                        ex.Body = _errorBody;
 1832                    }
 01833                }
 01834                catch (JsonException)
 1835                {
 1836                    // Ignore the exception
 01837                }
 01838                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01839                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01840                if (_shouldTrace)
 1841                {
 01842                    ServiceClientTracing.Error(_invocationId, ex);
 1843                }
 01844                _httpRequest.Dispose();
 01845                if (_httpResponse != null)
 1846                {
 01847                    _httpResponse.Dispose();
 1848                }
 01849                throw ex;
 1850            }
 1851            // Create Result
 01852            var _result = new AzureOperationHeaderResponse<ComputeNodeDisableSchedulingHeaders>();
 01853            _result.Request = _httpRequest;
 01854            _result.Response = _httpResponse;
 01855            if (_httpResponse.Headers.Contains("request-id"))
 1856            {
 01857                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1858            }
 1859            try
 1860            {
 01861                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeDisableSchedulingHeaders>(JsonSer
 01862            }
 01863            catch (JsonException ex)
 1864            {
 01865                _httpRequest.Dispose();
 01866                if (_httpResponse != null)
 1867                {
 01868                    _httpResponse.Dispose();
 1869                }
 01870                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1871            }
 01872            if (_shouldTrace)
 1873            {
 01874                ServiceClientTracing.Exit(_invocationId, _result);
 1875            }
 01876            return _result;
 01877        }
 1878
 1879        /// <summary>
 1880        /// Enables Task scheduling on the specified Compute Node.
 1881        /// </summary>
 1882        /// <remarks>
 1883        /// You can enable Task scheduling on a Compute Node only if its current
 1884        /// scheduling state is disabled
 1885        /// </remarks>
 1886        /// <param name='poolId'>
 1887        /// The ID of the Pool that contains the Compute Node.
 1888        /// </param>
 1889        /// <param name='nodeId'>
 1890        /// The ID of the Compute Node on which you want to enable Task scheduling.
 1891        /// </param>
 1892        /// <param name='computeNodeEnableSchedulingOptions'>
 1893        /// Additional parameters for the operation
 1894        /// </param>
 1895        /// <param name='customHeaders'>
 1896        /// Headers that will be added to request.
 1897        /// </param>
 1898        /// <param name='cancellationToken'>
 1899        /// The cancellation token.
 1900        /// </param>
 1901        /// <exception cref="BatchErrorException">
 1902        /// Thrown when the operation returned an invalid status code
 1903        /// </exception>
 1904        /// <exception cref="ValidationException">
 1905        /// Thrown when a required parameter is null
 1906        /// </exception>
 1907        /// <exception cref="System.ArgumentNullException">
 1908        /// Thrown when a required parameter is null
 1909        /// </exception>
 1910        /// <return>
 1911        /// A response object containing the response body and response headers.
 1912        /// </return>
 1913        public async Task<AzureOperationHeaderResponse<ComputeNodeEnableSchedulingHeaders>> EnableSchedulingWithHttpMess
 1914        {
 01915            if (Client.BatchUrl == null)
 1916            {
 01917                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1918            }
 01919            if (poolId == null)
 1920            {
 01921                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1922            }
 01923            if (nodeId == null)
 1924            {
 01925                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1926            }
 01927            if (Client.ApiVersion == null)
 1928            {
 01929                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1930            }
 01931            int? timeout = default(int?);
 01932            if (computeNodeEnableSchedulingOptions != null)
 1933            {
 01934                timeout = computeNodeEnableSchedulingOptions.Timeout;
 1935            }
 01936            System.Guid? clientRequestId = default(System.Guid?);
 01937            if (computeNodeEnableSchedulingOptions != null)
 1938            {
 01939                clientRequestId = computeNodeEnableSchedulingOptions.ClientRequestId;
 1940            }
 01941            bool? returnClientRequestId = default(bool?);
 01942            if (computeNodeEnableSchedulingOptions != null)
 1943            {
 01944                returnClientRequestId = computeNodeEnableSchedulingOptions.ReturnClientRequestId;
 1945            }
 01946            System.DateTime? ocpDate = default(System.DateTime?);
 01947            if (computeNodeEnableSchedulingOptions != null)
 1948            {
 01949                ocpDate = computeNodeEnableSchedulingOptions.OcpDate;
 1950            }
 1951            // Tracing
 01952            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01953            string _invocationId = null;
 01954            if (_shouldTrace)
 1955            {
 01956                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01957                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01958                tracingParameters.Add("poolId", poolId);
 01959                tracingParameters.Add("nodeId", nodeId);
 01960                tracingParameters.Add("timeout", timeout);
 01961                tracingParameters.Add("clientRequestId", clientRequestId);
 01962                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01963                tracingParameters.Add("ocpDate", ocpDate);
 01964                tracingParameters.Add("cancellationToken", cancellationToken);
 01965                ServiceClientTracing.Enter(_invocationId, this, "EnableScheduling", tracingParameters);
 1966            }
 1967            // Construct URL
 01968            var _baseUrl = Client.BaseUri;
 01969            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/enablescheduling"
 01970            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01971            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 01972            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 01973            List<string> _queryParameters = new List<string>();
 01974            if (Client.ApiVersion != null)
 1975            {
 01976                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1977            }
 01978            if (timeout != null)
 1979            {
 01980                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1981            }
 01982            if (_queryParameters.Count > 0)
 1983            {
 01984                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1985            }
 1986            // Create HTTP transport objects
 01987            var _httpRequest = new HttpRequestMessage();
 01988            HttpResponseMessage _httpResponse = null;
 01989            _httpRequest.Method = new HttpMethod("POST");
 01990            _httpRequest.RequestUri = new System.Uri(_url);
 1991            // Set Headers
 01992            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1993            {
 01994                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1995            }
 01996            if (Client.AcceptLanguage != null)
 1997            {
 01998                if (_httpRequest.Headers.Contains("accept-language"))
 1999                {
 02000                    _httpRequest.Headers.Remove("accept-language");
 2001                }
 02002                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2003            }
 02004            if (clientRequestId != null)
 2005            {
 02006                if (_httpRequest.Headers.Contains("client-request-id"))
 2007                {
 02008                    _httpRequest.Headers.Remove("client-request-id");
 2009                }
 02010                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2011            }
 02012            if (returnClientRequestId != null)
 2013            {
 02014                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2015                {
 02016                    _httpRequest.Headers.Remove("return-client-request-id");
 2017                }
 02018                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2019            }
 02020            if (ocpDate != null)
 2021            {
 02022                if (_httpRequest.Headers.Contains("ocp-date"))
 2023                {
 02024                    _httpRequest.Headers.Remove("ocp-date");
 2025                }
 02026                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2027            }
 2028
 2029
 02030            if (customHeaders != null)
 2031            {
 02032                foreach(var _header in customHeaders)
 2033                {
 02034                    if (_httpRequest.Headers.Contains(_header.Key))
 2035                    {
 02036                        _httpRequest.Headers.Remove(_header.Key);
 2037                    }
 02038                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2039                }
 2040            }
 2041
 2042            // Serialize Request
 02043            string _requestContent = null;
 2044            // Set Credentials
 02045            if (Client.Credentials != null)
 2046            {
 02047                cancellationToken.ThrowIfCancellationRequested();
 02048                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2049            }
 2050            // Send Request
 02051            if (_shouldTrace)
 2052            {
 02053                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2054            }
 02055            cancellationToken.ThrowIfCancellationRequested();
 02056            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02057            if (_shouldTrace)
 2058            {
 02059                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2060            }
 02061            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02062            cancellationToken.ThrowIfCancellationRequested();
 02063            string _responseContent = null;
 02064            if ((int)_statusCode != 200)
 2065            {
 02066                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2067                try
 2068                {
 02069                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02070                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02071                    if (_errorBody != null)
 2072                    {
 02073                        ex.Body = _errorBody;
 2074                    }
 02075                }
 02076                catch (JsonException)
 2077                {
 2078                    // Ignore the exception
 02079                }
 02080                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02081                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02082                if (_shouldTrace)
 2083                {
 02084                    ServiceClientTracing.Error(_invocationId, ex);
 2085                }
 02086                _httpRequest.Dispose();
 02087                if (_httpResponse != null)
 2088                {
 02089                    _httpResponse.Dispose();
 2090                }
 02091                throw ex;
 2092            }
 2093            // Create Result
 02094            var _result = new AzureOperationHeaderResponse<ComputeNodeEnableSchedulingHeaders>();
 02095            _result.Request = _httpRequest;
 02096            _result.Response = _httpResponse;
 02097            if (_httpResponse.Headers.Contains("request-id"))
 2098            {
 02099                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2100            }
 2101            try
 2102            {
 02103                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeEnableSchedulingHeaders>(JsonSeri
 02104            }
 02105            catch (JsonException ex)
 2106            {
 02107                _httpRequest.Dispose();
 02108                if (_httpResponse != null)
 2109                {
 02110                    _httpResponse.Dispose();
 2111                }
 02112                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2113            }
 02114            if (_shouldTrace)
 2115            {
 02116                ServiceClientTracing.Exit(_invocationId, _result);
 2117            }
 02118            return _result;
 02119        }
 2120
 2121        /// <summary>
 2122        /// Gets the settings required for remote login to a Compute Node.
 2123        /// </summary>
 2124        /// <remarks>
 2125        /// Before you can remotely login to a Compute Node using the remote login
 2126        /// settings, you must create a user Account on the Compute Node. This API can
 2127        /// be invoked only on Pools created with the virtual machine configuration
 2128        /// property. For Pools created with a cloud service configuration, see the
 2129        /// GetRemoteDesktop API.
 2130        /// </remarks>
 2131        /// <param name='poolId'>
 2132        /// The ID of the Pool that contains the Compute Node.
 2133        /// </param>
 2134        /// <param name='nodeId'>
 2135        /// The ID of the Compute Node for which to obtain the remote login settings.
 2136        /// </param>
 2137        /// <param name='computeNodeGetRemoteLoginSettingsOptions'>
 2138        /// Additional parameters for the operation
 2139        /// </param>
 2140        /// <param name='customHeaders'>
 2141        /// Headers that will be added to request.
 2142        /// </param>
 2143        /// <param name='cancellationToken'>
 2144        /// The cancellation token.
 2145        /// </param>
 2146        /// <exception cref="BatchErrorException">
 2147        /// Thrown when the operation returned an invalid status code
 2148        /// </exception>
 2149        /// <exception cref="SerializationException">
 2150        /// Thrown when unable to deserialize the response
 2151        /// </exception>
 2152        /// <exception cref="ValidationException">
 2153        /// Thrown when a required parameter is null
 2154        /// </exception>
 2155        /// <exception cref="System.ArgumentNullException">
 2156        /// Thrown when a required parameter is null
 2157        /// </exception>
 2158        /// <return>
 2159        /// A response object containing the response body and response headers.
 2160        /// </return>
 2161        public async Task<AzureOperationResponse<ComputeNodeGetRemoteLoginSettingsResult,ComputeNodeGetRemoteLoginSettin
 2162        {
 02163            if (Client.BatchUrl == null)
 2164            {
 02165                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2166            }
 02167            if (poolId == null)
 2168            {
 02169                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 2170            }
 02171            if (nodeId == null)
 2172            {
 02173                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 2174            }
 02175            if (Client.ApiVersion == null)
 2176            {
 02177                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2178            }
 02179            int? timeout = default(int?);
 02180            if (computeNodeGetRemoteLoginSettingsOptions != null)
 2181            {
 02182                timeout = computeNodeGetRemoteLoginSettingsOptions.Timeout;
 2183            }
 02184            System.Guid? clientRequestId = default(System.Guid?);
 02185            if (computeNodeGetRemoteLoginSettingsOptions != null)
 2186            {
 02187                clientRequestId = computeNodeGetRemoteLoginSettingsOptions.ClientRequestId;
 2188            }
 02189            bool? returnClientRequestId = default(bool?);
 02190            if (computeNodeGetRemoteLoginSettingsOptions != null)
 2191            {
 02192                returnClientRequestId = computeNodeGetRemoteLoginSettingsOptions.ReturnClientRequestId;
 2193            }
 02194            System.DateTime? ocpDate = default(System.DateTime?);
 02195            if (computeNodeGetRemoteLoginSettingsOptions != null)
 2196            {
 02197                ocpDate = computeNodeGetRemoteLoginSettingsOptions.OcpDate;
 2198            }
 2199            // Tracing
 02200            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02201            string _invocationId = null;
 02202            if (_shouldTrace)
 2203            {
 02204                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02205                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02206                tracingParameters.Add("poolId", poolId);
 02207                tracingParameters.Add("nodeId", nodeId);
 02208                tracingParameters.Add("timeout", timeout);
 02209                tracingParameters.Add("clientRequestId", clientRequestId);
 02210                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02211                tracingParameters.Add("ocpDate", ocpDate);
 02212                tracingParameters.Add("cancellationToken", cancellationToken);
 02213                ServiceClientTracing.Enter(_invocationId, this, "GetRemoteLoginSettings", tracingParameters);
 2214            }
 2215            // Construct URL
 02216            var _baseUrl = Client.BaseUri;
 02217            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/remoteloginsettin
 02218            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02219            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 02220            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 02221            List<string> _queryParameters = new List<string>();
 02222            if (Client.ApiVersion != null)
 2223            {
 02224                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2225            }
 02226            if (timeout != null)
 2227            {
 02228                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2229            }
 02230            if (_queryParameters.Count > 0)
 2231            {
 02232                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2233            }
 2234            // Create HTTP transport objects
 02235            var _httpRequest = new HttpRequestMessage();
 02236            HttpResponseMessage _httpResponse = null;
 02237            _httpRequest.Method = new HttpMethod("GET");
 02238            _httpRequest.RequestUri = new System.Uri(_url);
 2239            // Set Headers
 02240            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2241            {
 02242                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2243            }
 02244            if (Client.AcceptLanguage != null)
 2245            {
 02246                if (_httpRequest.Headers.Contains("accept-language"))
 2247                {
 02248                    _httpRequest.Headers.Remove("accept-language");
 2249                }
 02250                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2251            }
 02252            if (clientRequestId != null)
 2253            {
 02254                if (_httpRequest.Headers.Contains("client-request-id"))
 2255                {
 02256                    _httpRequest.Headers.Remove("client-request-id");
 2257                }
 02258                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2259            }
 02260            if (returnClientRequestId != null)
 2261            {
 02262                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2263                {
 02264                    _httpRequest.Headers.Remove("return-client-request-id");
 2265                }
 02266                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2267            }
 02268            if (ocpDate != null)
 2269            {
 02270                if (_httpRequest.Headers.Contains("ocp-date"))
 2271                {
 02272                    _httpRequest.Headers.Remove("ocp-date");
 2273                }
 02274                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2275            }
 2276
 2277
 02278            if (customHeaders != null)
 2279            {
 02280                foreach(var _header in customHeaders)
 2281                {
 02282                    if (_httpRequest.Headers.Contains(_header.Key))
 2283                    {
 02284                        _httpRequest.Headers.Remove(_header.Key);
 2285                    }
 02286                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2287                }
 2288            }
 2289
 2290            // Serialize Request
 02291            string _requestContent = null;
 2292            // Set Credentials
 02293            if (Client.Credentials != null)
 2294            {
 02295                cancellationToken.ThrowIfCancellationRequested();
 02296                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2297            }
 2298            // Send Request
 02299            if (_shouldTrace)
 2300            {
 02301                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2302            }
 02303            cancellationToken.ThrowIfCancellationRequested();
 02304            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02305            if (_shouldTrace)
 2306            {
 02307                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2308            }
 02309            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02310            cancellationToken.ThrowIfCancellationRequested();
 02311            string _responseContent = null;
 02312            if ((int)_statusCode != 200)
 2313            {
 02314                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2315                try
 2316                {
 02317                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02318                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02319                    if (_errorBody != null)
 2320                    {
 02321                        ex.Body = _errorBody;
 2322                    }
 02323                }
 02324                catch (JsonException)
 2325                {
 2326                    // Ignore the exception
 02327                }
 02328                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02329                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02330                if (_shouldTrace)
 2331                {
 02332                    ServiceClientTracing.Error(_invocationId, ex);
 2333                }
 02334                _httpRequest.Dispose();
 02335                if (_httpResponse != null)
 2336                {
 02337                    _httpResponse.Dispose();
 2338                }
 02339                throw ex;
 2340            }
 2341            // Create Result
 02342            var _result = new AzureOperationResponse<ComputeNodeGetRemoteLoginSettingsResult,ComputeNodeGetRemoteLoginSe
 02343            _result.Request = _httpRequest;
 02344            _result.Response = _httpResponse;
 02345            if (_httpResponse.Headers.Contains("request-id"))
 2346            {
 02347                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2348            }
 2349            // Deserialize Response
 02350            if ((int)_statusCode == 200)
 2351            {
 02352                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2353                try
 2354                {
 02355                    _result.Body = SafeJsonConvert.DeserializeObject<ComputeNodeGetRemoteLoginSettingsResult>(_responseC
 02356                }
 02357                catch (JsonException ex)
 2358                {
 02359                    _httpRequest.Dispose();
 02360                    if (_httpResponse != null)
 2361                    {
 02362                        _httpResponse.Dispose();
 2363                    }
 02364                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2365                }
 2366            }
 2367            try
 2368            {
 02369                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeGetRemoteLoginSettingsHeaders>(Js
 02370            }
 02371            catch (JsonException ex)
 2372            {
 02373                _httpRequest.Dispose();
 02374                if (_httpResponse != null)
 2375                {
 02376                    _httpResponse.Dispose();
 2377                }
 02378                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2379            }
 02380            if (_shouldTrace)
 2381            {
 02382                ServiceClientTracing.Exit(_invocationId, _result);
 2383            }
 02384            return _result;
 02385        }
 2386
 2387        /// <summary>
 2388        /// Gets the Remote Desktop Protocol file for the specified Compute Node.
 2389        /// </summary>
 2390        /// <remarks>
 2391        /// Before you can access a Compute Node by using the RDP file, you must create
 2392        /// a user Account on the Compute Node. This API can only be invoked on Pools
 2393        /// created with a cloud service configuration. For Pools created with a
 2394        /// virtual machine configuration, see the GetRemoteLoginSettings API.
 2395        /// </remarks>
 2396        /// <param name='poolId'>
 2397        /// The ID of the Pool that contains the Compute Node.
 2398        /// </param>
 2399        /// <param name='nodeId'>
 2400        /// The ID of the Compute Node for which you want to get the Remote Desktop
 2401        /// Protocol file.
 2402        /// </param>
 2403        /// <param name='computeNodeGetRemoteDesktopOptions'>
 2404        /// Additional parameters for the operation
 2405        /// </param>
 2406        /// <param name='customHeaders'>
 2407        /// Headers that will be added to request.
 2408        /// </param>
 2409        /// <param name='cancellationToken'>
 2410        /// The cancellation token.
 2411        /// </param>
 2412        /// <exception cref="BatchErrorException">
 2413        /// Thrown when the operation returned an invalid status code
 2414        /// </exception>
 2415        /// <exception cref="SerializationException">
 2416        /// Thrown when unable to deserialize the response
 2417        /// </exception>
 2418        /// <exception cref="ValidationException">
 2419        /// Thrown when a required parameter is null
 2420        /// </exception>
 2421        /// <exception cref="System.ArgumentNullException">
 2422        /// Thrown when a required parameter is null
 2423        /// </exception>
 2424        /// <return>
 2425        /// A response object containing the response body and response headers.
 2426        /// </return>
 2427        public async Task<AzureOperationResponse<Stream,ComputeNodeGetRemoteDesktopHeaders>> GetRemoteDesktopWithHttpMes
 2428        {
 02429            if (Client.BatchUrl == null)
 2430            {
 02431                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2432            }
 02433            if (poolId == null)
 2434            {
 02435                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 2436            }
 02437            if (nodeId == null)
 2438            {
 02439                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 2440            }
 02441            if (Client.ApiVersion == null)
 2442            {
 02443                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2444            }
 02445            int? timeout = default(int?);
 02446            if (computeNodeGetRemoteDesktopOptions != null)
 2447            {
 02448                timeout = computeNodeGetRemoteDesktopOptions.Timeout;
 2449            }
 02450            System.Guid? clientRequestId = default(System.Guid?);
 02451            if (computeNodeGetRemoteDesktopOptions != null)
 2452            {
 02453                clientRequestId = computeNodeGetRemoteDesktopOptions.ClientRequestId;
 2454            }
 02455            bool? returnClientRequestId = default(bool?);
 02456            if (computeNodeGetRemoteDesktopOptions != null)
 2457            {
 02458                returnClientRequestId = computeNodeGetRemoteDesktopOptions.ReturnClientRequestId;
 2459            }
 02460            System.DateTime? ocpDate = default(System.DateTime?);
 02461            if (computeNodeGetRemoteDesktopOptions != null)
 2462            {
 02463                ocpDate = computeNodeGetRemoteDesktopOptions.OcpDate;
 2464            }
 2465            // Tracing
 02466            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02467            string _invocationId = null;
 02468            if (_shouldTrace)
 2469            {
 02470                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02471                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02472                tracingParameters.Add("poolId", poolId);
 02473                tracingParameters.Add("nodeId", nodeId);
 02474                tracingParameters.Add("timeout", timeout);
 02475                tracingParameters.Add("clientRequestId", clientRequestId);
 02476                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02477                tracingParameters.Add("ocpDate", ocpDate);
 02478                tracingParameters.Add("cancellationToken", cancellationToken);
 02479                ServiceClientTracing.Enter(_invocationId, this, "GetRemoteDesktop", tracingParameters);
 2480            }
 2481            // Construct URL
 02482            var _baseUrl = Client.BaseUri;
 02483            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/rdp";
 02484            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02485            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 02486            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 02487            List<string> _queryParameters = new List<string>();
 02488            if (Client.ApiVersion != null)
 2489            {
 02490                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2491            }
 02492            if (timeout != null)
 2493            {
 02494                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2495            }
 02496            if (_queryParameters.Count > 0)
 2497            {
 02498                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2499            }
 2500            // Create HTTP transport objects
 02501            var _httpRequest = new HttpRequestMessage();
 02502            HttpResponseMessage _httpResponse = null;
 02503            _httpRequest.Method = new HttpMethod("GET");
 02504            _httpRequest.RequestUri = new System.Uri(_url);
 2505            // Set Headers
 02506            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2507            {
 02508                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2509            }
 02510            if (Client.AcceptLanguage != null)
 2511            {
 02512                if (_httpRequest.Headers.Contains("accept-language"))
 2513                {
 02514                    _httpRequest.Headers.Remove("accept-language");
 2515                }
 02516                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2517            }
 02518            if (clientRequestId != null)
 2519            {
 02520                if (_httpRequest.Headers.Contains("client-request-id"))
 2521                {
 02522                    _httpRequest.Headers.Remove("client-request-id");
 2523                }
 02524                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2525            }
 02526            if (returnClientRequestId != null)
 2527            {
 02528                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2529                {
 02530                    _httpRequest.Headers.Remove("return-client-request-id");
 2531                }
 02532                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2533            }
 02534            if (ocpDate != null)
 2535            {
 02536                if (_httpRequest.Headers.Contains("ocp-date"))
 2537                {
 02538                    _httpRequest.Headers.Remove("ocp-date");
 2539                }
 02540                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2541            }
 2542
 2543
 02544            if (customHeaders != null)
 2545            {
 02546                foreach(var _header in customHeaders)
 2547                {
 02548                    if (_httpRequest.Headers.Contains(_header.Key))
 2549                    {
 02550                        _httpRequest.Headers.Remove(_header.Key);
 2551                    }
 02552                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2553                }
 2554            }
 2555
 2556            // Serialize Request
 02557            string _requestContent = null;
 2558            // Set Credentials
 02559            if (Client.Credentials != null)
 2560            {
 02561                cancellationToken.ThrowIfCancellationRequested();
 02562                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2563            }
 2564            // Send Request
 02565            if (_shouldTrace)
 2566            {
 02567                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2568            }
 02569            cancellationToken.ThrowIfCancellationRequested();
 02570            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 02571            if (_shouldTrace)
 2572            {
 02573                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2574            }
 02575            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02576            cancellationToken.ThrowIfCancellationRequested();
 02577            string _responseContent = null;
 02578            if ((int)_statusCode != 200)
 2579            {
 02580                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2581                try
 2582                {
 02583                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02584                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02585                    if (_errorBody != null)
 2586                    {
 02587                        ex.Body = _errorBody;
 2588                    }
 02589                }
 02590                catch (JsonException)
 2591                {
 2592                    // Ignore the exception
 02593                }
 02594                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02595                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02596                if (_shouldTrace)
 2597                {
 02598                    ServiceClientTracing.Error(_invocationId, ex);
 2599                }
 02600                _httpRequest.Dispose();
 02601                if (_httpResponse != null)
 2602                {
 02603                    _httpResponse.Dispose();
 2604                }
 02605                throw ex;
 2606            }
 2607            // Create Result
 02608            var _result = new AzureOperationResponse<Stream,ComputeNodeGetRemoteDesktopHeaders>();
 02609            _result.Request = _httpRequest;
 02610            _result.Response = _httpResponse;
 02611            if (_httpResponse.Headers.Contains("request-id"))
 2612            {
 02613                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2614            }
 2615            // Deserialize Response
 02616            if ((int)_statusCode == 200)
 2617            {
 02618                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 2619            }
 2620            try
 2621            {
 02622                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeGetRemoteDesktopHeaders>(JsonSeri
 02623            }
 02624            catch (JsonException ex)
 2625            {
 02626                _httpRequest.Dispose();
 02627                if (_httpResponse != null)
 2628                {
 02629                    _httpResponse.Dispose();
 2630                }
 02631                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2632            }
 02633            if (_shouldTrace)
 2634            {
 02635                ServiceClientTracing.Exit(_invocationId, _result);
 2636            }
 02637            return _result;
 02638        }
 2639
 2640        /// <summary>
 2641        /// Upload Azure Batch service log files from the specified Compute Node to
 2642        /// Azure Blob Storage.
 2643        /// </summary>
 2644        /// <remarks>
 2645        /// This is for gathering Azure Batch service log files in an automated fashion
 2646        /// from Compute Nodes if you are experiencing an error and wish to escalate to
 2647        /// Azure support. The Azure Batch service log files should be shared with
 2648        /// Azure support to aid in debugging issues with the Batch service.
 2649        /// </remarks>
 2650        /// <param name='poolId'>
 2651        /// The ID of the Pool that contains the Compute Node.
 2652        /// </param>
 2653        /// <param name='nodeId'>
 2654        /// The ID of the Compute Node from which you want to upload the Azure Batch
 2655        /// service log files.
 2656        /// </param>
 2657        /// <param name='uploadBatchServiceLogsConfiguration'>
 2658        /// The Azure Batch service log files upload configuration.
 2659        /// </param>
 2660        /// <param name='computeNodeUploadBatchServiceLogsOptions'>
 2661        /// Additional parameters for the operation
 2662        /// </param>
 2663        /// <param name='customHeaders'>
 2664        /// Headers that will be added to request.
 2665        /// </param>
 2666        /// <param name='cancellationToken'>
 2667        /// The cancellation token.
 2668        /// </param>
 2669        /// <exception cref="BatchErrorException">
 2670        /// Thrown when the operation returned an invalid status code
 2671        /// </exception>
 2672        /// <exception cref="SerializationException">
 2673        /// Thrown when unable to deserialize the response
 2674        /// </exception>
 2675        /// <exception cref="ValidationException">
 2676        /// Thrown when a required parameter is null
 2677        /// </exception>
 2678        /// <exception cref="System.ArgumentNullException">
 2679        /// Thrown when a required parameter is null
 2680        /// </exception>
 2681        /// <return>
 2682        /// A response object containing the response body and response headers.
 2683        /// </return>
 2684        public async Task<AzureOperationResponse<UploadBatchServiceLogsResult,ComputeNodeUploadBatchServiceLogsHeaders>>
 2685        {
 02686            if (Client.BatchUrl == null)
 2687            {
 02688                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2689            }
 02690            if (poolId == null)
 2691            {
 02692                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 2693            }
 02694            if (nodeId == null)
 2695            {
 02696                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 2697            }
 02698            if (uploadBatchServiceLogsConfiguration == null)
 2699            {
 02700                throw new ValidationException(ValidationRules.CannotBeNull, "uploadBatchServiceLogsConfiguration");
 2701            }
 02702            if (Client.ApiVersion == null)
 2703            {
 02704                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2705            }
 02706            int? timeout = default(int?);
 02707            if (computeNodeUploadBatchServiceLogsOptions != null)
 2708            {
 02709                timeout = computeNodeUploadBatchServiceLogsOptions.Timeout;
 2710            }
 02711            System.Guid? clientRequestId = default(System.Guid?);
 02712            if (computeNodeUploadBatchServiceLogsOptions != null)
 2713            {
 02714                clientRequestId = computeNodeUploadBatchServiceLogsOptions.ClientRequestId;
 2715            }
 02716            bool? returnClientRequestId = default(bool?);
 02717            if (computeNodeUploadBatchServiceLogsOptions != null)
 2718            {
 02719                returnClientRequestId = computeNodeUploadBatchServiceLogsOptions.ReturnClientRequestId;
 2720            }
 02721            System.DateTime? ocpDate = default(System.DateTime?);
 02722            if (computeNodeUploadBatchServiceLogsOptions != null)
 2723            {
 02724                ocpDate = computeNodeUploadBatchServiceLogsOptions.OcpDate;
 2725            }
 2726            // Tracing
 02727            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02728            string _invocationId = null;
 02729            if (_shouldTrace)
 2730            {
 02731                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02732                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02733                tracingParameters.Add("poolId", poolId);
 02734                tracingParameters.Add("nodeId", nodeId);
 02735                tracingParameters.Add("uploadBatchServiceLogsConfiguration", uploadBatchServiceLogsConfiguration);
 02736                tracingParameters.Add("timeout", timeout);
 02737                tracingParameters.Add("clientRequestId", clientRequestId);
 02738                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02739                tracingParameters.Add("ocpDate", ocpDate);
 02740                tracingParameters.Add("cancellationToken", cancellationToken);
 02741                ServiceClientTracing.Enter(_invocationId, this, "UploadBatchServiceLogs", tracingParameters);
 2742            }
 2743            // Construct URL
 02744            var _baseUrl = Client.BaseUri;
 02745            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/uploadbatchservic
 02746            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02747            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 02748            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 02749            List<string> _queryParameters = new List<string>();
 02750            if (Client.ApiVersion != null)
 2751            {
 02752                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2753            }
 02754            if (timeout != null)
 2755            {
 02756                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2757            }
 02758            if (_queryParameters.Count > 0)
 2759            {
 02760                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2761            }
 2762            // Create HTTP transport objects
 02763            var _httpRequest = new HttpRequestMessage();
 02764            HttpResponseMessage _httpResponse = null;
 02765            _httpRequest.Method = new HttpMethod("POST");
 02766            _httpRequest.RequestUri = new System.Uri(_url);
 2767            // Set Headers
 02768            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2769            {
 02770                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2771            }
 02772            if (Client.AcceptLanguage != null)
 2773            {
 02774                if (_httpRequest.Headers.Contains("accept-language"))
 2775                {
 02776                    _httpRequest.Headers.Remove("accept-language");
 2777                }
 02778                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2779            }
 02780            if (clientRequestId != null)
 2781            {
 02782                if (_httpRequest.Headers.Contains("client-request-id"))
 2783                {
 02784                    _httpRequest.Headers.Remove("client-request-id");
 2785                }
 02786                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2787            }
 02788            if (returnClientRequestId != null)
 2789            {
 02790                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2791                {
 02792                    _httpRequest.Headers.Remove("return-client-request-id");
 2793                }
 02794                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2795            }
 02796            if (ocpDate != null)
 2797            {
 02798                if (_httpRequest.Headers.Contains("ocp-date"))
 2799                {
 02800                    _httpRequest.Headers.Remove("ocp-date");
 2801                }
 02802                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2803            }
 2804
 2805
 02806            if (customHeaders != null)
 2807            {
 02808                foreach(var _header in customHeaders)
 2809                {
 02810                    if (_httpRequest.Headers.Contains(_header.Key))
 2811                    {
 02812                        _httpRequest.Headers.Remove(_header.Key);
 2813                    }
 02814                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2815                }
 2816            }
 2817
 2818            // Serialize Request
 02819            string _requestContent = null;
 02820            if(uploadBatchServiceLogsConfiguration != null)
 2821            {
 02822                _requestContent = SafeJsonConvert.SerializeObject(uploadBatchServiceLogsConfiguration, Client.Serializat
 02823                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 02824                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2825            }
 2826            // Set Credentials
 02827            if (Client.Credentials != null)
 2828            {
 02829                cancellationToken.ThrowIfCancellationRequested();
 02830                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2831            }
 2832            // Send Request
 02833            if (_shouldTrace)
 2834            {
 02835                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2836            }
 02837            cancellationToken.ThrowIfCancellationRequested();
 02838            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02839            if (_shouldTrace)
 2840            {
 02841                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2842            }
 02843            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02844            cancellationToken.ThrowIfCancellationRequested();
 02845            string _responseContent = null;
 02846            if ((int)_statusCode != 200)
 2847            {
 02848                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2849                try
 2850                {
 02851                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02852                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02853                    if (_errorBody != null)
 2854                    {
 02855                        ex.Body = _errorBody;
 2856                    }
 02857                }
 02858                catch (JsonException)
 2859                {
 2860                    // Ignore the exception
 02861                }
 02862                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02863                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02864                if (_shouldTrace)
 2865                {
 02866                    ServiceClientTracing.Error(_invocationId, ex);
 2867                }
 02868                _httpRequest.Dispose();
 02869                if (_httpResponse != null)
 2870                {
 02871                    _httpResponse.Dispose();
 2872                }
 02873                throw ex;
 2874            }
 2875            // Create Result
 02876            var _result = new AzureOperationResponse<UploadBatchServiceLogsResult,ComputeNodeUploadBatchServiceLogsHeade
 02877            _result.Request = _httpRequest;
 02878            _result.Response = _httpResponse;
 02879            if (_httpResponse.Headers.Contains("request-id"))
 2880            {
 02881                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2882            }
 2883            // Deserialize Response
 02884            if ((int)_statusCode == 200)
 2885            {
 02886                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2887                try
 2888                {
 02889                    _result.Body = SafeJsonConvert.DeserializeObject<UploadBatchServiceLogsResult>(_responseContent, Cli
 02890                }
 02891                catch (JsonException ex)
 2892                {
 02893                    _httpRequest.Dispose();
 02894                    if (_httpResponse != null)
 2895                    {
 02896                        _httpResponse.Dispose();
 2897                    }
 02898                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2899                }
 2900            }
 2901            try
 2902            {
 02903                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeUploadBatchServiceLogsHeaders>(Js
 02904            }
 02905            catch (JsonException ex)
 2906            {
 02907                _httpRequest.Dispose();
 02908                if (_httpResponse != null)
 2909                {
 02910                    _httpResponse.Dispose();
 2911                }
 02912                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2913            }
 02914            if (_shouldTrace)
 2915            {
 02916                ServiceClientTracing.Exit(_invocationId, _result);
 2917            }
 02918            return _result;
 02919        }
 2920
 2921        /// <summary>
 2922        /// Lists the Compute Nodes in the specified Pool.
 2923        /// </summary>
 2924        /// <param name='poolId'>
 2925        /// The ID of the Pool from which you want to list Compute Nodes.
 2926        /// </param>
 2927        /// <param name='computeNodeListOptions'>
 2928        /// Additional parameters for the operation
 2929        /// </param>
 2930        /// <param name='customHeaders'>
 2931        /// Headers that will be added to request.
 2932        /// </param>
 2933        /// <param name='cancellationToken'>
 2934        /// The cancellation token.
 2935        /// </param>
 2936        /// <exception cref="BatchErrorException">
 2937        /// Thrown when the operation returned an invalid status code
 2938        /// </exception>
 2939        /// <exception cref="SerializationException">
 2940        /// Thrown when unable to deserialize the response
 2941        /// </exception>
 2942        /// <exception cref="ValidationException">
 2943        /// Thrown when a required parameter is null
 2944        /// </exception>
 2945        /// <exception cref="System.ArgumentNullException">
 2946        /// Thrown when a required parameter is null
 2947        /// </exception>
 2948        /// <return>
 2949        /// A response object containing the response body and response headers.
 2950        /// </return>
 2951        public async Task<AzureOperationResponse<IPage<ComputeNode>,ComputeNodeListHeaders>> ListWithHttpMessagesAsync(s
 2952        {
 02953            if (Client.BatchUrl == null)
 2954            {
 02955                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2956            }
 02957            if (poolId == null)
 2958            {
 02959                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 2960            }
 02961            if (Client.ApiVersion == null)
 2962            {
 02963                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2964            }
 02965            string filter = default(string);
 02966            if (computeNodeListOptions != null)
 2967            {
 02968                filter = computeNodeListOptions.Filter;
 2969            }
 02970            string select = default(string);
 02971            if (computeNodeListOptions != null)
 2972            {
 02973                select = computeNodeListOptions.Select;
 2974            }
 02975            int? maxResults = default(int?);
 02976            if (computeNodeListOptions != null)
 2977            {
 02978                maxResults = computeNodeListOptions.MaxResults;
 2979            }
 02980            int? timeout = default(int?);
 02981            if (computeNodeListOptions != null)
 2982            {
 02983                timeout = computeNodeListOptions.Timeout;
 2984            }
 02985            System.Guid? clientRequestId = default(System.Guid?);
 02986            if (computeNodeListOptions != null)
 2987            {
 02988                clientRequestId = computeNodeListOptions.ClientRequestId;
 2989            }
 02990            bool? returnClientRequestId = default(bool?);
 02991            if (computeNodeListOptions != null)
 2992            {
 02993                returnClientRequestId = computeNodeListOptions.ReturnClientRequestId;
 2994            }
 02995            System.DateTime? ocpDate = default(System.DateTime?);
 02996            if (computeNodeListOptions != null)
 2997            {
 02998                ocpDate = computeNodeListOptions.OcpDate;
 2999            }
 3000            // Tracing
 03001            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03002            string _invocationId = null;
 03003            if (_shouldTrace)
 3004            {
 03005                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03006                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03007                tracingParameters.Add("poolId", poolId);
 03008                tracingParameters.Add("filter", filter);
 03009                tracingParameters.Add("select", select);
 03010                tracingParameters.Add("maxResults", maxResults);
 03011                tracingParameters.Add("timeout", timeout);
 03012                tracingParameters.Add("clientRequestId", clientRequestId);
 03013                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03014                tracingParameters.Add("ocpDate", ocpDate);
 03015                tracingParameters.Add("cancellationToken", cancellationToken);
 03016                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 3017            }
 3018            // Construct URL
 03019            var _baseUrl = Client.BaseUri;
 03020            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes";
 03021            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 03022            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 03023            List<string> _queryParameters = new List<string>();
 03024            if (Client.ApiVersion != null)
 3025            {
 03026                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 3027            }
 03028            if (filter != null)
 3029            {
 03030                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 3031            }
 03032            if (select != null)
 3033            {
 03034                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 3035            }
 03036            if (maxResults != null)
 3037            {
 03038                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 3039            }
 03040            if (timeout != null)
 3041            {
 03042                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 3043            }
 03044            if (_queryParameters.Count > 0)
 3045            {
 03046                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3047            }
 3048            // Create HTTP transport objects
 03049            var _httpRequest = new HttpRequestMessage();
 03050            HttpResponseMessage _httpResponse = null;
 03051            _httpRequest.Method = new HttpMethod("GET");
 03052            _httpRequest.RequestUri = new System.Uri(_url);
 3053            // Set Headers
 03054            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3055            {
 03056                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3057            }
 03058            if (Client.AcceptLanguage != null)
 3059            {
 03060                if (_httpRequest.Headers.Contains("accept-language"))
 3061                {
 03062                    _httpRequest.Headers.Remove("accept-language");
 3063                }
 03064                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3065            }
 03066            if (clientRequestId != null)
 3067            {
 03068                if (_httpRequest.Headers.Contains("client-request-id"))
 3069                {
 03070                    _httpRequest.Headers.Remove("client-request-id");
 3071                }
 03072                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3073            }
 03074            if (returnClientRequestId != null)
 3075            {
 03076                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3077                {
 03078                    _httpRequest.Headers.Remove("return-client-request-id");
 3079                }
 03080                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3081            }
 03082            if (ocpDate != null)
 3083            {
 03084                if (_httpRequest.Headers.Contains("ocp-date"))
 3085                {
 03086                    _httpRequest.Headers.Remove("ocp-date");
 3087                }
 03088                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3089            }
 3090
 3091
 03092            if (customHeaders != null)
 3093            {
 03094                foreach(var _header in customHeaders)
 3095                {
 03096                    if (_httpRequest.Headers.Contains(_header.Key))
 3097                    {
 03098                        _httpRequest.Headers.Remove(_header.Key);
 3099                    }
 03100                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3101                }
 3102            }
 3103
 3104            // Serialize Request
 03105            string _requestContent = null;
 3106            // Set Credentials
 03107            if (Client.Credentials != null)
 3108            {
 03109                cancellationToken.ThrowIfCancellationRequested();
 03110                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3111            }
 3112            // Send Request
 03113            if (_shouldTrace)
 3114            {
 03115                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3116            }
 03117            cancellationToken.ThrowIfCancellationRequested();
 03118            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03119            if (_shouldTrace)
 3120            {
 03121                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3122            }
 03123            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03124            cancellationToken.ThrowIfCancellationRequested();
 03125            string _responseContent = null;
 03126            if ((int)_statusCode != 200)
 3127            {
 03128                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3129                try
 3130                {
 03131                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03132                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03133                    if (_errorBody != null)
 3134                    {
 03135                        ex.Body = _errorBody;
 3136                    }
 03137                }
 03138                catch (JsonException)
 3139                {
 3140                    // Ignore the exception
 03141                }
 03142                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03143                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03144                if (_shouldTrace)
 3145                {
 03146                    ServiceClientTracing.Error(_invocationId, ex);
 3147                }
 03148                _httpRequest.Dispose();
 03149                if (_httpResponse != null)
 3150                {
 03151                    _httpResponse.Dispose();
 3152                }
 03153                throw ex;
 3154            }
 3155            // Create Result
 03156            var _result = new AzureOperationResponse<IPage<ComputeNode>,ComputeNodeListHeaders>();
 03157            _result.Request = _httpRequest;
 03158            _result.Response = _httpResponse;
 03159            if (_httpResponse.Headers.Contains("request-id"))
 3160            {
 03161                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3162            }
 3163            // Deserialize Response
 03164            if ((int)_statusCode == 200)
 3165            {
 03166                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3167                try
 3168                {
 03169                    _result.Body = SafeJsonConvert.DeserializeObject<Page<ComputeNode>>(_responseContent, Client.Deseria
 03170                }
 03171                catch (JsonException ex)
 3172                {
 03173                    _httpRequest.Dispose();
 03174                    if (_httpResponse != null)
 3175                    {
 03176                        _httpResponse.Dispose();
 3177                    }
 03178                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3179                }
 3180            }
 3181            try
 3182            {
 03183                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeListHeaders>(JsonSerializer.Creat
 03184            }
 03185            catch (JsonException ex)
 3186            {
 03187                _httpRequest.Dispose();
 03188                if (_httpResponse != null)
 3189                {
 03190                    _httpResponse.Dispose();
 3191                }
 03192                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3193            }
 03194            if (_shouldTrace)
 3195            {
 03196                ServiceClientTracing.Exit(_invocationId, _result);
 3197            }
 03198            return _result;
 03199        }
 3200
 3201        /// <summary>
 3202        /// Lists the Compute Nodes in the specified Pool.
 3203        /// </summary>
 3204        /// <param name='nextPageLink'>
 3205        /// The NextLink from the previous successful call to List operation.
 3206        /// </param>
 3207        /// <param name='computeNodeListNextOptions'>
 3208        /// Additional parameters for the operation
 3209        /// </param>
 3210        /// <param name='customHeaders'>
 3211        /// Headers that will be added to request.
 3212        /// </param>
 3213        /// <param name='cancellationToken'>
 3214        /// The cancellation token.
 3215        /// </param>
 3216        /// <exception cref="BatchErrorException">
 3217        /// Thrown when the operation returned an invalid status code
 3218        /// </exception>
 3219        /// <exception cref="SerializationException">
 3220        /// Thrown when unable to deserialize the response
 3221        /// </exception>
 3222        /// <exception cref="ValidationException">
 3223        /// Thrown when a required parameter is null
 3224        /// </exception>
 3225        /// <exception cref="System.ArgumentNullException">
 3226        /// Thrown when a required parameter is null
 3227        /// </exception>
 3228        /// <return>
 3229        /// A response object containing the response body and response headers.
 3230        /// </return>
 3231        public async Task<AzureOperationResponse<IPage<ComputeNode>,ComputeNodeListHeaders>> ListNextWithHttpMessagesAsy
 3232        {
 03233            if (nextPageLink == null)
 3234            {
 03235                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 3236            }
 03237            System.Guid? clientRequestId = default(System.Guid?);
 03238            if (computeNodeListNextOptions != null)
 3239            {
 03240                clientRequestId = computeNodeListNextOptions.ClientRequestId;
 3241            }
 03242            bool? returnClientRequestId = default(bool?);
 03243            if (computeNodeListNextOptions != null)
 3244            {
 03245                returnClientRequestId = computeNodeListNextOptions.ReturnClientRequestId;
 3246            }
 03247            System.DateTime? ocpDate = default(System.DateTime?);
 03248            if (computeNodeListNextOptions != null)
 3249            {
 03250                ocpDate = computeNodeListNextOptions.OcpDate;
 3251            }
 3252            // Tracing
 03253            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03254            string _invocationId = null;
 03255            if (_shouldTrace)
 3256            {
 03257                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03258                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03259                tracingParameters.Add("nextPageLink", nextPageLink);
 03260                tracingParameters.Add("clientRequestId", clientRequestId);
 03261                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03262                tracingParameters.Add("ocpDate", ocpDate);
 03263                tracingParameters.Add("cancellationToken", cancellationToken);
 03264                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 3265            }
 3266            // Construct URL
 03267            string _url = "{nextLink}";
 03268            _url = _url.Replace("{nextLink}", nextPageLink);
 03269            List<string> _queryParameters = new List<string>();
 03270            if (_queryParameters.Count > 0)
 3271            {
 03272                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3273            }
 3274            // Create HTTP transport objects
 03275            var _httpRequest = new HttpRequestMessage();
 03276            HttpResponseMessage _httpResponse = null;
 03277            _httpRequest.Method = new HttpMethod("GET");
 03278            _httpRequest.RequestUri = new System.Uri(_url);
 3279            // Set Headers
 03280            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3281            {
 03282                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3283            }
 03284            if (Client.AcceptLanguage != null)
 3285            {
 03286                if (_httpRequest.Headers.Contains("accept-language"))
 3287                {
 03288                    _httpRequest.Headers.Remove("accept-language");
 3289                }
 03290                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3291            }
 03292            if (clientRequestId != null)
 3293            {
 03294                if (_httpRequest.Headers.Contains("client-request-id"))
 3295                {
 03296                    _httpRequest.Headers.Remove("client-request-id");
 3297                }
 03298                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3299            }
 03300            if (returnClientRequestId != null)
 3301            {
 03302                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3303                {
 03304                    _httpRequest.Headers.Remove("return-client-request-id");
 3305                }
 03306                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3307            }
 03308            if (ocpDate != null)
 3309            {
 03310                if (_httpRequest.Headers.Contains("ocp-date"))
 3311                {
 03312                    _httpRequest.Headers.Remove("ocp-date");
 3313                }
 03314                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3315            }
 3316
 3317
 03318            if (customHeaders != null)
 3319            {
 03320                foreach(var _header in customHeaders)
 3321                {
 03322                    if (_httpRequest.Headers.Contains(_header.Key))
 3323                    {
 03324                        _httpRequest.Headers.Remove(_header.Key);
 3325                    }
 03326                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3327                }
 3328            }
 3329
 3330            // Serialize Request
 03331            string _requestContent = null;
 3332            // Set Credentials
 03333            if (Client.Credentials != null)
 3334            {
 03335                cancellationToken.ThrowIfCancellationRequested();
 03336                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3337            }
 3338            // Send Request
 03339            if (_shouldTrace)
 3340            {
 03341                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3342            }
 03343            cancellationToken.ThrowIfCancellationRequested();
 03344            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03345            if (_shouldTrace)
 3346            {
 03347                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3348            }
 03349            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03350            cancellationToken.ThrowIfCancellationRequested();
 03351            string _responseContent = null;
 03352            if ((int)_statusCode != 200)
 3353            {
 03354                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3355                try
 3356                {
 03357                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03358                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03359                    if (_errorBody != null)
 3360                    {
 03361                        ex.Body = _errorBody;
 3362                    }
 03363                }
 03364                catch (JsonException)
 3365                {
 3366                    // Ignore the exception
 03367                }
 03368                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03369                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03370                if (_shouldTrace)
 3371                {
 03372                    ServiceClientTracing.Error(_invocationId, ex);
 3373                }
 03374                _httpRequest.Dispose();
 03375                if (_httpResponse != null)
 3376                {
 03377                    _httpResponse.Dispose();
 3378                }
 03379                throw ex;
 3380            }
 3381            // Create Result
 03382            var _result = new AzureOperationResponse<IPage<ComputeNode>,ComputeNodeListHeaders>();
 03383            _result.Request = _httpRequest;
 03384            _result.Response = _httpResponse;
 03385            if (_httpResponse.Headers.Contains("request-id"))
 3386            {
 03387                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3388            }
 3389            // Deserialize Response
 03390            if ((int)_statusCode == 200)
 3391            {
 03392                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3393                try
 3394                {
 03395                    _result.Body = SafeJsonConvert.DeserializeObject<Page<ComputeNode>>(_responseContent, Client.Deseria
 03396                }
 03397                catch (JsonException ex)
 3398                {
 03399                    _httpRequest.Dispose();
 03400                    if (_httpResponse != null)
 3401                    {
 03402                        _httpResponse.Dispose();
 3403                    }
 03404                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3405                }
 3406            }
 3407            try
 3408            {
 03409                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<ComputeNodeListHeaders>(JsonSerializer.Creat
 03410            }
 03411            catch (JsonException ex)
 3412            {
 03413                _httpRequest.Dispose();
 03414                if (_httpResponse != null)
 3415                {
 03416                    _httpResponse.Dispose();
 3417                }
 03418                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3419            }
 03420            if (_shouldTrace)
 3421            {
 03422                ServiceClientTracing.Exit(_invocationId, _result);
 3423            }
 03424            return _result;
 03425        }
 3426
 3427    }
 3428}