< Summary

Class:Microsoft.Azure.Batch.Protocol.FileOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\FileOperations.cs
Covered lines:325
Uncovered lines:1005
Coverable lines:1330
Total lines:2743
Line coverage:24.4% (325 of 1330)
Covered branches:211
Total branches:830
Branch coverage:25.4% (211 of 830)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
DeleteFromTaskWithHttpMessagesAsync()-0%0%
GetFromTaskWithHttpMessagesAsync()-56.08%57.29%
GetPropertiesFromTaskWithHttpMessagesAsync()-55.8%56.82%
DeleteFromComputeNodeWithHttpMessagesAsync()-0%0%
GetFromComputeNodeWithHttpMessagesAsync()-56.08%57.29%
GetPropertiesFromComputeNodeWithHttpMessagesAsync()-55.8%56.82%
ListFromTaskWithHttpMessagesAsync()-0%0%
ListFromComputeNodeWithHttpMessagesAsync()-0%0%
ListFromTaskNextWithHttpMessagesAsync()-0%0%
ListFromComputeNodeNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\FileOperations.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    /// FileOperations operations.
 29    /// </summary>
 30    internal partial class FileOperations : IServiceOperations<BatchServiceClient>, IFileOperations
 31    {
 32        /// <summary>
 33        /// Initializes a new instance of the FileOperations 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 FileOperations(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>
 20053        public BatchServiceClient Client { get; private set; }
 54
 55        /// <summary>
 56        /// Deletes the specified Task file from the Compute Node where the Task ran.
 57        /// </summary>
 58        /// <param name='jobId'>
 59        /// The ID of the Job that contains the Task.
 60        /// </param>
 61        /// <param name='taskId'>
 62        /// The ID of the Task whose file you want to delete.
 63        /// </param>
 64        /// <param name='filePath'>
 65        /// The path to the Task file or directory that you want to delete.
 66        /// </param>
 67        /// <param name='recursive'>
 68        /// Whether to delete children of a directory. If the filePath parameter
 69        /// represents a directory instead of a file, you can set recursive to true to
 70        /// delete the directory and all of the files and subdirectories in it. If
 71        /// recursive is false then the directory must be empty or deletion will fail.
 72        /// </param>
 73        /// <param name='fileDeleteFromTaskOptions'>
 74        /// Additional parameters for the operation
 75        /// </param>
 76        /// <param name='customHeaders'>
 77        /// Headers that will be added to request.
 78        /// </param>
 79        /// <param name='cancellationToken'>
 80        /// The cancellation token.
 81        /// </param>
 82        /// <exception cref="BatchErrorException">
 83        /// Thrown when the operation returned an invalid status code
 84        /// </exception>
 85        /// <exception cref="ValidationException">
 86        /// Thrown when a required parameter is null
 87        /// </exception>
 88        /// <exception cref="System.ArgumentNullException">
 89        /// Thrown when a required parameter is null
 90        /// </exception>
 91        /// <return>
 92        /// A response object containing the response body and response headers.
 93        /// </return>
 94        public async Task<AzureOperationHeaderResponse<FileDeleteFromTaskHeaders>> DeleteFromTaskWithHttpMessagesAsync(s
 95        {
 096            if (Client.BatchUrl == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 99            }
 0100            if (jobId == null)
 101            {
 0102                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 103            }
 0104            if (taskId == null)
 105            {
 0106                throw new ValidationException(ValidationRules.CannotBeNull, "taskId");
 107            }
 0108            if (filePath == null)
 109            {
 0110                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 111            }
 0112            if (Client.ApiVersion == null)
 113            {
 0114                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 115            }
 0116            int? timeout = default(int?);
 0117            if (fileDeleteFromTaskOptions != null)
 118            {
 0119                timeout = fileDeleteFromTaskOptions.Timeout;
 120            }
 0121            System.Guid? clientRequestId = default(System.Guid?);
 0122            if (fileDeleteFromTaskOptions != null)
 123            {
 0124                clientRequestId = fileDeleteFromTaskOptions.ClientRequestId;
 125            }
 0126            bool? returnClientRequestId = default(bool?);
 0127            if (fileDeleteFromTaskOptions != null)
 128            {
 0129                returnClientRequestId = fileDeleteFromTaskOptions.ReturnClientRequestId;
 130            }
 0131            System.DateTime? ocpDate = default(System.DateTime?);
 0132            if (fileDeleteFromTaskOptions != null)
 133            {
 0134                ocpDate = fileDeleteFromTaskOptions.OcpDate;
 135            }
 136            // Tracing
 0137            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0138            string _invocationId = null;
 0139            if (_shouldTrace)
 140            {
 0141                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0142                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0143                tracingParameters.Add("jobId", jobId);
 0144                tracingParameters.Add("taskId", taskId);
 0145                tracingParameters.Add("filePath", filePath);
 0146                tracingParameters.Add("recursive", recursive);
 0147                tracingParameters.Add("timeout", timeout);
 0148                tracingParameters.Add("clientRequestId", clientRequestId);
 0149                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0150                tracingParameters.Add("ocpDate", ocpDate);
 0151                tracingParameters.Add("cancellationToken", cancellationToken);
 0152                ServiceClientTracing.Enter(_invocationId, this, "DeleteFromTask", tracingParameters);
 153            }
 154            // Construct URL
 0155            var _baseUrl = Client.BaseUri;
 0156            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/files/{filePath}";
 0157            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0158            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 0159            _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId));
 0160            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 0161            List<string> _queryParameters = new List<string>();
 0162            if (recursive != null)
 163            {
 0164                _queryParameters.Add(string.Format("recursive={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 165            }
 0166            if (Client.ApiVersion != null)
 167            {
 0168                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 169            }
 0170            if (timeout != null)
 171            {
 0172                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 173            }
 0174            if (_queryParameters.Count > 0)
 175            {
 0176                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 177            }
 178            // Create HTTP transport objects
 0179            var _httpRequest = new HttpRequestMessage();
 0180            HttpResponseMessage _httpResponse = null;
 0181            _httpRequest.Method = new HttpMethod("DELETE");
 0182            _httpRequest.RequestUri = new System.Uri(_url);
 183            // Set Headers
 0184            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 185            {
 0186                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 187            }
 0188            if (Client.AcceptLanguage != null)
 189            {
 0190                if (_httpRequest.Headers.Contains("accept-language"))
 191                {
 0192                    _httpRequest.Headers.Remove("accept-language");
 193                }
 0194                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 195            }
 0196            if (clientRequestId != null)
 197            {
 0198                if (_httpRequest.Headers.Contains("client-request-id"))
 199                {
 0200                    _httpRequest.Headers.Remove("client-request-id");
 201                }
 0202                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 203            }
 0204            if (returnClientRequestId != null)
 205            {
 0206                if (_httpRequest.Headers.Contains("return-client-request-id"))
 207                {
 0208                    _httpRequest.Headers.Remove("return-client-request-id");
 209                }
 0210                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 211            }
 0212            if (ocpDate != null)
 213            {
 0214                if (_httpRequest.Headers.Contains("ocp-date"))
 215                {
 0216                    _httpRequest.Headers.Remove("ocp-date");
 217                }
 0218                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 219            }
 220
 221
 0222            if (customHeaders != null)
 223            {
 0224                foreach(var _header in customHeaders)
 225                {
 0226                    if (_httpRequest.Headers.Contains(_header.Key))
 227                    {
 0228                        _httpRequest.Headers.Remove(_header.Key);
 229                    }
 0230                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 231                }
 232            }
 233
 234            // Serialize Request
 0235            string _requestContent = null;
 236            // Set Credentials
 0237            if (Client.Credentials != null)
 238            {
 0239                cancellationToken.ThrowIfCancellationRequested();
 0240                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 241            }
 242            // Send Request
 0243            if (_shouldTrace)
 244            {
 0245                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 246            }
 0247            cancellationToken.ThrowIfCancellationRequested();
 0248            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0249            if (_shouldTrace)
 250            {
 0251                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 252            }
 0253            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0254            cancellationToken.ThrowIfCancellationRequested();
 0255            string _responseContent = null;
 0256            if ((int)_statusCode != 200)
 257            {
 0258                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 259                try
 260                {
 0261                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0262                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0263                    if (_errorBody != null)
 264                    {
 0265                        ex.Body = _errorBody;
 266                    }
 0267                }
 0268                catch (JsonException)
 269                {
 270                    // Ignore the exception
 0271                }
 0272                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0273                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0274                if (_shouldTrace)
 275                {
 0276                    ServiceClientTracing.Error(_invocationId, ex);
 277                }
 0278                _httpRequest.Dispose();
 0279                if (_httpResponse != null)
 280                {
 0281                    _httpResponse.Dispose();
 282                }
 0283                throw ex;
 284            }
 285            // Create Result
 0286            var _result = new AzureOperationHeaderResponse<FileDeleteFromTaskHeaders>();
 0287            _result.Request = _httpRequest;
 0288            _result.Response = _httpResponse;
 0289            if (_httpResponse.Headers.Contains("request-id"))
 290            {
 0291                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 292            }
 293            try
 294            {
 0295                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileDeleteFromTaskHeaders>(JsonSerializer.Cr
 0296            }
 0297            catch (JsonException ex)
 298            {
 0299                _httpRequest.Dispose();
 0300                if (_httpResponse != null)
 301                {
 0302                    _httpResponse.Dispose();
 303                }
 0304                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 305            }
 0306            if (_shouldTrace)
 307            {
 0308                ServiceClientTracing.Exit(_invocationId, _result);
 309            }
 0310            return _result;
 0311        }
 312
 313        /// <summary>
 314        /// Returns the content of the specified Task file.
 315        /// </summary>
 316        /// <param name='jobId'>
 317        /// The ID of the Job that contains the Task.
 318        /// </param>
 319        /// <param name='taskId'>
 320        /// The ID of the Task whose file you want to retrieve.
 321        /// </param>
 322        /// <param name='filePath'>
 323        /// The path to the Task file that you want to get the content of.
 324        /// </param>
 325        /// <param name='fileGetFromTaskOptions'>
 326        /// Additional parameters for the operation
 327        /// </param>
 328        /// <param name='customHeaders'>
 329        /// Headers that will be added to request.
 330        /// </param>
 331        /// <param name='cancellationToken'>
 332        /// The cancellation token.
 333        /// </param>
 334        /// <exception cref="BatchErrorException">
 335        /// Thrown when the operation returned an invalid status code
 336        /// </exception>
 337        /// <exception cref="SerializationException">
 338        /// Thrown when unable to deserialize the response
 339        /// </exception>
 340        /// <exception cref="ValidationException">
 341        /// Thrown when a required parameter is null
 342        /// </exception>
 343        /// <exception cref="System.ArgumentNullException">
 344        /// Thrown when a required parameter is null
 345        /// </exception>
 346        /// <return>
 347        /// A response object containing the response body and response headers.
 348        /// </return>
 349        public async Task<AzureOperationResponse<Stream,FileGetFromTaskHeaders>> GetFromTaskWithHttpMessagesAsync(string
 350        {
 1351            if (Client.BatchUrl == null)
 352            {
 0353                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 354            }
 1355            if (jobId == null)
 356            {
 0357                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 358            }
 1359            if (taskId == null)
 360            {
 0361                throw new ValidationException(ValidationRules.CannotBeNull, "taskId");
 362            }
 1363            if (filePath == null)
 364            {
 0365                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 366            }
 1367            if (Client.ApiVersion == null)
 368            {
 0369                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 370            }
 1371            int? timeout = default(int?);
 1372            if (fileGetFromTaskOptions != null)
 373            {
 1374                timeout = fileGetFromTaskOptions.Timeout;
 375            }
 1376            System.Guid? clientRequestId = default(System.Guid?);
 1377            if (fileGetFromTaskOptions != null)
 378            {
 1379                clientRequestId = fileGetFromTaskOptions.ClientRequestId;
 380            }
 1381            bool? returnClientRequestId = default(bool?);
 1382            if (fileGetFromTaskOptions != null)
 383            {
 1384                returnClientRequestId = fileGetFromTaskOptions.ReturnClientRequestId;
 385            }
 1386            System.DateTime? ocpDate = default(System.DateTime?);
 1387            if (fileGetFromTaskOptions != null)
 388            {
 1389                ocpDate = fileGetFromTaskOptions.OcpDate;
 390            }
 1391            string ocpRange = default(string);
 1392            if (fileGetFromTaskOptions != null)
 393            {
 1394                ocpRange = fileGetFromTaskOptions.OcpRange;
 395            }
 1396            System.DateTime? ifModifiedSince = default(System.DateTime?);
 1397            if (fileGetFromTaskOptions != null)
 398            {
 1399                ifModifiedSince = fileGetFromTaskOptions.IfModifiedSince;
 400            }
 1401            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 1402            if (fileGetFromTaskOptions != null)
 403            {
 1404                ifUnmodifiedSince = fileGetFromTaskOptions.IfUnmodifiedSince;
 405            }
 406            // Tracing
 1407            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1408            string _invocationId = null;
 1409            if (_shouldTrace)
 410            {
 0411                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0412                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0413                tracingParameters.Add("jobId", jobId);
 0414                tracingParameters.Add("taskId", taskId);
 0415                tracingParameters.Add("filePath", filePath);
 0416                tracingParameters.Add("timeout", timeout);
 0417                tracingParameters.Add("clientRequestId", clientRequestId);
 0418                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0419                tracingParameters.Add("ocpDate", ocpDate);
 0420                tracingParameters.Add("ocpRange", ocpRange);
 0421                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0422                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0423                tracingParameters.Add("cancellationToken", cancellationToken);
 0424                ServiceClientTracing.Enter(_invocationId, this, "GetFromTask", tracingParameters);
 425            }
 426            // Construct URL
 1427            var _baseUrl = Client.BaseUri;
 1428            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/files/{filePath}";
 1429            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 1430            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 1431            _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId));
 1432            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 1433            List<string> _queryParameters = new List<string>();
 1434            if (Client.ApiVersion != null)
 435            {
 1436                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 437            }
 1438            if (timeout != null)
 439            {
 0440                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 441            }
 1442            if (_queryParameters.Count > 0)
 443            {
 1444                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 445            }
 446            // Create HTTP transport objects
 1447            var _httpRequest = new HttpRequestMessage();
 1448            HttpResponseMessage _httpResponse = null;
 1449            _httpRequest.Method = new HttpMethod("GET");
 1450            _httpRequest.RequestUri = new System.Uri(_url);
 451            // Set Headers
 1452            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 453            {
 1454                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 455            }
 1456            if (Client.AcceptLanguage != null)
 457            {
 1458                if (_httpRequest.Headers.Contains("accept-language"))
 459                {
 0460                    _httpRequest.Headers.Remove("accept-language");
 461                }
 1462                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 463            }
 1464            if (clientRequestId != null)
 465            {
 1466                if (_httpRequest.Headers.Contains("client-request-id"))
 467                {
 1468                    _httpRequest.Headers.Remove("client-request-id");
 469                }
 1470                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 471            }
 1472            if (returnClientRequestId != null)
 473            {
 0474                if (_httpRequest.Headers.Contains("return-client-request-id"))
 475                {
 0476                    _httpRequest.Headers.Remove("return-client-request-id");
 477                }
 0478                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 479            }
 1480            if (ocpDate != null)
 481            {
 0482                if (_httpRequest.Headers.Contains("ocp-date"))
 483                {
 0484                    _httpRequest.Headers.Remove("ocp-date");
 485                }
 0486                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 487            }
 1488            if (ocpRange != null)
 489            {
 0490                if (_httpRequest.Headers.Contains("ocp-range"))
 491                {
 0492                    _httpRequest.Headers.Remove("ocp-range");
 493                }
 0494                _httpRequest.Headers.TryAddWithoutValidation("ocp-range", ocpRange);
 495            }
 1496            if (ifModifiedSince != null)
 497            {
 0498                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 499                {
 0500                    _httpRequest.Headers.Remove("If-Modified-Since");
 501                }
 0502                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 503            }
 1504            if (ifUnmodifiedSince != null)
 505            {
 0506                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 507                {
 0508                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 509                }
 0510                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 511            }
 512
 513
 1514            if (customHeaders != null)
 515            {
 0516                foreach(var _header in customHeaders)
 517                {
 0518                    if (_httpRequest.Headers.Contains(_header.Key))
 519                    {
 0520                        _httpRequest.Headers.Remove(_header.Key);
 521                    }
 0522                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 523                }
 524            }
 525
 526            // Serialize Request
 1527            string _requestContent = null;
 528            // Set Credentials
 1529            if (Client.Credentials != null)
 530            {
 1531                cancellationToken.ThrowIfCancellationRequested();
 1532                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 533            }
 534            // Send Request
 1535            if (_shouldTrace)
 536            {
 0537                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 538            }
 1539            cancellationToken.ThrowIfCancellationRequested();
 1540            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 1541            if (_shouldTrace)
 542            {
 0543                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 544            }
 1545            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1546            cancellationToken.ThrowIfCancellationRequested();
 1547            string _responseContent = null;
 1548            if ((int)_statusCode != 200)
 549            {
 0550                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 551                try
 552                {
 0553                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0554                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0555                    if (_errorBody != null)
 556                    {
 0557                        ex.Body = _errorBody;
 558                    }
 0559                }
 0560                catch (JsonException)
 561                {
 562                    // Ignore the exception
 0563                }
 0564                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0565                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0566                if (_shouldTrace)
 567                {
 0568                    ServiceClientTracing.Error(_invocationId, ex);
 569                }
 0570                _httpRequest.Dispose();
 0571                if (_httpResponse != null)
 572                {
 0573                    _httpResponse.Dispose();
 574                }
 0575                throw ex;
 576            }
 577            // Create Result
 1578            var _result = new AzureOperationResponse<Stream,FileGetFromTaskHeaders>();
 1579            _result.Request = _httpRequest;
 1580            _result.Response = _httpResponse;
 1581            if (_httpResponse.Headers.Contains("request-id"))
 582            {
 0583                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 584            }
 585            // Deserialize Response
 1586            if ((int)_statusCode == 200)
 587            {
 1588                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 589            }
 590            try
 591            {
 1592                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileGetFromTaskHeaders>(JsonSerializer.Creat
 1593            }
 0594            catch (JsonException ex)
 595            {
 0596                _httpRequest.Dispose();
 0597                if (_httpResponse != null)
 598                {
 0599                    _httpResponse.Dispose();
 600                }
 0601                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 602            }
 1603            if (_shouldTrace)
 604            {
 0605                ServiceClientTracing.Exit(_invocationId, _result);
 606            }
 1607            return _result;
 1608        }
 609
 610        /// <summary>
 611        /// Gets the properties of the specified Task file.
 612        /// </summary>
 613        /// <param name='jobId'>
 614        /// The ID of the Job that contains the Task.
 615        /// </param>
 616        /// <param name='taskId'>
 617        /// The ID of the Task whose file you want to get the properties of.
 618        /// </param>
 619        /// <param name='filePath'>
 620        /// The path to the Task file that you want to get the properties of.
 621        /// </param>
 622        /// <param name='fileGetPropertiesFromTaskOptions'>
 623        /// Additional parameters for the operation
 624        /// </param>
 625        /// <param name='customHeaders'>
 626        /// Headers that will be added to request.
 627        /// </param>
 628        /// <param name='cancellationToken'>
 629        /// The cancellation token.
 630        /// </param>
 631        /// <exception cref="BatchErrorException">
 632        /// Thrown when the operation returned an invalid status code
 633        /// </exception>
 634        /// <exception cref="ValidationException">
 635        /// Thrown when a required parameter is null
 636        /// </exception>
 637        /// <exception cref="System.ArgumentNullException">
 638        /// Thrown when a required parameter is null
 639        /// </exception>
 640        /// <return>
 641        /// A response object containing the response body and response headers.
 642        /// </return>
 643        public async Task<AzureOperationHeaderResponse<FileGetPropertiesFromTaskHeaders>> GetPropertiesFromTaskWithHttpM
 644        {
 1645            if (Client.BatchUrl == null)
 646            {
 0647                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 648            }
 1649            if (jobId == null)
 650            {
 0651                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 652            }
 1653            if (taskId == null)
 654            {
 0655                throw new ValidationException(ValidationRules.CannotBeNull, "taskId");
 656            }
 1657            if (filePath == null)
 658            {
 0659                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 660            }
 1661            if (Client.ApiVersion == null)
 662            {
 0663                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 664            }
 1665            int? timeout = default(int?);
 1666            if (fileGetPropertiesFromTaskOptions != null)
 667            {
 1668                timeout = fileGetPropertiesFromTaskOptions.Timeout;
 669            }
 1670            System.Guid? clientRequestId = default(System.Guid?);
 1671            if (fileGetPropertiesFromTaskOptions != null)
 672            {
 1673                clientRequestId = fileGetPropertiesFromTaskOptions.ClientRequestId;
 674            }
 1675            bool? returnClientRequestId = default(bool?);
 1676            if (fileGetPropertiesFromTaskOptions != null)
 677            {
 1678                returnClientRequestId = fileGetPropertiesFromTaskOptions.ReturnClientRequestId;
 679            }
 1680            System.DateTime? ocpDate = default(System.DateTime?);
 1681            if (fileGetPropertiesFromTaskOptions != null)
 682            {
 1683                ocpDate = fileGetPropertiesFromTaskOptions.OcpDate;
 684            }
 1685            System.DateTime? ifModifiedSince = default(System.DateTime?);
 1686            if (fileGetPropertiesFromTaskOptions != null)
 687            {
 1688                ifModifiedSince = fileGetPropertiesFromTaskOptions.IfModifiedSince;
 689            }
 1690            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 1691            if (fileGetPropertiesFromTaskOptions != null)
 692            {
 1693                ifUnmodifiedSince = fileGetPropertiesFromTaskOptions.IfUnmodifiedSince;
 694            }
 695            // Tracing
 1696            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1697            string _invocationId = null;
 1698            if (_shouldTrace)
 699            {
 0700                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0701                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0702                tracingParameters.Add("jobId", jobId);
 0703                tracingParameters.Add("taskId", taskId);
 0704                tracingParameters.Add("filePath", filePath);
 0705                tracingParameters.Add("timeout", timeout);
 0706                tracingParameters.Add("clientRequestId", clientRequestId);
 0707                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0708                tracingParameters.Add("ocpDate", ocpDate);
 0709                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0710                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0711                tracingParameters.Add("cancellationToken", cancellationToken);
 0712                ServiceClientTracing.Enter(_invocationId, this, "GetPropertiesFromTask", tracingParameters);
 713            }
 714            // Construct URL
 1715            var _baseUrl = Client.BaseUri;
 1716            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/files/{filePath}";
 1717            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 1718            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 1719            _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId));
 1720            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 1721            List<string> _queryParameters = new List<string>();
 1722            if (Client.ApiVersion != null)
 723            {
 1724                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 725            }
 1726            if (timeout != null)
 727            {
 0728                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 729            }
 1730            if (_queryParameters.Count > 0)
 731            {
 1732                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 733            }
 734            // Create HTTP transport objects
 1735            var _httpRequest = new HttpRequestMessage();
 1736            HttpResponseMessage _httpResponse = null;
 1737            _httpRequest.Method = new HttpMethod("HEAD");
 1738            _httpRequest.RequestUri = new System.Uri(_url);
 739            // Set Headers
 1740            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 741            {
 1742                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 743            }
 1744            if (Client.AcceptLanguage != null)
 745            {
 1746                if (_httpRequest.Headers.Contains("accept-language"))
 747                {
 0748                    _httpRequest.Headers.Remove("accept-language");
 749                }
 1750                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 751            }
 1752            if (clientRequestId != null)
 753            {
 1754                if (_httpRequest.Headers.Contains("client-request-id"))
 755                {
 1756                    _httpRequest.Headers.Remove("client-request-id");
 757                }
 1758                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 759            }
 1760            if (returnClientRequestId != null)
 761            {
 0762                if (_httpRequest.Headers.Contains("return-client-request-id"))
 763                {
 0764                    _httpRequest.Headers.Remove("return-client-request-id");
 765                }
 0766                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 767            }
 1768            if (ocpDate != null)
 769            {
 0770                if (_httpRequest.Headers.Contains("ocp-date"))
 771                {
 0772                    _httpRequest.Headers.Remove("ocp-date");
 773                }
 0774                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 775            }
 1776            if (ifModifiedSince != null)
 777            {
 0778                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 779                {
 0780                    _httpRequest.Headers.Remove("If-Modified-Since");
 781                }
 0782                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 783            }
 1784            if (ifUnmodifiedSince != null)
 785            {
 0786                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 787                {
 0788                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 789                }
 0790                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 791            }
 792
 793
 1794            if (customHeaders != null)
 795            {
 0796                foreach(var _header in customHeaders)
 797                {
 0798                    if (_httpRequest.Headers.Contains(_header.Key))
 799                    {
 0800                        _httpRequest.Headers.Remove(_header.Key);
 801                    }
 0802                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 803                }
 804            }
 805
 806            // Serialize Request
 1807            string _requestContent = null;
 808            // Set Credentials
 1809            if (Client.Credentials != null)
 810            {
 1811                cancellationToken.ThrowIfCancellationRequested();
 1812                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 813            }
 814            // Send Request
 1815            if (_shouldTrace)
 816            {
 0817                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 818            }
 1819            cancellationToken.ThrowIfCancellationRequested();
 1820            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 1821            if (_shouldTrace)
 822            {
 0823                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 824            }
 1825            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1826            cancellationToken.ThrowIfCancellationRequested();
 1827            string _responseContent = null;
 1828            if ((int)_statusCode != 200)
 829            {
 0830                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 831                try
 832                {
 0833                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0834                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0835                    if (_errorBody != null)
 836                    {
 0837                        ex.Body = _errorBody;
 838                    }
 0839                }
 0840                catch (JsonException)
 841                {
 842                    // Ignore the exception
 0843                }
 0844                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0845                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0846                if (_shouldTrace)
 847                {
 0848                    ServiceClientTracing.Error(_invocationId, ex);
 849                }
 0850                _httpRequest.Dispose();
 0851                if (_httpResponse != null)
 852                {
 0853                    _httpResponse.Dispose();
 854                }
 0855                throw ex;
 856            }
 857            // Create Result
 1858            var _result = new AzureOperationHeaderResponse<FileGetPropertiesFromTaskHeaders>();
 1859            _result.Request = _httpRequest;
 1860            _result.Response = _httpResponse;
 1861            if (_httpResponse.Headers.Contains("request-id"))
 862            {
 0863                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 864            }
 865            try
 866            {
 1867                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileGetPropertiesFromTaskHeaders>(JsonSerial
 1868            }
 0869            catch (JsonException ex)
 870            {
 0871                _httpRequest.Dispose();
 0872                if (_httpResponse != null)
 873                {
 0874                    _httpResponse.Dispose();
 875                }
 0876                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 877            }
 1878            if (_shouldTrace)
 879            {
 0880                ServiceClientTracing.Exit(_invocationId, _result);
 881            }
 1882            return _result;
 1883        }
 884
 885        /// <summary>
 886        /// Deletes the specified file from the Compute Node.
 887        /// </summary>
 888        /// <param name='poolId'>
 889        /// The ID of the Pool that contains the Compute Node.
 890        /// </param>
 891        /// <param name='nodeId'>
 892        /// The ID of the Compute Node from which you want to delete the file.
 893        /// </param>
 894        /// <param name='filePath'>
 895        /// The path to the file or directory that you want to delete.
 896        /// </param>
 897        /// <param name='recursive'>
 898        /// Whether to delete children of a directory. If the filePath parameter
 899        /// represents a directory instead of a file, you can set recursive to true to
 900        /// delete the directory and all of the files and subdirectories in it. If
 901        /// recursive is false then the directory must be empty or deletion will fail.
 902        /// </param>
 903        /// <param name='fileDeleteFromComputeNodeOptions'>
 904        /// Additional parameters for the operation
 905        /// </param>
 906        /// <param name='customHeaders'>
 907        /// Headers that will be added to request.
 908        /// </param>
 909        /// <param name='cancellationToken'>
 910        /// The cancellation token.
 911        /// </param>
 912        /// <exception cref="BatchErrorException">
 913        /// Thrown when the operation returned an invalid status code
 914        /// </exception>
 915        /// <exception cref="ValidationException">
 916        /// Thrown when a required parameter is null
 917        /// </exception>
 918        /// <exception cref="System.ArgumentNullException">
 919        /// Thrown when a required parameter is null
 920        /// </exception>
 921        /// <return>
 922        /// A response object containing the response body and response headers.
 923        /// </return>
 924        public async Task<AzureOperationHeaderResponse<FileDeleteFromComputeNodeHeaders>> DeleteFromComputeNodeWithHttpM
 925        {
 0926            if (Client.BatchUrl == null)
 927            {
 0928                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 929            }
 0930            if (poolId == null)
 931            {
 0932                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 933            }
 0934            if (nodeId == null)
 935            {
 0936                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 937            }
 0938            if (filePath == null)
 939            {
 0940                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 941            }
 0942            if (Client.ApiVersion == null)
 943            {
 0944                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 945            }
 0946            int? timeout = default(int?);
 0947            if (fileDeleteFromComputeNodeOptions != null)
 948            {
 0949                timeout = fileDeleteFromComputeNodeOptions.Timeout;
 950            }
 0951            System.Guid? clientRequestId = default(System.Guid?);
 0952            if (fileDeleteFromComputeNodeOptions != null)
 953            {
 0954                clientRequestId = fileDeleteFromComputeNodeOptions.ClientRequestId;
 955            }
 0956            bool? returnClientRequestId = default(bool?);
 0957            if (fileDeleteFromComputeNodeOptions != null)
 958            {
 0959                returnClientRequestId = fileDeleteFromComputeNodeOptions.ReturnClientRequestId;
 960            }
 0961            System.DateTime? ocpDate = default(System.DateTime?);
 0962            if (fileDeleteFromComputeNodeOptions != null)
 963            {
 0964                ocpDate = fileDeleteFromComputeNodeOptions.OcpDate;
 965            }
 966            // Tracing
 0967            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0968            string _invocationId = null;
 0969            if (_shouldTrace)
 970            {
 0971                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0972                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0973                tracingParameters.Add("poolId", poolId);
 0974                tracingParameters.Add("nodeId", nodeId);
 0975                tracingParameters.Add("filePath", filePath);
 0976                tracingParameters.Add("recursive", recursive);
 0977                tracingParameters.Add("timeout", timeout);
 0978                tracingParameters.Add("clientRequestId", clientRequestId);
 0979                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0980                tracingParameters.Add("ocpDate", ocpDate);
 0981                tracingParameters.Add("cancellationToken", cancellationToken);
 0982                ServiceClientTracing.Enter(_invocationId, this, "DeleteFromComputeNode", tracingParameters);
 983            }
 984            // Construct URL
 0985            var _baseUrl = Client.BaseUri;
 0986            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/files/{filePath}"
 0987            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0988            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 0989            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 0990            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 0991            List<string> _queryParameters = new List<string>();
 0992            if (recursive != null)
 993            {
 0994                _queryParameters.Add(string.Format("recursive={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 995            }
 0996            if (Client.ApiVersion != null)
 997            {
 0998                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 999            }
 01000            if (timeout != null)
 1001            {
 01002                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1003            }
 01004            if (_queryParameters.Count > 0)
 1005            {
 01006                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1007            }
 1008            // Create HTTP transport objects
 01009            var _httpRequest = new HttpRequestMessage();
 01010            HttpResponseMessage _httpResponse = null;
 01011            _httpRequest.Method = new HttpMethod("DELETE");
 01012            _httpRequest.RequestUri = new System.Uri(_url);
 1013            // Set Headers
 01014            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1015            {
 01016                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1017            }
 01018            if (Client.AcceptLanguage != null)
 1019            {
 01020                if (_httpRequest.Headers.Contains("accept-language"))
 1021                {
 01022                    _httpRequest.Headers.Remove("accept-language");
 1023                }
 01024                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1025            }
 01026            if (clientRequestId != null)
 1027            {
 01028                if (_httpRequest.Headers.Contains("client-request-id"))
 1029                {
 01030                    _httpRequest.Headers.Remove("client-request-id");
 1031                }
 01032                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1033            }
 01034            if (returnClientRequestId != null)
 1035            {
 01036                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1037                {
 01038                    _httpRequest.Headers.Remove("return-client-request-id");
 1039                }
 01040                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1041            }
 01042            if (ocpDate != null)
 1043            {
 01044                if (_httpRequest.Headers.Contains("ocp-date"))
 1045                {
 01046                    _httpRequest.Headers.Remove("ocp-date");
 1047                }
 01048                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1049            }
 1050
 1051
 01052            if (customHeaders != null)
 1053            {
 01054                foreach(var _header in customHeaders)
 1055                {
 01056                    if (_httpRequest.Headers.Contains(_header.Key))
 1057                    {
 01058                        _httpRequest.Headers.Remove(_header.Key);
 1059                    }
 01060                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1061                }
 1062            }
 1063
 1064            // Serialize Request
 01065            string _requestContent = null;
 1066            // Set Credentials
 01067            if (Client.Credentials != null)
 1068            {
 01069                cancellationToken.ThrowIfCancellationRequested();
 01070                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1071            }
 1072            // Send Request
 01073            if (_shouldTrace)
 1074            {
 01075                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1076            }
 01077            cancellationToken.ThrowIfCancellationRequested();
 01078            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01079            if (_shouldTrace)
 1080            {
 01081                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1082            }
 01083            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01084            cancellationToken.ThrowIfCancellationRequested();
 01085            string _responseContent = null;
 01086            if ((int)_statusCode != 200)
 1087            {
 01088                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1089                try
 1090                {
 01091                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01092                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01093                    if (_errorBody != null)
 1094                    {
 01095                        ex.Body = _errorBody;
 1096                    }
 01097                }
 01098                catch (JsonException)
 1099                {
 1100                    // Ignore the exception
 01101                }
 01102                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01103                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01104                if (_shouldTrace)
 1105                {
 01106                    ServiceClientTracing.Error(_invocationId, ex);
 1107                }
 01108                _httpRequest.Dispose();
 01109                if (_httpResponse != null)
 1110                {
 01111                    _httpResponse.Dispose();
 1112                }
 01113                throw ex;
 1114            }
 1115            // Create Result
 01116            var _result = new AzureOperationHeaderResponse<FileDeleteFromComputeNodeHeaders>();
 01117            _result.Request = _httpRequest;
 01118            _result.Response = _httpResponse;
 01119            if (_httpResponse.Headers.Contains("request-id"))
 1120            {
 01121                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1122            }
 1123            try
 1124            {
 01125                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileDeleteFromComputeNodeHeaders>(JsonSerial
 01126            }
 01127            catch (JsonException ex)
 1128            {
 01129                _httpRequest.Dispose();
 01130                if (_httpResponse != null)
 1131                {
 01132                    _httpResponse.Dispose();
 1133                }
 01134                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1135            }
 01136            if (_shouldTrace)
 1137            {
 01138                ServiceClientTracing.Exit(_invocationId, _result);
 1139            }
 01140            return _result;
 01141        }
 1142
 1143        /// <summary>
 1144        /// Returns the content of the specified Compute Node file.
 1145        /// </summary>
 1146        /// <param name='poolId'>
 1147        /// The ID of the Pool that contains the Compute Node.
 1148        /// </param>
 1149        /// <param name='nodeId'>
 1150        /// The ID of the Compute Node that contains the file.
 1151        /// </param>
 1152        /// <param name='filePath'>
 1153        /// The path to the Compute Node file that you want to get the content of.
 1154        /// </param>
 1155        /// <param name='fileGetFromComputeNodeOptions'>
 1156        /// Additional parameters for the operation
 1157        /// </param>
 1158        /// <param name='customHeaders'>
 1159        /// Headers that will be added to request.
 1160        /// </param>
 1161        /// <param name='cancellationToken'>
 1162        /// The cancellation token.
 1163        /// </param>
 1164        /// <exception cref="BatchErrorException">
 1165        /// Thrown when the operation returned an invalid status code
 1166        /// </exception>
 1167        /// <exception cref="SerializationException">
 1168        /// Thrown when unable to deserialize the response
 1169        /// </exception>
 1170        /// <exception cref="ValidationException">
 1171        /// Thrown when a required parameter is null
 1172        /// </exception>
 1173        /// <exception cref="System.ArgumentNullException">
 1174        /// Thrown when a required parameter is null
 1175        /// </exception>
 1176        /// <return>
 1177        /// A response object containing the response body and response headers.
 1178        /// </return>
 1179        public async Task<AzureOperationResponse<Stream,FileGetFromComputeNodeHeaders>> GetFromComputeNodeWithHttpMessag
 1180        {
 11181            if (Client.BatchUrl == null)
 1182            {
 01183                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1184            }
 11185            if (poolId == null)
 1186            {
 01187                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1188            }
 11189            if (nodeId == null)
 1190            {
 01191                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1192            }
 11193            if (filePath == null)
 1194            {
 01195                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 1196            }
 11197            if (Client.ApiVersion == null)
 1198            {
 01199                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1200            }
 11201            int? timeout = default(int?);
 11202            if (fileGetFromComputeNodeOptions != null)
 1203            {
 11204                timeout = fileGetFromComputeNodeOptions.Timeout;
 1205            }
 11206            System.Guid? clientRequestId = default(System.Guid?);
 11207            if (fileGetFromComputeNodeOptions != null)
 1208            {
 11209                clientRequestId = fileGetFromComputeNodeOptions.ClientRequestId;
 1210            }
 11211            bool? returnClientRequestId = default(bool?);
 11212            if (fileGetFromComputeNodeOptions != null)
 1213            {
 11214                returnClientRequestId = fileGetFromComputeNodeOptions.ReturnClientRequestId;
 1215            }
 11216            System.DateTime? ocpDate = default(System.DateTime?);
 11217            if (fileGetFromComputeNodeOptions != null)
 1218            {
 11219                ocpDate = fileGetFromComputeNodeOptions.OcpDate;
 1220            }
 11221            string ocpRange = default(string);
 11222            if (fileGetFromComputeNodeOptions != null)
 1223            {
 11224                ocpRange = fileGetFromComputeNodeOptions.OcpRange;
 1225            }
 11226            System.DateTime? ifModifiedSince = default(System.DateTime?);
 11227            if (fileGetFromComputeNodeOptions != null)
 1228            {
 11229                ifModifiedSince = fileGetFromComputeNodeOptions.IfModifiedSince;
 1230            }
 11231            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 11232            if (fileGetFromComputeNodeOptions != null)
 1233            {
 11234                ifUnmodifiedSince = fileGetFromComputeNodeOptions.IfUnmodifiedSince;
 1235            }
 1236            // Tracing
 11237            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11238            string _invocationId = null;
 11239            if (_shouldTrace)
 1240            {
 01241                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01242                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01243                tracingParameters.Add("poolId", poolId);
 01244                tracingParameters.Add("nodeId", nodeId);
 01245                tracingParameters.Add("filePath", filePath);
 01246                tracingParameters.Add("timeout", timeout);
 01247                tracingParameters.Add("clientRequestId", clientRequestId);
 01248                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01249                tracingParameters.Add("ocpDate", ocpDate);
 01250                tracingParameters.Add("ocpRange", ocpRange);
 01251                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01252                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01253                tracingParameters.Add("cancellationToken", cancellationToken);
 01254                ServiceClientTracing.Enter(_invocationId, this, "GetFromComputeNode", tracingParameters);
 1255            }
 1256            // Construct URL
 11257            var _baseUrl = Client.BaseUri;
 11258            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/files/{filePath}"
 11259            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 11260            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 11261            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 11262            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 11263            List<string> _queryParameters = new List<string>();
 11264            if (Client.ApiVersion != null)
 1265            {
 11266                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1267            }
 11268            if (timeout != null)
 1269            {
 01270                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1271            }
 11272            if (_queryParameters.Count > 0)
 1273            {
 11274                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1275            }
 1276            // Create HTTP transport objects
 11277            var _httpRequest = new HttpRequestMessage();
 11278            HttpResponseMessage _httpResponse = null;
 11279            _httpRequest.Method = new HttpMethod("GET");
 11280            _httpRequest.RequestUri = new System.Uri(_url);
 1281            // Set Headers
 11282            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1283            {
 11284                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1285            }
 11286            if (Client.AcceptLanguage != null)
 1287            {
 11288                if (_httpRequest.Headers.Contains("accept-language"))
 1289                {
 01290                    _httpRequest.Headers.Remove("accept-language");
 1291                }
 11292                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1293            }
 11294            if (clientRequestId != null)
 1295            {
 11296                if (_httpRequest.Headers.Contains("client-request-id"))
 1297                {
 11298                    _httpRequest.Headers.Remove("client-request-id");
 1299                }
 11300                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1301            }
 11302            if (returnClientRequestId != null)
 1303            {
 01304                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1305                {
 01306                    _httpRequest.Headers.Remove("return-client-request-id");
 1307                }
 01308                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1309            }
 11310            if (ocpDate != null)
 1311            {
 01312                if (_httpRequest.Headers.Contains("ocp-date"))
 1313                {
 01314                    _httpRequest.Headers.Remove("ocp-date");
 1315                }
 01316                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1317            }
 11318            if (ocpRange != null)
 1319            {
 01320                if (_httpRequest.Headers.Contains("ocp-range"))
 1321                {
 01322                    _httpRequest.Headers.Remove("ocp-range");
 1323                }
 01324                _httpRequest.Headers.TryAddWithoutValidation("ocp-range", ocpRange);
 1325            }
 11326            if (ifModifiedSince != null)
 1327            {
 01328                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1329                {
 01330                    _httpRequest.Headers.Remove("If-Modified-Since");
 1331                }
 01332                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1333            }
 11334            if (ifUnmodifiedSince != null)
 1335            {
 01336                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1337                {
 01338                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1339                }
 01340                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1341            }
 1342
 1343
 11344            if (customHeaders != null)
 1345            {
 01346                foreach(var _header in customHeaders)
 1347                {
 01348                    if (_httpRequest.Headers.Contains(_header.Key))
 1349                    {
 01350                        _httpRequest.Headers.Remove(_header.Key);
 1351                    }
 01352                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1353                }
 1354            }
 1355
 1356            // Serialize Request
 11357            string _requestContent = null;
 1358            // Set Credentials
 11359            if (Client.Credentials != null)
 1360            {
 11361                cancellationToken.ThrowIfCancellationRequested();
 11362                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1363            }
 1364            // Send Request
 11365            if (_shouldTrace)
 1366            {
 01367                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1368            }
 11369            cancellationToken.ThrowIfCancellationRequested();
 11370            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 11371            if (_shouldTrace)
 1372            {
 01373                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1374            }
 11375            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11376            cancellationToken.ThrowIfCancellationRequested();
 11377            string _responseContent = null;
 11378            if ((int)_statusCode != 200)
 1379            {
 01380                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1381                try
 1382                {
 01383                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01384                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01385                    if (_errorBody != null)
 1386                    {
 01387                        ex.Body = _errorBody;
 1388                    }
 01389                }
 01390                catch (JsonException)
 1391                {
 1392                    // Ignore the exception
 01393                }
 01394                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01395                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01396                if (_shouldTrace)
 1397                {
 01398                    ServiceClientTracing.Error(_invocationId, ex);
 1399                }
 01400                _httpRequest.Dispose();
 01401                if (_httpResponse != null)
 1402                {
 01403                    _httpResponse.Dispose();
 1404                }
 01405                throw ex;
 1406            }
 1407            // Create Result
 11408            var _result = new AzureOperationResponse<Stream,FileGetFromComputeNodeHeaders>();
 11409            _result.Request = _httpRequest;
 11410            _result.Response = _httpResponse;
 11411            if (_httpResponse.Headers.Contains("request-id"))
 1412            {
 01413                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1414            }
 1415            // Deserialize Response
 11416            if ((int)_statusCode == 200)
 1417            {
 11418                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 1419            }
 1420            try
 1421            {
 11422                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileGetFromComputeNodeHeaders>(JsonSerialize
 11423            }
 01424            catch (JsonException ex)
 1425            {
 01426                _httpRequest.Dispose();
 01427                if (_httpResponse != null)
 1428                {
 01429                    _httpResponse.Dispose();
 1430                }
 01431                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1432            }
 11433            if (_shouldTrace)
 1434            {
 01435                ServiceClientTracing.Exit(_invocationId, _result);
 1436            }
 11437            return _result;
 11438        }
 1439
 1440        /// <summary>
 1441        /// Gets the properties of the specified Compute Node file.
 1442        /// </summary>
 1443        /// <param name='poolId'>
 1444        /// The ID of the Pool that contains the Compute Node.
 1445        /// </param>
 1446        /// <param name='nodeId'>
 1447        /// The ID of the Compute Node that contains the file.
 1448        /// </param>
 1449        /// <param name='filePath'>
 1450        /// The path to the Compute Node file that you want to get the properties of.
 1451        /// </param>
 1452        /// <param name='fileGetPropertiesFromComputeNodeOptions'>
 1453        /// Additional parameters for the operation
 1454        /// </param>
 1455        /// <param name='customHeaders'>
 1456        /// Headers that will be added to request.
 1457        /// </param>
 1458        /// <param name='cancellationToken'>
 1459        /// The cancellation token.
 1460        /// </param>
 1461        /// <exception cref="BatchErrorException">
 1462        /// Thrown when the operation returned an invalid status code
 1463        /// </exception>
 1464        /// <exception cref="ValidationException">
 1465        /// Thrown when a required parameter is null
 1466        /// </exception>
 1467        /// <exception cref="System.ArgumentNullException">
 1468        /// Thrown when a required parameter is null
 1469        /// </exception>
 1470        /// <return>
 1471        /// A response object containing the response body and response headers.
 1472        /// </return>
 1473        public async Task<AzureOperationHeaderResponse<FileGetPropertiesFromComputeNodeHeaders>> GetPropertiesFromComput
 1474        {
 11475            if (Client.BatchUrl == null)
 1476            {
 01477                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1478            }
 11479            if (poolId == null)
 1480            {
 01481                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 1482            }
 11483            if (nodeId == null)
 1484            {
 01485                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 1486            }
 11487            if (filePath == null)
 1488            {
 01489                throw new ValidationException(ValidationRules.CannotBeNull, "filePath");
 1490            }
 11491            if (Client.ApiVersion == null)
 1492            {
 01493                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1494            }
 11495            int? timeout = default(int?);
 11496            if (fileGetPropertiesFromComputeNodeOptions != null)
 1497            {
 11498                timeout = fileGetPropertiesFromComputeNodeOptions.Timeout;
 1499            }
 11500            System.Guid? clientRequestId = default(System.Guid?);
 11501            if (fileGetPropertiesFromComputeNodeOptions != null)
 1502            {
 11503                clientRequestId = fileGetPropertiesFromComputeNodeOptions.ClientRequestId;
 1504            }
 11505            bool? returnClientRequestId = default(bool?);
 11506            if (fileGetPropertiesFromComputeNodeOptions != null)
 1507            {
 11508                returnClientRequestId = fileGetPropertiesFromComputeNodeOptions.ReturnClientRequestId;
 1509            }
 11510            System.DateTime? ocpDate = default(System.DateTime?);
 11511            if (fileGetPropertiesFromComputeNodeOptions != null)
 1512            {
 11513                ocpDate = fileGetPropertiesFromComputeNodeOptions.OcpDate;
 1514            }
 11515            System.DateTime? ifModifiedSince = default(System.DateTime?);
 11516            if (fileGetPropertiesFromComputeNodeOptions != null)
 1517            {
 11518                ifModifiedSince = fileGetPropertiesFromComputeNodeOptions.IfModifiedSince;
 1519            }
 11520            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 11521            if (fileGetPropertiesFromComputeNodeOptions != null)
 1522            {
 11523                ifUnmodifiedSince = fileGetPropertiesFromComputeNodeOptions.IfUnmodifiedSince;
 1524            }
 1525            // Tracing
 11526            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11527            string _invocationId = null;
 11528            if (_shouldTrace)
 1529            {
 01530                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01531                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01532                tracingParameters.Add("poolId", poolId);
 01533                tracingParameters.Add("nodeId", nodeId);
 01534                tracingParameters.Add("filePath", filePath);
 01535                tracingParameters.Add("timeout", timeout);
 01536                tracingParameters.Add("clientRequestId", clientRequestId);
 01537                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01538                tracingParameters.Add("ocpDate", ocpDate);
 01539                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01540                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01541                tracingParameters.Add("cancellationToken", cancellationToken);
 01542                ServiceClientTracing.Enter(_invocationId, this, "GetPropertiesFromComputeNode", tracingParameters);
 1543            }
 1544            // Construct URL
 11545            var _baseUrl = Client.BaseUri;
 11546            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/files/{filePath}"
 11547            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 11548            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 11549            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 11550            _url = _url.Replace("{filePath}", System.Uri.EscapeDataString(filePath));
 11551            List<string> _queryParameters = new List<string>();
 11552            if (Client.ApiVersion != null)
 1553            {
 11554                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1555            }
 11556            if (timeout != null)
 1557            {
 01558                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1559            }
 11560            if (_queryParameters.Count > 0)
 1561            {
 11562                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1563            }
 1564            // Create HTTP transport objects
 11565            var _httpRequest = new HttpRequestMessage();
 11566            HttpResponseMessage _httpResponse = null;
 11567            _httpRequest.Method = new HttpMethod("HEAD");
 11568            _httpRequest.RequestUri = new System.Uri(_url);
 1569            // Set Headers
 11570            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1571            {
 11572                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1573            }
 11574            if (Client.AcceptLanguage != null)
 1575            {
 11576                if (_httpRequest.Headers.Contains("accept-language"))
 1577                {
 01578                    _httpRequest.Headers.Remove("accept-language");
 1579                }
 11580                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1581            }
 11582            if (clientRequestId != null)
 1583            {
 11584                if (_httpRequest.Headers.Contains("client-request-id"))
 1585                {
 11586                    _httpRequest.Headers.Remove("client-request-id");
 1587                }
 11588                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1589            }
 11590            if (returnClientRequestId != null)
 1591            {
 01592                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1593                {
 01594                    _httpRequest.Headers.Remove("return-client-request-id");
 1595                }
 01596                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1597            }
 11598            if (ocpDate != null)
 1599            {
 01600                if (_httpRequest.Headers.Contains("ocp-date"))
 1601                {
 01602                    _httpRequest.Headers.Remove("ocp-date");
 1603                }
 01604                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1605            }
 11606            if (ifModifiedSince != null)
 1607            {
 01608                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1609                {
 01610                    _httpRequest.Headers.Remove("If-Modified-Since");
 1611                }
 01612                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1613            }
 11614            if (ifUnmodifiedSince != null)
 1615            {
 01616                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1617                {
 01618                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1619                }
 01620                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1621            }
 1622
 1623
 11624            if (customHeaders != null)
 1625            {
 01626                foreach(var _header in customHeaders)
 1627                {
 01628                    if (_httpRequest.Headers.Contains(_header.Key))
 1629                    {
 01630                        _httpRequest.Headers.Remove(_header.Key);
 1631                    }
 01632                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1633                }
 1634            }
 1635
 1636            // Serialize Request
 11637            string _requestContent = null;
 1638            // Set Credentials
 11639            if (Client.Credentials != null)
 1640            {
 11641                cancellationToken.ThrowIfCancellationRequested();
 11642                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1643            }
 1644            // Send Request
 11645            if (_shouldTrace)
 1646            {
 01647                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1648            }
 11649            cancellationToken.ThrowIfCancellationRequested();
 11650            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 11651            if (_shouldTrace)
 1652            {
 01653                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1654            }
 11655            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11656            cancellationToken.ThrowIfCancellationRequested();
 11657            string _responseContent = null;
 11658            if ((int)_statusCode != 200)
 1659            {
 01660                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1661                try
 1662                {
 01663                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01664                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01665                    if (_errorBody != null)
 1666                    {
 01667                        ex.Body = _errorBody;
 1668                    }
 01669                }
 01670                catch (JsonException)
 1671                {
 1672                    // Ignore the exception
 01673                }
 01674                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01675                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01676                if (_shouldTrace)
 1677                {
 01678                    ServiceClientTracing.Error(_invocationId, ex);
 1679                }
 01680                _httpRequest.Dispose();
 01681                if (_httpResponse != null)
 1682                {
 01683                    _httpResponse.Dispose();
 1684                }
 01685                throw ex;
 1686            }
 1687            // Create Result
 11688            var _result = new AzureOperationHeaderResponse<FileGetPropertiesFromComputeNodeHeaders>();
 11689            _result.Request = _httpRequest;
 11690            _result.Response = _httpResponse;
 11691            if (_httpResponse.Headers.Contains("request-id"))
 1692            {
 01693                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1694            }
 1695            try
 1696            {
 11697                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileGetPropertiesFromComputeNodeHeaders>(Jso
 11698            }
 01699            catch (JsonException ex)
 1700            {
 01701                _httpRequest.Dispose();
 01702                if (_httpResponse != null)
 1703                {
 01704                    _httpResponse.Dispose();
 1705                }
 01706                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1707            }
 11708            if (_shouldTrace)
 1709            {
 01710                ServiceClientTracing.Exit(_invocationId, _result);
 1711            }
 11712            return _result;
 11713        }
 1714
 1715        /// <summary>
 1716        /// Lists the files in a Task's directory on its Compute Node.
 1717        /// </summary>
 1718        /// <param name='jobId'>
 1719        /// The ID of the Job that contains the Task.
 1720        /// </param>
 1721        /// <param name='taskId'>
 1722        /// The ID of the Task whose files you want to list.
 1723        /// </param>
 1724        /// <param name='recursive'>
 1725        /// Whether to list children of the Task directory. This parameter can be used
 1726        /// in combination with the filter parameter to list specific type of files.
 1727        /// </param>
 1728        /// <param name='fileListFromTaskOptions'>
 1729        /// Additional parameters for the operation
 1730        /// </param>
 1731        /// <param name='customHeaders'>
 1732        /// Headers that will be added to request.
 1733        /// </param>
 1734        /// <param name='cancellationToken'>
 1735        /// The cancellation token.
 1736        /// </param>
 1737        /// <exception cref="BatchErrorException">
 1738        /// Thrown when the operation returned an invalid status code
 1739        /// </exception>
 1740        /// <exception cref="SerializationException">
 1741        /// Thrown when unable to deserialize the response
 1742        /// </exception>
 1743        /// <exception cref="ValidationException">
 1744        /// Thrown when a required parameter is null
 1745        /// </exception>
 1746        /// <exception cref="System.ArgumentNullException">
 1747        /// Thrown when a required parameter is null
 1748        /// </exception>
 1749        /// <return>
 1750        /// A response object containing the response body and response headers.
 1751        /// </return>
 1752        public async Task<AzureOperationResponse<IPage<NodeFile>,FileListFromTaskHeaders>> ListFromTaskWithHttpMessagesA
 1753        {
 01754            if (Client.BatchUrl == null)
 1755            {
 01756                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1757            }
 01758            if (jobId == null)
 1759            {
 01760                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 1761            }
 01762            if (taskId == null)
 1763            {
 01764                throw new ValidationException(ValidationRules.CannotBeNull, "taskId");
 1765            }
 01766            if (Client.ApiVersion == null)
 1767            {
 01768                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1769            }
 01770            string filter = default(string);
 01771            if (fileListFromTaskOptions != null)
 1772            {
 01773                filter = fileListFromTaskOptions.Filter;
 1774            }
 01775            int? maxResults = default(int?);
 01776            if (fileListFromTaskOptions != null)
 1777            {
 01778                maxResults = fileListFromTaskOptions.MaxResults;
 1779            }
 01780            int? timeout = default(int?);
 01781            if (fileListFromTaskOptions != null)
 1782            {
 01783                timeout = fileListFromTaskOptions.Timeout;
 1784            }
 01785            System.Guid? clientRequestId = default(System.Guid?);
 01786            if (fileListFromTaskOptions != null)
 1787            {
 01788                clientRequestId = fileListFromTaskOptions.ClientRequestId;
 1789            }
 01790            bool? returnClientRequestId = default(bool?);
 01791            if (fileListFromTaskOptions != null)
 1792            {
 01793                returnClientRequestId = fileListFromTaskOptions.ReturnClientRequestId;
 1794            }
 01795            System.DateTime? ocpDate = default(System.DateTime?);
 01796            if (fileListFromTaskOptions != null)
 1797            {
 01798                ocpDate = fileListFromTaskOptions.OcpDate;
 1799            }
 1800            // Tracing
 01801            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01802            string _invocationId = null;
 01803            if (_shouldTrace)
 1804            {
 01805                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01806                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01807                tracingParameters.Add("jobId", jobId);
 01808                tracingParameters.Add("taskId", taskId);
 01809                tracingParameters.Add("recursive", recursive);
 01810                tracingParameters.Add("filter", filter);
 01811                tracingParameters.Add("maxResults", maxResults);
 01812                tracingParameters.Add("timeout", timeout);
 01813                tracingParameters.Add("clientRequestId", clientRequestId);
 01814                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01815                tracingParameters.Add("ocpDate", ocpDate);
 01816                tracingParameters.Add("cancellationToken", cancellationToken);
 01817                ServiceClientTracing.Enter(_invocationId, this, "ListFromTask", tracingParameters);
 1818            }
 1819            // Construct URL
 01820            var _baseUrl = Client.BaseUri;
 01821            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/files";
 01822            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01823            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 01824            _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId));
 01825            List<string> _queryParameters = new List<string>();
 01826            if (recursive != null)
 1827            {
 01828                _queryParameters.Add(string.Format("recursive={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 1829            }
 01830            if (Client.ApiVersion != null)
 1831            {
 01832                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1833            }
 01834            if (filter != null)
 1835            {
 01836                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 1837            }
 01838            if (maxResults != null)
 1839            {
 01840                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 1841            }
 01842            if (timeout != null)
 1843            {
 01844                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1845            }
 01846            if (_queryParameters.Count > 0)
 1847            {
 01848                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1849            }
 1850            // Create HTTP transport objects
 01851            var _httpRequest = new HttpRequestMessage();
 01852            HttpResponseMessage _httpResponse = null;
 01853            _httpRequest.Method = new HttpMethod("GET");
 01854            _httpRequest.RequestUri = new System.Uri(_url);
 1855            // Set Headers
 01856            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1857            {
 01858                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1859            }
 01860            if (Client.AcceptLanguage != null)
 1861            {
 01862                if (_httpRequest.Headers.Contains("accept-language"))
 1863                {
 01864                    _httpRequest.Headers.Remove("accept-language");
 1865                }
 01866                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1867            }
 01868            if (clientRequestId != null)
 1869            {
 01870                if (_httpRequest.Headers.Contains("client-request-id"))
 1871                {
 01872                    _httpRequest.Headers.Remove("client-request-id");
 1873                }
 01874                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1875            }
 01876            if (returnClientRequestId != null)
 1877            {
 01878                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1879                {
 01880                    _httpRequest.Headers.Remove("return-client-request-id");
 1881                }
 01882                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1883            }
 01884            if (ocpDate != null)
 1885            {
 01886                if (_httpRequest.Headers.Contains("ocp-date"))
 1887                {
 01888                    _httpRequest.Headers.Remove("ocp-date");
 1889                }
 01890                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1891            }
 1892
 1893
 01894            if (customHeaders != null)
 1895            {
 01896                foreach(var _header in customHeaders)
 1897                {
 01898                    if (_httpRequest.Headers.Contains(_header.Key))
 1899                    {
 01900                        _httpRequest.Headers.Remove(_header.Key);
 1901                    }
 01902                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1903                }
 1904            }
 1905
 1906            // Serialize Request
 01907            string _requestContent = null;
 1908            // Set Credentials
 01909            if (Client.Credentials != null)
 1910            {
 01911                cancellationToken.ThrowIfCancellationRequested();
 01912                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1913            }
 1914            // Send Request
 01915            if (_shouldTrace)
 1916            {
 01917                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1918            }
 01919            cancellationToken.ThrowIfCancellationRequested();
 01920            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01921            if (_shouldTrace)
 1922            {
 01923                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1924            }
 01925            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01926            cancellationToken.ThrowIfCancellationRequested();
 01927            string _responseContent = null;
 01928            if ((int)_statusCode != 200)
 1929            {
 01930                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1931                try
 1932                {
 01933                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01934                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01935                    if (_errorBody != null)
 1936                    {
 01937                        ex.Body = _errorBody;
 1938                    }
 01939                }
 01940                catch (JsonException)
 1941                {
 1942                    // Ignore the exception
 01943                }
 01944                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01945                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01946                if (_shouldTrace)
 1947                {
 01948                    ServiceClientTracing.Error(_invocationId, ex);
 1949                }
 01950                _httpRequest.Dispose();
 01951                if (_httpResponse != null)
 1952                {
 01953                    _httpResponse.Dispose();
 1954                }
 01955                throw ex;
 1956            }
 1957            // Create Result
 01958            var _result = new AzureOperationResponse<IPage<NodeFile>,FileListFromTaskHeaders>();
 01959            _result.Request = _httpRequest;
 01960            _result.Response = _httpResponse;
 01961            if (_httpResponse.Headers.Contains("request-id"))
 1962            {
 01963                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1964            }
 1965            // Deserialize Response
 01966            if ((int)_statusCode == 200)
 1967            {
 01968                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1969                try
 1970                {
 01971                    _result.Body = SafeJsonConvert.DeserializeObject<Page<NodeFile>>(_responseContent, Client.Deserializ
 01972                }
 01973                catch (JsonException ex)
 1974                {
 01975                    _httpRequest.Dispose();
 01976                    if (_httpResponse != null)
 1977                    {
 01978                        _httpResponse.Dispose();
 1979                    }
 01980                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1981                }
 1982            }
 1983            try
 1984            {
 01985                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileListFromTaskHeaders>(JsonSerializer.Crea
 01986            }
 01987            catch (JsonException ex)
 1988            {
 01989                _httpRequest.Dispose();
 01990                if (_httpResponse != null)
 1991                {
 01992                    _httpResponse.Dispose();
 1993                }
 01994                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1995            }
 01996            if (_shouldTrace)
 1997            {
 01998                ServiceClientTracing.Exit(_invocationId, _result);
 1999            }
 02000            return _result;
 02001        }
 2002
 2003        /// <summary>
 2004        /// Lists all of the files in Task directories on the specified Compute Node.
 2005        /// </summary>
 2006        /// <param name='poolId'>
 2007        /// The ID of the Pool that contains the Compute Node.
 2008        /// </param>
 2009        /// <param name='nodeId'>
 2010        /// The ID of the Compute Node whose files you want to list.
 2011        /// </param>
 2012        /// <param name='recursive'>
 2013        /// Whether to list children of a directory.
 2014        /// </param>
 2015        /// <param name='fileListFromComputeNodeOptions'>
 2016        /// Additional parameters for the operation
 2017        /// </param>
 2018        /// <param name='customHeaders'>
 2019        /// Headers that will be added to request.
 2020        /// </param>
 2021        /// <param name='cancellationToken'>
 2022        /// The cancellation token.
 2023        /// </param>
 2024        /// <exception cref="BatchErrorException">
 2025        /// Thrown when the operation returned an invalid status code
 2026        /// </exception>
 2027        /// <exception cref="SerializationException">
 2028        /// Thrown when unable to deserialize the response
 2029        /// </exception>
 2030        /// <exception cref="ValidationException">
 2031        /// Thrown when a required parameter is null
 2032        /// </exception>
 2033        /// <exception cref="System.ArgumentNullException">
 2034        /// Thrown when a required parameter is null
 2035        /// </exception>
 2036        /// <return>
 2037        /// A response object containing the response body and response headers.
 2038        /// </return>
 2039        public async Task<AzureOperationResponse<IPage<NodeFile>,FileListFromComputeNodeHeaders>> ListFromComputeNodeWit
 2040        {
 02041            if (Client.BatchUrl == null)
 2042            {
 02043                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2044            }
 02045            if (poolId == null)
 2046            {
 02047                throw new ValidationException(ValidationRules.CannotBeNull, "poolId");
 2048            }
 02049            if (nodeId == null)
 2050            {
 02051                throw new ValidationException(ValidationRules.CannotBeNull, "nodeId");
 2052            }
 02053            if (Client.ApiVersion == null)
 2054            {
 02055                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2056            }
 02057            string filter = default(string);
 02058            if (fileListFromComputeNodeOptions != null)
 2059            {
 02060                filter = fileListFromComputeNodeOptions.Filter;
 2061            }
 02062            int? maxResults = default(int?);
 02063            if (fileListFromComputeNodeOptions != null)
 2064            {
 02065                maxResults = fileListFromComputeNodeOptions.MaxResults;
 2066            }
 02067            int? timeout = default(int?);
 02068            if (fileListFromComputeNodeOptions != null)
 2069            {
 02070                timeout = fileListFromComputeNodeOptions.Timeout;
 2071            }
 02072            System.Guid? clientRequestId = default(System.Guid?);
 02073            if (fileListFromComputeNodeOptions != null)
 2074            {
 02075                clientRequestId = fileListFromComputeNodeOptions.ClientRequestId;
 2076            }
 02077            bool? returnClientRequestId = default(bool?);
 02078            if (fileListFromComputeNodeOptions != null)
 2079            {
 02080                returnClientRequestId = fileListFromComputeNodeOptions.ReturnClientRequestId;
 2081            }
 02082            System.DateTime? ocpDate = default(System.DateTime?);
 02083            if (fileListFromComputeNodeOptions != null)
 2084            {
 02085                ocpDate = fileListFromComputeNodeOptions.OcpDate;
 2086            }
 2087            // Tracing
 02088            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02089            string _invocationId = null;
 02090            if (_shouldTrace)
 2091            {
 02092                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02093                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02094                tracingParameters.Add("poolId", poolId);
 02095                tracingParameters.Add("nodeId", nodeId);
 02096                tracingParameters.Add("recursive", recursive);
 02097                tracingParameters.Add("filter", filter);
 02098                tracingParameters.Add("maxResults", maxResults);
 02099                tracingParameters.Add("timeout", timeout);
 02100                tracingParameters.Add("clientRequestId", clientRequestId);
 02101                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02102                tracingParameters.Add("ocpDate", ocpDate);
 02103                tracingParameters.Add("cancellationToken", cancellationToken);
 02104                ServiceClientTracing.Enter(_invocationId, this, "ListFromComputeNode", tracingParameters);
 2105            }
 2106            // Construct URL
 02107            var _baseUrl = Client.BaseUri;
 02108            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "pools/{poolId}/nodes/{nodeId}/files";
 02109            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02110            _url = _url.Replace("{poolId}", System.Uri.EscapeDataString(poolId));
 02111            _url = _url.Replace("{nodeId}", System.Uri.EscapeDataString(nodeId));
 02112            List<string> _queryParameters = new List<string>();
 02113            if (recursive != null)
 2114            {
 02115                _queryParameters.Add(string.Format("recursive={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 2116            }
 02117            if (Client.ApiVersion != null)
 2118            {
 02119                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2120            }
 02121            if (filter != null)
 2122            {
 02123                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 2124            }
 02125            if (maxResults != null)
 2126            {
 02127                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 2128            }
 02129            if (timeout != null)
 2130            {
 02131                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2132            }
 02133            if (_queryParameters.Count > 0)
 2134            {
 02135                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2136            }
 2137            // Create HTTP transport objects
 02138            var _httpRequest = new HttpRequestMessage();
 02139            HttpResponseMessage _httpResponse = null;
 02140            _httpRequest.Method = new HttpMethod("GET");
 02141            _httpRequest.RequestUri = new System.Uri(_url);
 2142            // Set Headers
 02143            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2144            {
 02145                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2146            }
 02147            if (Client.AcceptLanguage != null)
 2148            {
 02149                if (_httpRequest.Headers.Contains("accept-language"))
 2150                {
 02151                    _httpRequest.Headers.Remove("accept-language");
 2152                }
 02153                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2154            }
 02155            if (clientRequestId != null)
 2156            {
 02157                if (_httpRequest.Headers.Contains("client-request-id"))
 2158                {
 02159                    _httpRequest.Headers.Remove("client-request-id");
 2160                }
 02161                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2162            }
 02163            if (returnClientRequestId != null)
 2164            {
 02165                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2166                {
 02167                    _httpRequest.Headers.Remove("return-client-request-id");
 2168                }
 02169                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2170            }
 02171            if (ocpDate != null)
 2172            {
 02173                if (_httpRequest.Headers.Contains("ocp-date"))
 2174                {
 02175                    _httpRequest.Headers.Remove("ocp-date");
 2176                }
 02177                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2178            }
 2179
 2180
 02181            if (customHeaders != null)
 2182            {
 02183                foreach(var _header in customHeaders)
 2184                {
 02185                    if (_httpRequest.Headers.Contains(_header.Key))
 2186                    {
 02187                        _httpRequest.Headers.Remove(_header.Key);
 2188                    }
 02189                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2190                }
 2191            }
 2192
 2193            // Serialize Request
 02194            string _requestContent = null;
 2195            // Set Credentials
 02196            if (Client.Credentials != null)
 2197            {
 02198                cancellationToken.ThrowIfCancellationRequested();
 02199                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2200            }
 2201            // Send Request
 02202            if (_shouldTrace)
 2203            {
 02204                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2205            }
 02206            cancellationToken.ThrowIfCancellationRequested();
 02207            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02208            if (_shouldTrace)
 2209            {
 02210                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2211            }
 02212            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02213            cancellationToken.ThrowIfCancellationRequested();
 02214            string _responseContent = null;
 02215            if ((int)_statusCode != 200)
 2216            {
 02217                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2218                try
 2219                {
 02220                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02221                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02222                    if (_errorBody != null)
 2223                    {
 02224                        ex.Body = _errorBody;
 2225                    }
 02226                }
 02227                catch (JsonException)
 2228                {
 2229                    // Ignore the exception
 02230                }
 02231                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02232                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02233                if (_shouldTrace)
 2234                {
 02235                    ServiceClientTracing.Error(_invocationId, ex);
 2236                }
 02237                _httpRequest.Dispose();
 02238                if (_httpResponse != null)
 2239                {
 02240                    _httpResponse.Dispose();
 2241                }
 02242                throw ex;
 2243            }
 2244            // Create Result
 02245            var _result = new AzureOperationResponse<IPage<NodeFile>,FileListFromComputeNodeHeaders>();
 02246            _result.Request = _httpRequest;
 02247            _result.Response = _httpResponse;
 02248            if (_httpResponse.Headers.Contains("request-id"))
 2249            {
 02250                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2251            }
 2252            // Deserialize Response
 02253            if ((int)_statusCode == 200)
 2254            {
 02255                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2256                try
 2257                {
 02258                    _result.Body = SafeJsonConvert.DeserializeObject<Page<NodeFile>>(_responseContent, Client.Deserializ
 02259                }
 02260                catch (JsonException ex)
 2261                {
 02262                    _httpRequest.Dispose();
 02263                    if (_httpResponse != null)
 2264                    {
 02265                        _httpResponse.Dispose();
 2266                    }
 02267                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2268                }
 2269            }
 2270            try
 2271            {
 02272                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileListFromComputeNodeHeaders>(JsonSerializ
 02273            }
 02274            catch (JsonException ex)
 2275            {
 02276                _httpRequest.Dispose();
 02277                if (_httpResponse != null)
 2278                {
 02279                    _httpResponse.Dispose();
 2280                }
 02281                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2282            }
 02283            if (_shouldTrace)
 2284            {
 02285                ServiceClientTracing.Exit(_invocationId, _result);
 2286            }
 02287            return _result;
 02288        }
 2289
 2290        /// <summary>
 2291        /// Lists the files in a Task's directory on its Compute Node.
 2292        /// </summary>
 2293        /// <param name='nextPageLink'>
 2294        /// The NextLink from the previous successful call to List operation.
 2295        /// </param>
 2296        /// <param name='fileListFromTaskNextOptions'>
 2297        /// Additional parameters for the operation
 2298        /// </param>
 2299        /// <param name='customHeaders'>
 2300        /// Headers that will be added to request.
 2301        /// </param>
 2302        /// <param name='cancellationToken'>
 2303        /// The cancellation token.
 2304        /// </param>
 2305        /// <exception cref="BatchErrorException">
 2306        /// Thrown when the operation returned an invalid status code
 2307        /// </exception>
 2308        /// <exception cref="SerializationException">
 2309        /// Thrown when unable to deserialize the response
 2310        /// </exception>
 2311        /// <exception cref="ValidationException">
 2312        /// Thrown when a required parameter is null
 2313        /// </exception>
 2314        /// <exception cref="System.ArgumentNullException">
 2315        /// Thrown when a required parameter is null
 2316        /// </exception>
 2317        /// <return>
 2318        /// A response object containing the response body and response headers.
 2319        /// </return>
 2320        public async Task<AzureOperationResponse<IPage<NodeFile>,FileListFromTaskHeaders>> ListFromTaskNextWithHttpMessa
 2321        {
 02322            if (nextPageLink == null)
 2323            {
 02324                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 2325            }
 02326            System.Guid? clientRequestId = default(System.Guid?);
 02327            if (fileListFromTaskNextOptions != null)
 2328            {
 02329                clientRequestId = fileListFromTaskNextOptions.ClientRequestId;
 2330            }
 02331            bool? returnClientRequestId = default(bool?);
 02332            if (fileListFromTaskNextOptions != null)
 2333            {
 02334                returnClientRequestId = fileListFromTaskNextOptions.ReturnClientRequestId;
 2335            }
 02336            System.DateTime? ocpDate = default(System.DateTime?);
 02337            if (fileListFromTaskNextOptions != null)
 2338            {
 02339                ocpDate = fileListFromTaskNextOptions.OcpDate;
 2340            }
 2341            // Tracing
 02342            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02343            string _invocationId = null;
 02344            if (_shouldTrace)
 2345            {
 02346                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02347                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02348                tracingParameters.Add("nextPageLink", nextPageLink);
 02349                tracingParameters.Add("clientRequestId", clientRequestId);
 02350                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02351                tracingParameters.Add("ocpDate", ocpDate);
 02352                tracingParameters.Add("cancellationToken", cancellationToken);
 02353                ServiceClientTracing.Enter(_invocationId, this, "ListFromTaskNext", tracingParameters);
 2354            }
 2355            // Construct URL
 02356            string _url = "{nextLink}";
 02357            _url = _url.Replace("{nextLink}", nextPageLink);
 02358            List<string> _queryParameters = new List<string>();
 02359            if (_queryParameters.Count > 0)
 2360            {
 02361                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2362            }
 2363            // Create HTTP transport objects
 02364            var _httpRequest = new HttpRequestMessage();
 02365            HttpResponseMessage _httpResponse = null;
 02366            _httpRequest.Method = new HttpMethod("GET");
 02367            _httpRequest.RequestUri = new System.Uri(_url);
 2368            // Set Headers
 02369            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2370            {
 02371                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2372            }
 02373            if (Client.AcceptLanguage != null)
 2374            {
 02375                if (_httpRequest.Headers.Contains("accept-language"))
 2376                {
 02377                    _httpRequest.Headers.Remove("accept-language");
 2378                }
 02379                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2380            }
 02381            if (clientRequestId != null)
 2382            {
 02383                if (_httpRequest.Headers.Contains("client-request-id"))
 2384                {
 02385                    _httpRequest.Headers.Remove("client-request-id");
 2386                }
 02387                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2388            }
 02389            if (returnClientRequestId != null)
 2390            {
 02391                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2392                {
 02393                    _httpRequest.Headers.Remove("return-client-request-id");
 2394                }
 02395                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2396            }
 02397            if (ocpDate != null)
 2398            {
 02399                if (_httpRequest.Headers.Contains("ocp-date"))
 2400                {
 02401                    _httpRequest.Headers.Remove("ocp-date");
 2402                }
 02403                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2404            }
 2405
 2406
 02407            if (customHeaders != null)
 2408            {
 02409                foreach(var _header in customHeaders)
 2410                {
 02411                    if (_httpRequest.Headers.Contains(_header.Key))
 2412                    {
 02413                        _httpRequest.Headers.Remove(_header.Key);
 2414                    }
 02415                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2416                }
 2417            }
 2418
 2419            // Serialize Request
 02420            string _requestContent = null;
 2421            // Set Credentials
 02422            if (Client.Credentials != null)
 2423            {
 02424                cancellationToken.ThrowIfCancellationRequested();
 02425                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2426            }
 2427            // Send Request
 02428            if (_shouldTrace)
 2429            {
 02430                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2431            }
 02432            cancellationToken.ThrowIfCancellationRequested();
 02433            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02434            if (_shouldTrace)
 2435            {
 02436                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2437            }
 02438            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02439            cancellationToken.ThrowIfCancellationRequested();
 02440            string _responseContent = null;
 02441            if ((int)_statusCode != 200)
 2442            {
 02443                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2444                try
 2445                {
 02446                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02447                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02448                    if (_errorBody != null)
 2449                    {
 02450                        ex.Body = _errorBody;
 2451                    }
 02452                }
 02453                catch (JsonException)
 2454                {
 2455                    // Ignore the exception
 02456                }
 02457                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02458                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02459                if (_shouldTrace)
 2460                {
 02461                    ServiceClientTracing.Error(_invocationId, ex);
 2462                }
 02463                _httpRequest.Dispose();
 02464                if (_httpResponse != null)
 2465                {
 02466                    _httpResponse.Dispose();
 2467                }
 02468                throw ex;
 2469            }
 2470            // Create Result
 02471            var _result = new AzureOperationResponse<IPage<NodeFile>,FileListFromTaskHeaders>();
 02472            _result.Request = _httpRequest;
 02473            _result.Response = _httpResponse;
 02474            if (_httpResponse.Headers.Contains("request-id"))
 2475            {
 02476                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2477            }
 2478            // Deserialize Response
 02479            if ((int)_statusCode == 200)
 2480            {
 02481                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2482                try
 2483                {
 02484                    _result.Body = SafeJsonConvert.DeserializeObject<Page<NodeFile>>(_responseContent, Client.Deserializ
 02485                }
 02486                catch (JsonException ex)
 2487                {
 02488                    _httpRequest.Dispose();
 02489                    if (_httpResponse != null)
 2490                    {
 02491                        _httpResponse.Dispose();
 2492                    }
 02493                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2494                }
 2495            }
 2496            try
 2497            {
 02498                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileListFromTaskHeaders>(JsonSerializer.Crea
 02499            }
 02500            catch (JsonException ex)
 2501            {
 02502                _httpRequest.Dispose();
 02503                if (_httpResponse != null)
 2504                {
 02505                    _httpResponse.Dispose();
 2506                }
 02507                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2508            }
 02509            if (_shouldTrace)
 2510            {
 02511                ServiceClientTracing.Exit(_invocationId, _result);
 2512            }
 02513            return _result;
 02514        }
 2515
 2516        /// <summary>
 2517        /// Lists all of the files in Task directories on the specified Compute Node.
 2518        /// </summary>
 2519        /// <param name='nextPageLink'>
 2520        /// The NextLink from the previous successful call to List operation.
 2521        /// </param>
 2522        /// <param name='fileListFromComputeNodeNextOptions'>
 2523        /// Additional parameters for the operation
 2524        /// </param>
 2525        /// <param name='customHeaders'>
 2526        /// Headers that will be added to request.
 2527        /// </param>
 2528        /// <param name='cancellationToken'>
 2529        /// The cancellation token.
 2530        /// </param>
 2531        /// <exception cref="BatchErrorException">
 2532        /// Thrown when the operation returned an invalid status code
 2533        /// </exception>
 2534        /// <exception cref="SerializationException">
 2535        /// Thrown when unable to deserialize the response
 2536        /// </exception>
 2537        /// <exception cref="ValidationException">
 2538        /// Thrown when a required parameter is null
 2539        /// </exception>
 2540        /// <exception cref="System.ArgumentNullException">
 2541        /// Thrown when a required parameter is null
 2542        /// </exception>
 2543        /// <return>
 2544        /// A response object containing the response body and response headers.
 2545        /// </return>
 2546        public async Task<AzureOperationResponse<IPage<NodeFile>,FileListFromComputeNodeHeaders>> ListFromComputeNodeNex
 2547        {
 02548            if (nextPageLink == null)
 2549            {
 02550                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 2551            }
 02552            System.Guid? clientRequestId = default(System.Guid?);
 02553            if (fileListFromComputeNodeNextOptions != null)
 2554            {
 02555                clientRequestId = fileListFromComputeNodeNextOptions.ClientRequestId;
 2556            }
 02557            bool? returnClientRequestId = default(bool?);
 02558            if (fileListFromComputeNodeNextOptions != null)
 2559            {
 02560                returnClientRequestId = fileListFromComputeNodeNextOptions.ReturnClientRequestId;
 2561            }
 02562            System.DateTime? ocpDate = default(System.DateTime?);
 02563            if (fileListFromComputeNodeNextOptions != null)
 2564            {
 02565                ocpDate = fileListFromComputeNodeNextOptions.OcpDate;
 2566            }
 2567            // Tracing
 02568            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02569            string _invocationId = null;
 02570            if (_shouldTrace)
 2571            {
 02572                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02573                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02574                tracingParameters.Add("nextPageLink", nextPageLink);
 02575                tracingParameters.Add("clientRequestId", clientRequestId);
 02576                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02577                tracingParameters.Add("ocpDate", ocpDate);
 02578                tracingParameters.Add("cancellationToken", cancellationToken);
 02579                ServiceClientTracing.Enter(_invocationId, this, "ListFromComputeNodeNext", tracingParameters);
 2580            }
 2581            // Construct URL
 02582            string _url = "{nextLink}";
 02583            _url = _url.Replace("{nextLink}", nextPageLink);
 02584            List<string> _queryParameters = new List<string>();
 02585            if (_queryParameters.Count > 0)
 2586            {
 02587                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2588            }
 2589            // Create HTTP transport objects
 02590            var _httpRequest = new HttpRequestMessage();
 02591            HttpResponseMessage _httpResponse = null;
 02592            _httpRequest.Method = new HttpMethod("GET");
 02593            _httpRequest.RequestUri = new System.Uri(_url);
 2594            // Set Headers
 02595            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2596            {
 02597                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2598            }
 02599            if (Client.AcceptLanguage != null)
 2600            {
 02601                if (_httpRequest.Headers.Contains("accept-language"))
 2602                {
 02603                    _httpRequest.Headers.Remove("accept-language");
 2604                }
 02605                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2606            }
 02607            if (clientRequestId != null)
 2608            {
 02609                if (_httpRequest.Headers.Contains("client-request-id"))
 2610                {
 02611                    _httpRequest.Headers.Remove("client-request-id");
 2612                }
 02613                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2614            }
 02615            if (returnClientRequestId != null)
 2616            {
 02617                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2618                {
 02619                    _httpRequest.Headers.Remove("return-client-request-id");
 2620                }
 02621                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2622            }
 02623            if (ocpDate != null)
 2624            {
 02625                if (_httpRequest.Headers.Contains("ocp-date"))
 2626                {
 02627                    _httpRequest.Headers.Remove("ocp-date");
 2628                }
 02629                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2630            }
 2631
 2632
 02633            if (customHeaders != null)
 2634            {
 02635                foreach(var _header in customHeaders)
 2636                {
 02637                    if (_httpRequest.Headers.Contains(_header.Key))
 2638                    {
 02639                        _httpRequest.Headers.Remove(_header.Key);
 2640                    }
 02641                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2642                }
 2643            }
 2644
 2645            // Serialize Request
 02646            string _requestContent = null;
 2647            // Set Credentials
 02648            if (Client.Credentials != null)
 2649            {
 02650                cancellationToken.ThrowIfCancellationRequested();
 02651                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2652            }
 2653            // Send Request
 02654            if (_shouldTrace)
 2655            {
 02656                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2657            }
 02658            cancellationToken.ThrowIfCancellationRequested();
 02659            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02660            if (_shouldTrace)
 2661            {
 02662                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2663            }
 02664            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02665            cancellationToken.ThrowIfCancellationRequested();
 02666            string _responseContent = null;
 02667            if ((int)_statusCode != 200)
 2668            {
 02669                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2670                try
 2671                {
 02672                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02673                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02674                    if (_errorBody != null)
 2675                    {
 02676                        ex.Body = _errorBody;
 2677                    }
 02678                }
 02679                catch (JsonException)
 2680                {
 2681                    // Ignore the exception
 02682                }
 02683                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02684                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02685                if (_shouldTrace)
 2686                {
 02687                    ServiceClientTracing.Error(_invocationId, ex);
 2688                }
 02689                _httpRequest.Dispose();
 02690                if (_httpResponse != null)
 2691                {
 02692                    _httpResponse.Dispose();
 2693                }
 02694                throw ex;
 2695            }
 2696            // Create Result
 02697            var _result = new AzureOperationResponse<IPage<NodeFile>,FileListFromComputeNodeHeaders>();
 02698            _result.Request = _httpRequest;
 02699            _result.Response = _httpResponse;
 02700            if (_httpResponse.Headers.Contains("request-id"))
 2701            {
 02702                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2703            }
 2704            // Deserialize Response
 02705            if ((int)_statusCode == 200)
 2706            {
 02707                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2708                try
 2709                {
 02710                    _result.Body = SafeJsonConvert.DeserializeObject<Page<NodeFile>>(_responseContent, Client.Deserializ
 02711                }
 02712                catch (JsonException ex)
 2713                {
 02714                    _httpRequest.Dispose();
 02715                    if (_httpResponse != null)
 2716                    {
 02717                        _httpResponse.Dispose();
 2718                    }
 02719                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2720                }
 2721            }
 2722            try
 2723            {
 02724                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<FileListFromComputeNodeHeaders>(JsonSerializ
 02725            }
 02726            catch (JsonException ex)
 2727            {
 02728                _httpRequest.Dispose();
 02729                if (_httpResponse != null)
 2730                {
 02731                    _httpResponse.Dispose();
 2732                }
 02733                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2734            }
 02735            if (_shouldTrace)
 2736            {
 02737                ServiceClientTracing.Exit(_invocationId, _result);
 2738            }
 02739            return _result;
 02740        }
 2741
 2742    }
 2743}