< Summary

Class:Microsoft.Azure.Batch.Protocol.JobOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\JobOperations.cs
Covered lines:8
Uncovered lines:2188
Coverable lines:2196
Total lines:4492
Line coverage:0.3% (8 of 2196)
Covered branches:3
Total branches:1386
Branch coverage:0.2% (3 of 1386)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
GetAllLifetimeStatisticsWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-1.8%1.85%
PatchWithHttpMessagesAsync()-0%0%
UpdateWithHttpMessagesAsync()-0%0%
DisableWithHttpMessagesAsync()-0%0%
EnableWithHttpMessagesAsync()-0%0%
TerminateWithHttpMessagesAsync()-0%0%
AddWithHttpMessagesAsync()-0%0%
ListWithHttpMessagesAsync()-0%0%
ListFromJobScheduleWithHttpMessagesAsync()-0%0%
ListPreparationAndReleaseTaskStatusWithHttpMessagesAsync()-0%0%
GetTaskCountsWithHttpMessagesAsync()-0%0%
ListNextWithHttpMessagesAsync()-0%0%
ListFromJobScheduleNextWithHttpMessagesAsync()-0%0%
ListPreparationAndReleaseTaskStatusNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\JobOperations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Batch.Protocol
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Microsoft.Rest.Serialization;
 16    using Models;
 17    using Newtonsoft.Json;
 18    using System.Collections;
 19    using System.Collections.Generic;
 20    using System.Linq;
 21    using System.Net;
 22    using System.Net.Http;
 23    using System.Threading;
 24    using System.Threading.Tasks;
 25
 26    /// <summary>
 27    /// JobOperations operations.
 28    /// </summary>
 29    internal partial class JobOperations : IServiceOperations<BatchServiceClient>, IJobOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the JobOperations class.
 33        /// </summary>
 34        /// <param name='client'>
 35        /// Reference to the service client.
 36        /// </param>
 37        /// <exception cref="System.ArgumentNullException">
 38        /// Thrown when a required parameter is null
 39        /// </exception>
 14840        internal JobOperations(BatchServiceClient client)
 41        {
 14842            if (client == null)
 43            {
 044                throw new System.ArgumentNullException("client");
 45            }
 14846            Client = client;
 14847        }
 48
 49        /// <summary>
 50        /// Gets a reference to the BatchServiceClient
 51        /// </summary>
 14152        public BatchServiceClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Gets lifetime summary statistics for all of the Jobs in the specified
 56        /// Account.
 57        /// </summary>
 58        /// <remarks>
 59        /// Statistics are aggregated across all Jobs that have ever existed in the
 60        /// Account, from Account creation to the last update time of the statistics.
 61        /// The statistics may not be immediately available. The Batch service performs
 62        /// periodic roll-up of statistics. The typical delay is about 30 minutes.
 63        /// </remarks>
 64        /// <param name='jobGetAllLifetimeStatisticsOptions'>
 65        /// Additional parameters for the operation
 66        /// </param>
 67        /// <param name='customHeaders'>
 68        /// Headers that will be added to request.
 69        /// </param>
 70        /// <param name='cancellationToken'>
 71        /// The cancellation token.
 72        /// </param>
 73        /// <exception cref="BatchErrorException">
 74        /// Thrown when the operation returned an invalid status code
 75        /// </exception>
 76        /// <exception cref="SerializationException">
 77        /// Thrown when unable to deserialize the response
 78        /// </exception>
 79        /// <exception cref="ValidationException">
 80        /// Thrown when a required parameter is null
 81        /// </exception>
 82        /// <exception cref="System.ArgumentNullException">
 83        /// Thrown when a required parameter is null
 84        /// </exception>
 85        /// <return>
 86        /// A response object containing the response body and response headers.
 87        /// </return>
 88        public async Task<AzureOperationResponse<JobStatistics,JobGetAllLifetimeStatisticsHeaders>> GetAllLifetimeStatis
 89        {
 090            if (Client.BatchUrl == null)
 91            {
 092                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 93            }
 094            if (Client.ApiVersion == null)
 95            {
 096                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 97            }
 098            int? timeout = default(int?);
 099            if (jobGetAllLifetimeStatisticsOptions != null)
 100            {
 0101                timeout = jobGetAllLifetimeStatisticsOptions.Timeout;
 102            }
 0103            System.Guid? clientRequestId = default(System.Guid?);
 0104            if (jobGetAllLifetimeStatisticsOptions != null)
 105            {
 0106                clientRequestId = jobGetAllLifetimeStatisticsOptions.ClientRequestId;
 107            }
 0108            bool? returnClientRequestId = default(bool?);
 0109            if (jobGetAllLifetimeStatisticsOptions != null)
 110            {
 0111                returnClientRequestId = jobGetAllLifetimeStatisticsOptions.ReturnClientRequestId;
 112            }
 0113            System.DateTime? ocpDate = default(System.DateTime?);
 0114            if (jobGetAllLifetimeStatisticsOptions != null)
 115            {
 0116                ocpDate = jobGetAllLifetimeStatisticsOptions.OcpDate;
 117            }
 118            // Tracing
 0119            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0120            string _invocationId = null;
 0121            if (_shouldTrace)
 122            {
 0123                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0124                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0125                tracingParameters.Add("timeout", timeout);
 0126                tracingParameters.Add("clientRequestId", clientRequestId);
 0127                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0128                tracingParameters.Add("ocpDate", ocpDate);
 0129                tracingParameters.Add("cancellationToken", cancellationToken);
 0130                ServiceClientTracing.Enter(_invocationId, this, "GetAllLifetimeStatistics", tracingParameters);
 131            }
 132            // Construct URL
 0133            var _baseUrl = Client.BaseUri;
 0134            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "lifetimejobstats";
 0135            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0136            List<string> _queryParameters = new List<string>();
 0137            if (Client.ApiVersion != null)
 138            {
 0139                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 140            }
 0141            if (timeout != null)
 142            {
 0143                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 144            }
 0145            if (_queryParameters.Count > 0)
 146            {
 0147                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 148            }
 149            // Create HTTP transport objects
 0150            var _httpRequest = new HttpRequestMessage();
 0151            HttpResponseMessage _httpResponse = null;
 0152            _httpRequest.Method = new HttpMethod("GET");
 0153            _httpRequest.RequestUri = new System.Uri(_url);
 154            // Set Headers
 0155            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 156            {
 0157                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 158            }
 0159            if (Client.AcceptLanguage != null)
 160            {
 0161                if (_httpRequest.Headers.Contains("accept-language"))
 162                {
 0163                    _httpRequest.Headers.Remove("accept-language");
 164                }
 0165                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 166            }
 0167            if (clientRequestId != null)
 168            {
 0169                if (_httpRequest.Headers.Contains("client-request-id"))
 170                {
 0171                    _httpRequest.Headers.Remove("client-request-id");
 172                }
 0173                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 174            }
 0175            if (returnClientRequestId != null)
 176            {
 0177                if (_httpRequest.Headers.Contains("return-client-request-id"))
 178                {
 0179                    _httpRequest.Headers.Remove("return-client-request-id");
 180                }
 0181                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 182            }
 0183            if (ocpDate != null)
 184            {
 0185                if (_httpRequest.Headers.Contains("ocp-date"))
 186                {
 0187                    _httpRequest.Headers.Remove("ocp-date");
 188                }
 0189                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 190            }
 191
 192
 0193            if (customHeaders != null)
 194            {
 0195                foreach(var _header in customHeaders)
 196                {
 0197                    if (_httpRequest.Headers.Contains(_header.Key))
 198                    {
 0199                        _httpRequest.Headers.Remove(_header.Key);
 200                    }
 0201                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 202                }
 203            }
 204
 205            // Serialize Request
 0206            string _requestContent = null;
 207            // Set Credentials
 0208            if (Client.Credentials != null)
 209            {
 0210                cancellationToken.ThrowIfCancellationRequested();
 0211                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 212            }
 213            // Send Request
 0214            if (_shouldTrace)
 215            {
 0216                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 217            }
 0218            cancellationToken.ThrowIfCancellationRequested();
 0219            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0220            if (_shouldTrace)
 221            {
 0222                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 223            }
 0224            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0225            cancellationToken.ThrowIfCancellationRequested();
 0226            string _responseContent = null;
 0227            if ((int)_statusCode != 200)
 228            {
 0229                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 230                try
 231                {
 0232                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0233                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0234                    if (_errorBody != null)
 235                    {
 0236                        ex.Body = _errorBody;
 237                    }
 0238                }
 0239                catch (JsonException)
 240                {
 241                    // Ignore the exception
 0242                }
 0243                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0244                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0245                if (_shouldTrace)
 246                {
 0247                    ServiceClientTracing.Error(_invocationId, ex);
 248                }
 0249                _httpRequest.Dispose();
 0250                if (_httpResponse != null)
 251                {
 0252                    _httpResponse.Dispose();
 253                }
 0254                throw ex;
 255            }
 256            // Create Result
 0257            var _result = new AzureOperationResponse<JobStatistics,JobGetAllLifetimeStatisticsHeaders>();
 0258            _result.Request = _httpRequest;
 0259            _result.Response = _httpResponse;
 0260            if (_httpResponse.Headers.Contains("request-id"))
 261            {
 0262                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 263            }
 264            // Deserialize Response
 0265            if ((int)_statusCode == 200)
 266            {
 0267                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 268                try
 269                {
 0270                    _result.Body = SafeJsonConvert.DeserializeObject<JobStatistics>(_responseContent, Client.Deserializa
 0271                }
 0272                catch (JsonException ex)
 273                {
 0274                    _httpRequest.Dispose();
 0275                    if (_httpResponse != null)
 276                    {
 0277                        _httpResponse.Dispose();
 278                    }
 0279                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 280                }
 281            }
 282            try
 283            {
 0284                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobGetAllLifetimeStatisticsHeaders>(JsonSeri
 0285            }
 0286            catch (JsonException ex)
 287            {
 0288                _httpRequest.Dispose();
 0289                if (_httpResponse != null)
 290                {
 0291                    _httpResponse.Dispose();
 292                }
 0293                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 294            }
 0295            if (_shouldTrace)
 296            {
 0297                ServiceClientTracing.Exit(_invocationId, _result);
 298            }
 0299            return _result;
 0300        }
 301
 302        /// <summary>
 303        /// Deletes a Job.
 304        /// </summary>
 305        /// <remarks>
 306        /// Deleting a Job also deletes all Tasks that are part of that Job, and all
 307        /// Job statistics. This also overrides the retention period for Task data;
 308        /// that is, if the Job contains Tasks which are still retained on Compute
 309        /// Nodes, the Batch services deletes those Tasks' working directories and all
 310        /// their contents.  When a Delete Job request is received, the Batch service
 311        /// sets the Job to the deleting state. All update operations on a Job that is
 312        /// in deleting state will fail with status code 409 (Conflict), with
 313        /// additional information indicating that the Job is being deleted.
 314        /// </remarks>
 315        /// <param name='jobId'>
 316        /// The ID of the Job to delete.
 317        /// </param>
 318        /// <param name='jobDeleteOptions'>
 319        /// Additional parameters for the operation
 320        /// </param>
 321        /// <param name='customHeaders'>
 322        /// Headers that will be added to request.
 323        /// </param>
 324        /// <param name='cancellationToken'>
 325        /// The cancellation token.
 326        /// </param>
 327        /// <exception cref="BatchErrorException">
 328        /// Thrown when the operation returned an invalid status code
 329        /// </exception>
 330        /// <exception cref="ValidationException">
 331        /// Thrown when a required parameter is null
 332        /// </exception>
 333        /// <exception cref="System.ArgumentNullException">
 334        /// Thrown when a required parameter is null
 335        /// </exception>
 336        /// <return>
 337        /// A response object containing the response body and response headers.
 338        /// </return>
 339        public async Task<AzureOperationHeaderResponse<JobDeleteHeaders>> DeleteWithHttpMessagesAsync(string jobId, JobD
 340        {
 0341            if (Client.BatchUrl == null)
 342            {
 0343                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 344            }
 0345            if (jobId == null)
 346            {
 0347                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 348            }
 0349            if (Client.ApiVersion == null)
 350            {
 0351                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 352            }
 0353            int? timeout = default(int?);
 0354            if (jobDeleteOptions != null)
 355            {
 0356                timeout = jobDeleteOptions.Timeout;
 357            }
 0358            System.Guid? clientRequestId = default(System.Guid?);
 0359            if (jobDeleteOptions != null)
 360            {
 0361                clientRequestId = jobDeleteOptions.ClientRequestId;
 362            }
 0363            bool? returnClientRequestId = default(bool?);
 0364            if (jobDeleteOptions != null)
 365            {
 0366                returnClientRequestId = jobDeleteOptions.ReturnClientRequestId;
 367            }
 0368            System.DateTime? ocpDate = default(System.DateTime?);
 0369            if (jobDeleteOptions != null)
 370            {
 0371                ocpDate = jobDeleteOptions.OcpDate;
 372            }
 0373            string ifMatch = default(string);
 0374            if (jobDeleteOptions != null)
 375            {
 0376                ifMatch = jobDeleteOptions.IfMatch;
 377            }
 0378            string ifNoneMatch = default(string);
 0379            if (jobDeleteOptions != null)
 380            {
 0381                ifNoneMatch = jobDeleteOptions.IfNoneMatch;
 382            }
 0383            System.DateTime? ifModifiedSince = default(System.DateTime?);
 0384            if (jobDeleteOptions != null)
 385            {
 0386                ifModifiedSince = jobDeleteOptions.IfModifiedSince;
 387            }
 0388            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 0389            if (jobDeleteOptions != null)
 390            {
 0391                ifUnmodifiedSince = jobDeleteOptions.IfUnmodifiedSince;
 392            }
 393            // Tracing
 0394            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0395            string _invocationId = null;
 0396            if (_shouldTrace)
 397            {
 0398                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0399                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0400                tracingParameters.Add("jobId", jobId);
 0401                tracingParameters.Add("timeout", timeout);
 0402                tracingParameters.Add("clientRequestId", clientRequestId);
 0403                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0404                tracingParameters.Add("ocpDate", ocpDate);
 0405                tracingParameters.Add("ifMatch", ifMatch);
 0406                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0407                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0408                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0409                tracingParameters.Add("cancellationToken", cancellationToken);
 0410                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 411            }
 412            // Construct URL
 0413            var _baseUrl = Client.BaseUri;
 0414            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}";
 0415            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0416            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 0417            List<string> _queryParameters = new List<string>();
 0418            if (Client.ApiVersion != null)
 419            {
 0420                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 421            }
 0422            if (timeout != null)
 423            {
 0424                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 425            }
 0426            if (_queryParameters.Count > 0)
 427            {
 0428                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 429            }
 430            // Create HTTP transport objects
 0431            var _httpRequest = new HttpRequestMessage();
 0432            HttpResponseMessage _httpResponse = null;
 0433            _httpRequest.Method = new HttpMethod("DELETE");
 0434            _httpRequest.RequestUri = new System.Uri(_url);
 435            // Set Headers
 0436            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 437            {
 0438                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 439            }
 0440            if (Client.AcceptLanguage != null)
 441            {
 0442                if (_httpRequest.Headers.Contains("accept-language"))
 443                {
 0444                    _httpRequest.Headers.Remove("accept-language");
 445                }
 0446                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 447            }
 0448            if (clientRequestId != null)
 449            {
 0450                if (_httpRequest.Headers.Contains("client-request-id"))
 451                {
 0452                    _httpRequest.Headers.Remove("client-request-id");
 453                }
 0454                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 455            }
 0456            if (returnClientRequestId != null)
 457            {
 0458                if (_httpRequest.Headers.Contains("return-client-request-id"))
 459                {
 0460                    _httpRequest.Headers.Remove("return-client-request-id");
 461                }
 0462                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 463            }
 0464            if (ocpDate != null)
 465            {
 0466                if (_httpRequest.Headers.Contains("ocp-date"))
 467                {
 0468                    _httpRequest.Headers.Remove("ocp-date");
 469                }
 0470                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 471            }
 0472            if (ifMatch != null)
 473            {
 0474                if (_httpRequest.Headers.Contains("If-Match"))
 475                {
 0476                    _httpRequest.Headers.Remove("If-Match");
 477                }
 0478                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 479            }
 0480            if (ifNoneMatch != null)
 481            {
 0482                if (_httpRequest.Headers.Contains("If-None-Match"))
 483                {
 0484                    _httpRequest.Headers.Remove("If-None-Match");
 485                }
 0486                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 487            }
 0488            if (ifModifiedSince != null)
 489            {
 0490                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 491                {
 0492                    _httpRequest.Headers.Remove("If-Modified-Since");
 493                }
 0494                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 495            }
 0496            if (ifUnmodifiedSince != null)
 497            {
 0498                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 499                {
 0500                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 501                }
 0502                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 503            }
 504
 505
 0506            if (customHeaders != null)
 507            {
 0508                foreach(var _header in customHeaders)
 509                {
 0510                    if (_httpRequest.Headers.Contains(_header.Key))
 511                    {
 0512                        _httpRequest.Headers.Remove(_header.Key);
 513                    }
 0514                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 515                }
 516            }
 517
 518            // Serialize Request
 0519            string _requestContent = null;
 520            // Set Credentials
 0521            if (Client.Credentials != null)
 522            {
 0523                cancellationToken.ThrowIfCancellationRequested();
 0524                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 525            }
 526            // Send Request
 0527            if (_shouldTrace)
 528            {
 0529                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 530            }
 0531            cancellationToken.ThrowIfCancellationRequested();
 0532            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0533            if (_shouldTrace)
 534            {
 0535                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 536            }
 0537            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0538            cancellationToken.ThrowIfCancellationRequested();
 0539            string _responseContent = null;
 0540            if ((int)_statusCode != 202)
 541            {
 0542                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 543                try
 544                {
 0545                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0546                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0547                    if (_errorBody != null)
 548                    {
 0549                        ex.Body = _errorBody;
 550                    }
 0551                }
 0552                catch (JsonException)
 553                {
 554                    // Ignore the exception
 0555                }
 0556                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0557                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0558                if (_shouldTrace)
 559                {
 0560                    ServiceClientTracing.Error(_invocationId, ex);
 561                }
 0562                _httpRequest.Dispose();
 0563                if (_httpResponse != null)
 564                {
 0565                    _httpResponse.Dispose();
 566                }
 0567                throw ex;
 568            }
 569            // Create Result
 0570            var _result = new AzureOperationHeaderResponse<JobDeleteHeaders>();
 0571            _result.Request = _httpRequest;
 0572            _result.Response = _httpResponse;
 0573            if (_httpResponse.Headers.Contains("request-id"))
 574            {
 0575                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 576            }
 577            try
 578            {
 0579                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobDeleteHeaders>(JsonSerializer.Create(Clie
 0580            }
 0581            catch (JsonException ex)
 582            {
 0583                _httpRequest.Dispose();
 0584                if (_httpResponse != null)
 585                {
 0586                    _httpResponse.Dispose();
 587                }
 0588                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 589            }
 0590            if (_shouldTrace)
 591            {
 0592                ServiceClientTracing.Exit(_invocationId, _result);
 593            }
 0594            return _result;
 0595        }
 596
 597        /// <summary>
 598        /// Gets information about the specified Job.
 599        /// </summary>
 600        /// <param name='jobId'>
 601        /// The ID of the Job.
 602        /// </param>
 603        /// <param name='jobGetOptions'>
 604        /// Additional parameters for the operation
 605        /// </param>
 606        /// <param name='customHeaders'>
 607        /// Headers that will be added to request.
 608        /// </param>
 609        /// <param name='cancellationToken'>
 610        /// The cancellation token.
 611        /// </param>
 612        /// <exception cref="BatchErrorException">
 613        /// Thrown when the operation returned an invalid status code
 614        /// </exception>
 615        /// <exception cref="SerializationException">
 616        /// Thrown when unable to deserialize the response
 617        /// </exception>
 618        /// <exception cref="ValidationException">
 619        /// Thrown when a required parameter is null
 620        /// </exception>
 621        /// <exception cref="System.ArgumentNullException">
 622        /// Thrown when a required parameter is null
 623        /// </exception>
 624        /// <return>
 625        /// A response object containing the response body and response headers.
 626        /// </return>
 627        public async Task<AzureOperationResponse<CloudJob,JobGetHeaders>> GetWithHttpMessagesAsync(string jobId, JobGetO
 628        {
 1629            if (Client.BatchUrl == null)
 630            {
 0631                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 632            }
 1633            if (jobId == null)
 634            {
 1635                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 636            }
 0637            if (Client.ApiVersion == null)
 638            {
 0639                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 640            }
 0641            string select = default(string);
 0642            if (jobGetOptions != null)
 643            {
 0644                select = jobGetOptions.Select;
 645            }
 0646            string expand = default(string);
 0647            if (jobGetOptions != null)
 648            {
 0649                expand = jobGetOptions.Expand;
 650            }
 0651            int? timeout = default(int?);
 0652            if (jobGetOptions != null)
 653            {
 0654                timeout = jobGetOptions.Timeout;
 655            }
 0656            System.Guid? clientRequestId = default(System.Guid?);
 0657            if (jobGetOptions != null)
 658            {
 0659                clientRequestId = jobGetOptions.ClientRequestId;
 660            }
 0661            bool? returnClientRequestId = default(bool?);
 0662            if (jobGetOptions != null)
 663            {
 0664                returnClientRequestId = jobGetOptions.ReturnClientRequestId;
 665            }
 0666            System.DateTime? ocpDate = default(System.DateTime?);
 0667            if (jobGetOptions != null)
 668            {
 0669                ocpDate = jobGetOptions.OcpDate;
 670            }
 0671            string ifMatch = default(string);
 0672            if (jobGetOptions != null)
 673            {
 0674                ifMatch = jobGetOptions.IfMatch;
 675            }
 0676            string ifNoneMatch = default(string);
 0677            if (jobGetOptions != null)
 678            {
 0679                ifNoneMatch = jobGetOptions.IfNoneMatch;
 680            }
 0681            System.DateTime? ifModifiedSince = default(System.DateTime?);
 0682            if (jobGetOptions != null)
 683            {
 0684                ifModifiedSince = jobGetOptions.IfModifiedSince;
 685            }
 0686            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 0687            if (jobGetOptions != null)
 688            {
 0689                ifUnmodifiedSince = jobGetOptions.IfUnmodifiedSince;
 690            }
 691            // Tracing
 0692            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0693            string _invocationId = null;
 0694            if (_shouldTrace)
 695            {
 0696                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0697                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0698                tracingParameters.Add("jobId", jobId);
 0699                tracingParameters.Add("select", select);
 0700                tracingParameters.Add("expand", expand);
 0701                tracingParameters.Add("timeout", timeout);
 0702                tracingParameters.Add("clientRequestId", clientRequestId);
 0703                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0704                tracingParameters.Add("ocpDate", ocpDate);
 0705                tracingParameters.Add("ifMatch", ifMatch);
 0706                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0707                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0708                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0709                tracingParameters.Add("cancellationToken", cancellationToken);
 0710                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 711            }
 712            // Construct URL
 0713            var _baseUrl = Client.BaseUri;
 0714            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}";
 0715            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0716            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 0717            List<string> _queryParameters = new List<string>();
 0718            if (Client.ApiVersion != null)
 719            {
 0720                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 721            }
 0722            if (select != null)
 723            {
 0724                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 725            }
 0726            if (expand != null)
 727            {
 0728                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
 729            }
 0730            if (timeout != null)
 731            {
 0732                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 733            }
 0734            if (_queryParameters.Count > 0)
 735            {
 0736                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 737            }
 738            // Create HTTP transport objects
 0739            var _httpRequest = new HttpRequestMessage();
 0740            HttpResponseMessage _httpResponse = null;
 0741            _httpRequest.Method = new HttpMethod("GET");
 0742            _httpRequest.RequestUri = new System.Uri(_url);
 743            // Set Headers
 0744            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 745            {
 0746                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 747            }
 0748            if (Client.AcceptLanguage != null)
 749            {
 0750                if (_httpRequest.Headers.Contains("accept-language"))
 751                {
 0752                    _httpRequest.Headers.Remove("accept-language");
 753                }
 0754                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 755            }
 0756            if (clientRequestId != null)
 757            {
 0758                if (_httpRequest.Headers.Contains("client-request-id"))
 759                {
 0760                    _httpRequest.Headers.Remove("client-request-id");
 761                }
 0762                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 763            }
 0764            if (returnClientRequestId != null)
 765            {
 0766                if (_httpRequest.Headers.Contains("return-client-request-id"))
 767                {
 0768                    _httpRequest.Headers.Remove("return-client-request-id");
 769                }
 0770                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 771            }
 0772            if (ocpDate != null)
 773            {
 0774                if (_httpRequest.Headers.Contains("ocp-date"))
 775                {
 0776                    _httpRequest.Headers.Remove("ocp-date");
 777                }
 0778                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 779            }
 0780            if (ifMatch != null)
 781            {
 0782                if (_httpRequest.Headers.Contains("If-Match"))
 783                {
 0784                    _httpRequest.Headers.Remove("If-Match");
 785                }
 0786                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 787            }
 0788            if (ifNoneMatch != null)
 789            {
 0790                if (_httpRequest.Headers.Contains("If-None-Match"))
 791                {
 0792                    _httpRequest.Headers.Remove("If-None-Match");
 793                }
 0794                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 795            }
 0796            if (ifModifiedSince != null)
 797            {
 0798                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 799                {
 0800                    _httpRequest.Headers.Remove("If-Modified-Since");
 801                }
 0802                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 803            }
 0804            if (ifUnmodifiedSince != null)
 805            {
 0806                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 807                {
 0808                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 809                }
 0810                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 811            }
 812
 813
 0814            if (customHeaders != null)
 815            {
 0816                foreach(var _header in customHeaders)
 817                {
 0818                    if (_httpRequest.Headers.Contains(_header.Key))
 819                    {
 0820                        _httpRequest.Headers.Remove(_header.Key);
 821                    }
 0822                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 823                }
 824            }
 825
 826            // Serialize Request
 0827            string _requestContent = null;
 828            // Set Credentials
 0829            if (Client.Credentials != null)
 830            {
 0831                cancellationToken.ThrowIfCancellationRequested();
 0832                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 833            }
 834            // Send Request
 0835            if (_shouldTrace)
 836            {
 0837                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 838            }
 0839            cancellationToken.ThrowIfCancellationRequested();
 0840            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0841            if (_shouldTrace)
 842            {
 0843                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 844            }
 0845            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0846            cancellationToken.ThrowIfCancellationRequested();
 0847            string _responseContent = null;
 0848            if ((int)_statusCode != 200)
 849            {
 0850                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 851                try
 852                {
 0853                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0854                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0855                    if (_errorBody != null)
 856                    {
 0857                        ex.Body = _errorBody;
 858                    }
 0859                }
 0860                catch (JsonException)
 861                {
 862                    // Ignore the exception
 0863                }
 0864                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0865                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0866                if (_shouldTrace)
 867                {
 0868                    ServiceClientTracing.Error(_invocationId, ex);
 869                }
 0870                _httpRequest.Dispose();
 0871                if (_httpResponse != null)
 872                {
 0873                    _httpResponse.Dispose();
 874                }
 0875                throw ex;
 876            }
 877            // Create Result
 0878            var _result = new AzureOperationResponse<CloudJob,JobGetHeaders>();
 0879            _result.Request = _httpRequest;
 0880            _result.Response = _httpResponse;
 0881            if (_httpResponse.Headers.Contains("request-id"))
 882            {
 0883                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 884            }
 885            // Deserialize Response
 0886            if ((int)_statusCode == 200)
 887            {
 0888                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 889                try
 890                {
 0891                    _result.Body = SafeJsonConvert.DeserializeObject<CloudJob>(_responseContent, Client.DeserializationS
 0892                }
 0893                catch (JsonException ex)
 894                {
 0895                    _httpRequest.Dispose();
 0896                    if (_httpResponse != null)
 897                    {
 0898                        _httpResponse.Dispose();
 899                    }
 0900                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 901                }
 902            }
 903            try
 904            {
 0905                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobGetHeaders>(JsonSerializer.Create(Client.
 0906            }
 0907            catch (JsonException ex)
 908            {
 0909                _httpRequest.Dispose();
 0910                if (_httpResponse != null)
 911                {
 0912                    _httpResponse.Dispose();
 913                }
 0914                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 915            }
 0916            if (_shouldTrace)
 917            {
 0918                ServiceClientTracing.Exit(_invocationId, _result);
 919            }
 0920            return _result;
 0921        }
 922
 923        /// <summary>
 924        /// Updates the properties of the specified Job.
 925        /// </summary>
 926        /// <remarks>
 927        /// This replaces only the Job properties specified in the request. For
 928        /// example, if the Job has constraints, and a request does not specify the
 929        /// constraints element, then the Job keeps the existing constraints.
 930        /// </remarks>
 931        /// <param name='jobId'>
 932        /// The ID of the Job whose properties you want to update.
 933        /// </param>
 934        /// <param name='jobPatchParameter'>
 935        /// The parameters for the request.
 936        /// </param>
 937        /// <param name='jobPatchOptions'>
 938        /// Additional parameters for the operation
 939        /// </param>
 940        /// <param name='customHeaders'>
 941        /// Headers that will be added to request.
 942        /// </param>
 943        /// <param name='cancellationToken'>
 944        /// The cancellation token.
 945        /// </param>
 946        /// <exception cref="BatchErrorException">
 947        /// Thrown when the operation returned an invalid status code
 948        /// </exception>
 949        /// <exception cref="ValidationException">
 950        /// Thrown when a required parameter is null
 951        /// </exception>
 952        /// <exception cref="System.ArgumentNullException">
 953        /// Thrown when a required parameter is null
 954        /// </exception>
 955        /// <return>
 956        /// A response object containing the response body and response headers.
 957        /// </return>
 958        public async Task<AzureOperationHeaderResponse<JobPatchHeaders>> PatchWithHttpMessagesAsync(string jobId, JobPat
 959        {
 0960            if (Client.BatchUrl == null)
 961            {
 0962                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 963            }
 0964            if (jobId == null)
 965            {
 0966                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 967            }
 0968            if (jobPatchParameter == null)
 969            {
 0970                throw new ValidationException(ValidationRules.CannotBeNull, "jobPatchParameter");
 971            }
 0972            if (Client.ApiVersion == null)
 973            {
 0974                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 975            }
 0976            int? timeout = default(int?);
 0977            if (jobPatchOptions != null)
 978            {
 0979                timeout = jobPatchOptions.Timeout;
 980            }
 0981            System.Guid? clientRequestId = default(System.Guid?);
 0982            if (jobPatchOptions != null)
 983            {
 0984                clientRequestId = jobPatchOptions.ClientRequestId;
 985            }
 0986            bool? returnClientRequestId = default(bool?);
 0987            if (jobPatchOptions != null)
 988            {
 0989                returnClientRequestId = jobPatchOptions.ReturnClientRequestId;
 990            }
 0991            System.DateTime? ocpDate = default(System.DateTime?);
 0992            if (jobPatchOptions != null)
 993            {
 0994                ocpDate = jobPatchOptions.OcpDate;
 995            }
 0996            string ifMatch = default(string);
 0997            if (jobPatchOptions != null)
 998            {
 0999                ifMatch = jobPatchOptions.IfMatch;
 1000            }
 01001            string ifNoneMatch = default(string);
 01002            if (jobPatchOptions != null)
 1003            {
 01004                ifNoneMatch = jobPatchOptions.IfNoneMatch;
 1005            }
 01006            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01007            if (jobPatchOptions != null)
 1008            {
 01009                ifModifiedSince = jobPatchOptions.IfModifiedSince;
 1010            }
 01011            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01012            if (jobPatchOptions != null)
 1013            {
 01014                ifUnmodifiedSince = jobPatchOptions.IfUnmodifiedSince;
 1015            }
 1016            // Tracing
 01017            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01018            string _invocationId = null;
 01019            if (_shouldTrace)
 1020            {
 01021                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01022                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01023                tracingParameters.Add("jobId", jobId);
 01024                tracingParameters.Add("jobPatchParameter", jobPatchParameter);
 01025                tracingParameters.Add("timeout", timeout);
 01026                tracingParameters.Add("clientRequestId", clientRequestId);
 01027                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01028                tracingParameters.Add("ocpDate", ocpDate);
 01029                tracingParameters.Add("ifMatch", ifMatch);
 01030                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01031                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01032                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01033                tracingParameters.Add("cancellationToken", cancellationToken);
 01034                ServiceClientTracing.Enter(_invocationId, this, "Patch", tracingParameters);
 1035            }
 1036            // Construct URL
 01037            var _baseUrl = Client.BaseUri;
 01038            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}";
 01039            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01040            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 01041            List<string> _queryParameters = new List<string>();
 01042            if (Client.ApiVersion != null)
 1043            {
 01044                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1045            }
 01046            if (timeout != null)
 1047            {
 01048                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1049            }
 01050            if (_queryParameters.Count > 0)
 1051            {
 01052                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1053            }
 1054            // Create HTTP transport objects
 01055            var _httpRequest = new HttpRequestMessage();
 01056            HttpResponseMessage _httpResponse = null;
 01057            _httpRequest.Method = new HttpMethod("PATCH");
 01058            _httpRequest.RequestUri = new System.Uri(_url);
 1059            // Set Headers
 01060            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1061            {
 01062                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1063            }
 01064            if (Client.AcceptLanguage != null)
 1065            {
 01066                if (_httpRequest.Headers.Contains("accept-language"))
 1067                {
 01068                    _httpRequest.Headers.Remove("accept-language");
 1069                }
 01070                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1071            }
 01072            if (clientRequestId != null)
 1073            {
 01074                if (_httpRequest.Headers.Contains("client-request-id"))
 1075                {
 01076                    _httpRequest.Headers.Remove("client-request-id");
 1077                }
 01078                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1079            }
 01080            if (returnClientRequestId != null)
 1081            {
 01082                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1083                {
 01084                    _httpRequest.Headers.Remove("return-client-request-id");
 1085                }
 01086                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1087            }
 01088            if (ocpDate != null)
 1089            {
 01090                if (_httpRequest.Headers.Contains("ocp-date"))
 1091                {
 01092                    _httpRequest.Headers.Remove("ocp-date");
 1093                }
 01094                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1095            }
 01096            if (ifMatch != null)
 1097            {
 01098                if (_httpRequest.Headers.Contains("If-Match"))
 1099                {
 01100                    _httpRequest.Headers.Remove("If-Match");
 1101                }
 01102                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1103            }
 01104            if (ifNoneMatch != null)
 1105            {
 01106                if (_httpRequest.Headers.Contains("If-None-Match"))
 1107                {
 01108                    _httpRequest.Headers.Remove("If-None-Match");
 1109                }
 01110                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1111            }
 01112            if (ifModifiedSince != null)
 1113            {
 01114                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1115                {
 01116                    _httpRequest.Headers.Remove("If-Modified-Since");
 1117                }
 01118                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1119            }
 01120            if (ifUnmodifiedSince != null)
 1121            {
 01122                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1123                {
 01124                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1125                }
 01126                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1127            }
 1128
 1129
 01130            if (customHeaders != null)
 1131            {
 01132                foreach(var _header in customHeaders)
 1133                {
 01134                    if (_httpRequest.Headers.Contains(_header.Key))
 1135                    {
 01136                        _httpRequest.Headers.Remove(_header.Key);
 1137                    }
 01138                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1139                }
 1140            }
 1141
 1142            // Serialize Request
 01143            string _requestContent = null;
 01144            if(jobPatchParameter != null)
 1145            {
 01146                _requestContent = SafeJsonConvert.SerializeObject(jobPatchParameter, Client.SerializationSettings);
 01147                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01148                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1149            }
 1150            // Set Credentials
 01151            if (Client.Credentials != null)
 1152            {
 01153                cancellationToken.ThrowIfCancellationRequested();
 01154                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1155            }
 1156            // Send Request
 01157            if (_shouldTrace)
 1158            {
 01159                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1160            }
 01161            cancellationToken.ThrowIfCancellationRequested();
 01162            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01163            if (_shouldTrace)
 1164            {
 01165                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1166            }
 01167            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01168            cancellationToken.ThrowIfCancellationRequested();
 01169            string _responseContent = null;
 01170            if ((int)_statusCode != 200)
 1171            {
 01172                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1173                try
 1174                {
 01175                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01176                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01177                    if (_errorBody != null)
 1178                    {
 01179                        ex.Body = _errorBody;
 1180                    }
 01181                }
 01182                catch (JsonException)
 1183                {
 1184                    // Ignore the exception
 01185                }
 01186                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01187                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01188                if (_shouldTrace)
 1189                {
 01190                    ServiceClientTracing.Error(_invocationId, ex);
 1191                }
 01192                _httpRequest.Dispose();
 01193                if (_httpResponse != null)
 1194                {
 01195                    _httpResponse.Dispose();
 1196                }
 01197                throw ex;
 1198            }
 1199            // Create Result
 01200            var _result = new AzureOperationHeaderResponse<JobPatchHeaders>();
 01201            _result.Request = _httpRequest;
 01202            _result.Response = _httpResponse;
 01203            if (_httpResponse.Headers.Contains("request-id"))
 1204            {
 01205                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1206            }
 1207            try
 1208            {
 01209                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobPatchHeaders>(JsonSerializer.Create(Clien
 01210            }
 01211            catch (JsonException ex)
 1212            {
 01213                _httpRequest.Dispose();
 01214                if (_httpResponse != null)
 1215                {
 01216                    _httpResponse.Dispose();
 1217                }
 01218                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1219            }
 01220            if (_shouldTrace)
 1221            {
 01222                ServiceClientTracing.Exit(_invocationId, _result);
 1223            }
 01224            return _result;
 01225        }
 1226
 1227        /// <summary>
 1228        /// Updates the properties of the specified Job.
 1229        /// </summary>
 1230        /// <remarks>
 1231        /// This fully replaces all the updatable properties of the Job. For example,
 1232        /// if the Job has constraints associated with it and if constraints is not
 1233        /// specified with this request, then the Batch service will remove the
 1234        /// existing constraints.
 1235        /// </remarks>
 1236        /// <param name='jobId'>
 1237        /// The ID of the Job whose properties you want to update.
 1238        /// </param>
 1239        /// <param name='jobUpdateParameter'>
 1240        /// The parameters for the request.
 1241        /// </param>
 1242        /// <param name='jobUpdateOptions'>
 1243        /// Additional parameters for the operation
 1244        /// </param>
 1245        /// <param name='customHeaders'>
 1246        /// Headers that will be added to request.
 1247        /// </param>
 1248        /// <param name='cancellationToken'>
 1249        /// The cancellation token.
 1250        /// </param>
 1251        /// <exception cref="BatchErrorException">
 1252        /// Thrown when the operation returned an invalid status code
 1253        /// </exception>
 1254        /// <exception cref="ValidationException">
 1255        /// Thrown when a required parameter is null
 1256        /// </exception>
 1257        /// <exception cref="System.ArgumentNullException">
 1258        /// Thrown when a required parameter is null
 1259        /// </exception>
 1260        /// <return>
 1261        /// A response object containing the response body and response headers.
 1262        /// </return>
 1263        public async Task<AzureOperationHeaderResponse<JobUpdateHeaders>> UpdateWithHttpMessagesAsync(string jobId, JobU
 1264        {
 01265            if (Client.BatchUrl == null)
 1266            {
 01267                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1268            }
 01269            if (jobId == null)
 1270            {
 01271                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 1272            }
 01273            if (jobUpdateParameter == null)
 1274            {
 01275                throw new ValidationException(ValidationRules.CannotBeNull, "jobUpdateParameter");
 1276            }
 01277            if (Client.ApiVersion == null)
 1278            {
 01279                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1280            }
 01281            int? timeout = default(int?);
 01282            if (jobUpdateOptions != null)
 1283            {
 01284                timeout = jobUpdateOptions.Timeout;
 1285            }
 01286            System.Guid? clientRequestId = default(System.Guid?);
 01287            if (jobUpdateOptions != null)
 1288            {
 01289                clientRequestId = jobUpdateOptions.ClientRequestId;
 1290            }
 01291            bool? returnClientRequestId = default(bool?);
 01292            if (jobUpdateOptions != null)
 1293            {
 01294                returnClientRequestId = jobUpdateOptions.ReturnClientRequestId;
 1295            }
 01296            System.DateTime? ocpDate = default(System.DateTime?);
 01297            if (jobUpdateOptions != null)
 1298            {
 01299                ocpDate = jobUpdateOptions.OcpDate;
 1300            }
 01301            string ifMatch = default(string);
 01302            if (jobUpdateOptions != null)
 1303            {
 01304                ifMatch = jobUpdateOptions.IfMatch;
 1305            }
 01306            string ifNoneMatch = default(string);
 01307            if (jobUpdateOptions != null)
 1308            {
 01309                ifNoneMatch = jobUpdateOptions.IfNoneMatch;
 1310            }
 01311            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01312            if (jobUpdateOptions != null)
 1313            {
 01314                ifModifiedSince = jobUpdateOptions.IfModifiedSince;
 1315            }
 01316            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01317            if (jobUpdateOptions != null)
 1318            {
 01319                ifUnmodifiedSince = jobUpdateOptions.IfUnmodifiedSince;
 1320            }
 1321            // Tracing
 01322            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01323            string _invocationId = null;
 01324            if (_shouldTrace)
 1325            {
 01326                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01327                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01328                tracingParameters.Add("jobId", jobId);
 01329                tracingParameters.Add("jobUpdateParameter", jobUpdateParameter);
 01330                tracingParameters.Add("timeout", timeout);
 01331                tracingParameters.Add("clientRequestId", clientRequestId);
 01332                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01333                tracingParameters.Add("ocpDate", ocpDate);
 01334                tracingParameters.Add("ifMatch", ifMatch);
 01335                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01336                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01337                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01338                tracingParameters.Add("cancellationToken", cancellationToken);
 01339                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 1340            }
 1341            // Construct URL
 01342            var _baseUrl = Client.BaseUri;
 01343            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}";
 01344            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01345            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 01346            List<string> _queryParameters = new List<string>();
 01347            if (Client.ApiVersion != null)
 1348            {
 01349                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1350            }
 01351            if (timeout != null)
 1352            {
 01353                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1354            }
 01355            if (_queryParameters.Count > 0)
 1356            {
 01357                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1358            }
 1359            // Create HTTP transport objects
 01360            var _httpRequest = new HttpRequestMessage();
 01361            HttpResponseMessage _httpResponse = null;
 01362            _httpRequest.Method = new HttpMethod("PUT");
 01363            _httpRequest.RequestUri = new System.Uri(_url);
 1364            // Set Headers
 01365            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1366            {
 01367                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1368            }
 01369            if (Client.AcceptLanguage != null)
 1370            {
 01371                if (_httpRequest.Headers.Contains("accept-language"))
 1372                {
 01373                    _httpRequest.Headers.Remove("accept-language");
 1374                }
 01375                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1376            }
 01377            if (clientRequestId != null)
 1378            {
 01379                if (_httpRequest.Headers.Contains("client-request-id"))
 1380                {
 01381                    _httpRequest.Headers.Remove("client-request-id");
 1382                }
 01383                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1384            }
 01385            if (returnClientRequestId != null)
 1386            {
 01387                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1388                {
 01389                    _httpRequest.Headers.Remove("return-client-request-id");
 1390                }
 01391                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1392            }
 01393            if (ocpDate != null)
 1394            {
 01395                if (_httpRequest.Headers.Contains("ocp-date"))
 1396                {
 01397                    _httpRequest.Headers.Remove("ocp-date");
 1398                }
 01399                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1400            }
 01401            if (ifMatch != null)
 1402            {
 01403                if (_httpRequest.Headers.Contains("If-Match"))
 1404                {
 01405                    _httpRequest.Headers.Remove("If-Match");
 1406                }
 01407                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1408            }
 01409            if (ifNoneMatch != null)
 1410            {
 01411                if (_httpRequest.Headers.Contains("If-None-Match"))
 1412                {
 01413                    _httpRequest.Headers.Remove("If-None-Match");
 1414                }
 01415                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1416            }
 01417            if (ifModifiedSince != null)
 1418            {
 01419                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1420                {
 01421                    _httpRequest.Headers.Remove("If-Modified-Since");
 1422                }
 01423                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1424            }
 01425            if (ifUnmodifiedSince != null)
 1426            {
 01427                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1428                {
 01429                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1430                }
 01431                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1432            }
 1433
 1434
 01435            if (customHeaders != null)
 1436            {
 01437                foreach(var _header in customHeaders)
 1438                {
 01439                    if (_httpRequest.Headers.Contains(_header.Key))
 1440                    {
 01441                        _httpRequest.Headers.Remove(_header.Key);
 1442                    }
 01443                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1444                }
 1445            }
 1446
 1447            // Serialize Request
 01448            string _requestContent = null;
 01449            if(jobUpdateParameter != null)
 1450            {
 01451                _requestContent = SafeJsonConvert.SerializeObject(jobUpdateParameter, Client.SerializationSettings);
 01452                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01453                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1454            }
 1455            // Set Credentials
 01456            if (Client.Credentials != null)
 1457            {
 01458                cancellationToken.ThrowIfCancellationRequested();
 01459                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1460            }
 1461            // Send Request
 01462            if (_shouldTrace)
 1463            {
 01464                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1465            }
 01466            cancellationToken.ThrowIfCancellationRequested();
 01467            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01468            if (_shouldTrace)
 1469            {
 01470                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1471            }
 01472            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01473            cancellationToken.ThrowIfCancellationRequested();
 01474            string _responseContent = null;
 01475            if ((int)_statusCode != 200)
 1476            {
 01477                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1478                try
 1479                {
 01480                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01481                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01482                    if (_errorBody != null)
 1483                    {
 01484                        ex.Body = _errorBody;
 1485                    }
 01486                }
 01487                catch (JsonException)
 1488                {
 1489                    // Ignore the exception
 01490                }
 01491                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01492                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01493                if (_shouldTrace)
 1494                {
 01495                    ServiceClientTracing.Error(_invocationId, ex);
 1496                }
 01497                _httpRequest.Dispose();
 01498                if (_httpResponse != null)
 1499                {
 01500                    _httpResponse.Dispose();
 1501                }
 01502                throw ex;
 1503            }
 1504            // Create Result
 01505            var _result = new AzureOperationHeaderResponse<JobUpdateHeaders>();
 01506            _result.Request = _httpRequest;
 01507            _result.Response = _httpResponse;
 01508            if (_httpResponse.Headers.Contains("request-id"))
 1509            {
 01510                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1511            }
 1512            try
 1513            {
 01514                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobUpdateHeaders>(JsonSerializer.Create(Clie
 01515            }
 01516            catch (JsonException ex)
 1517            {
 01518                _httpRequest.Dispose();
 01519                if (_httpResponse != null)
 1520                {
 01521                    _httpResponse.Dispose();
 1522                }
 01523                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1524            }
 01525            if (_shouldTrace)
 1526            {
 01527                ServiceClientTracing.Exit(_invocationId, _result);
 1528            }
 01529            return _result;
 01530        }
 1531
 1532        /// <summary>
 1533        /// Disables the specified Job, preventing new Tasks from running.
 1534        /// </summary>
 1535        /// <remarks>
 1536        /// The Batch Service immediately moves the Job to the disabling state. Batch
 1537        /// then uses the disableTasks parameter to determine what to do with the
 1538        /// currently running Tasks of the Job. The Job remains in the disabling state
 1539        /// until the disable operation is completed and all Tasks have been dealt with
 1540        /// according to the disableTasks option; the Job then moves to the disabled
 1541        /// state. No new Tasks are started under the Job until it moves back to active
 1542        /// state. If you try to disable a Job that is in any state other than active,
 1543        /// disabling, or disabled, the request fails with status code 409.
 1544        /// </remarks>
 1545        /// <param name='jobId'>
 1546        /// The ID of the Job to disable.
 1547        /// </param>
 1548        /// <param name='disableTasks'>
 1549        /// What to do with active Tasks associated with the Job. Possible values
 1550        /// include: 'requeue', 'terminate', 'wait'
 1551        /// </param>
 1552        /// <param name='jobDisableOptions'>
 1553        /// Additional parameters for the operation
 1554        /// </param>
 1555        /// <param name='customHeaders'>
 1556        /// Headers that will be added to request.
 1557        /// </param>
 1558        /// <param name='cancellationToken'>
 1559        /// The cancellation token.
 1560        /// </param>
 1561        /// <exception cref="BatchErrorException">
 1562        /// Thrown when the operation returned an invalid status code
 1563        /// </exception>
 1564        /// <exception cref="ValidationException">
 1565        /// Thrown when a required parameter is null
 1566        /// </exception>
 1567        /// <exception cref="System.ArgumentNullException">
 1568        /// Thrown when a required parameter is null
 1569        /// </exception>
 1570        /// <return>
 1571        /// A response object containing the response body and response headers.
 1572        /// </return>
 1573        public async Task<AzureOperationHeaderResponse<JobDisableHeaders>> DisableWithHttpMessagesAsync(string jobId, Di
 1574        {
 01575            if (Client.BatchUrl == null)
 1576            {
 01577                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1578            }
 01579            if (jobId == null)
 1580            {
 01581                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 1582            }
 01583            if (Client.ApiVersion == null)
 1584            {
 01585                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1586            }
 01587            int? timeout = default(int?);
 01588            if (jobDisableOptions != null)
 1589            {
 01590                timeout = jobDisableOptions.Timeout;
 1591            }
 01592            System.Guid? clientRequestId = default(System.Guid?);
 01593            if (jobDisableOptions != null)
 1594            {
 01595                clientRequestId = jobDisableOptions.ClientRequestId;
 1596            }
 01597            bool? returnClientRequestId = default(bool?);
 01598            if (jobDisableOptions != null)
 1599            {
 01600                returnClientRequestId = jobDisableOptions.ReturnClientRequestId;
 1601            }
 01602            System.DateTime? ocpDate = default(System.DateTime?);
 01603            if (jobDisableOptions != null)
 1604            {
 01605                ocpDate = jobDisableOptions.OcpDate;
 1606            }
 01607            string ifMatch = default(string);
 01608            if (jobDisableOptions != null)
 1609            {
 01610                ifMatch = jobDisableOptions.IfMatch;
 1611            }
 01612            string ifNoneMatch = default(string);
 01613            if (jobDisableOptions != null)
 1614            {
 01615                ifNoneMatch = jobDisableOptions.IfNoneMatch;
 1616            }
 01617            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01618            if (jobDisableOptions != null)
 1619            {
 01620                ifModifiedSince = jobDisableOptions.IfModifiedSince;
 1621            }
 01622            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01623            if (jobDisableOptions != null)
 1624            {
 01625                ifUnmodifiedSince = jobDisableOptions.IfUnmodifiedSince;
 1626            }
 01627            JobDisableParameter jobDisableParameter = new JobDisableParameter();
 01628            jobDisableParameter.DisableTasks = disableTasks;
 1629            // Tracing
 01630            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01631            string _invocationId = null;
 01632            if (_shouldTrace)
 1633            {
 01634                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01635                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01636                tracingParameters.Add("jobId", jobId);
 01637                tracingParameters.Add("timeout", timeout);
 01638                tracingParameters.Add("clientRequestId", clientRequestId);
 01639                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01640                tracingParameters.Add("ocpDate", ocpDate);
 01641                tracingParameters.Add("ifMatch", ifMatch);
 01642                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01643                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01644                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01645                tracingParameters.Add("jobDisableParameter", jobDisableParameter);
 01646                tracingParameters.Add("cancellationToken", cancellationToken);
 01647                ServiceClientTracing.Enter(_invocationId, this, "Disable", tracingParameters);
 1648            }
 1649            // Construct URL
 01650            var _baseUrl = Client.BaseUri;
 01651            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/disable";
 01652            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01653            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 01654            List<string> _queryParameters = new List<string>();
 01655            if (Client.ApiVersion != null)
 1656            {
 01657                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1658            }
 01659            if (timeout != null)
 1660            {
 01661                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1662            }
 01663            if (_queryParameters.Count > 0)
 1664            {
 01665                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1666            }
 1667            // Create HTTP transport objects
 01668            var _httpRequest = new HttpRequestMessage();
 01669            HttpResponseMessage _httpResponse = null;
 01670            _httpRequest.Method = new HttpMethod("POST");
 01671            _httpRequest.RequestUri = new System.Uri(_url);
 1672            // Set Headers
 01673            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1674            {
 01675                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1676            }
 01677            if (Client.AcceptLanguage != null)
 1678            {
 01679                if (_httpRequest.Headers.Contains("accept-language"))
 1680                {
 01681                    _httpRequest.Headers.Remove("accept-language");
 1682                }
 01683                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1684            }
 01685            if (clientRequestId != null)
 1686            {
 01687                if (_httpRequest.Headers.Contains("client-request-id"))
 1688                {
 01689                    _httpRequest.Headers.Remove("client-request-id");
 1690                }
 01691                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1692            }
 01693            if (returnClientRequestId != null)
 1694            {
 01695                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1696                {
 01697                    _httpRequest.Headers.Remove("return-client-request-id");
 1698                }
 01699                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1700            }
 01701            if (ocpDate != null)
 1702            {
 01703                if (_httpRequest.Headers.Contains("ocp-date"))
 1704                {
 01705                    _httpRequest.Headers.Remove("ocp-date");
 1706                }
 01707                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1708            }
 01709            if (ifMatch != null)
 1710            {
 01711                if (_httpRequest.Headers.Contains("If-Match"))
 1712                {
 01713                    _httpRequest.Headers.Remove("If-Match");
 1714                }
 01715                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1716            }
 01717            if (ifNoneMatch != null)
 1718            {
 01719                if (_httpRequest.Headers.Contains("If-None-Match"))
 1720                {
 01721                    _httpRequest.Headers.Remove("If-None-Match");
 1722                }
 01723                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1724            }
 01725            if (ifModifiedSince != null)
 1726            {
 01727                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1728                {
 01729                    _httpRequest.Headers.Remove("If-Modified-Since");
 1730                }
 01731                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1732            }
 01733            if (ifUnmodifiedSince != null)
 1734            {
 01735                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1736                {
 01737                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1738                }
 01739                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1740            }
 1741
 1742
 01743            if (customHeaders != null)
 1744            {
 01745                foreach(var _header in customHeaders)
 1746                {
 01747                    if (_httpRequest.Headers.Contains(_header.Key))
 1748                    {
 01749                        _httpRequest.Headers.Remove(_header.Key);
 1750                    }
 01751                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1752                }
 1753            }
 1754
 1755            // Serialize Request
 01756            string _requestContent = null;
 01757            if(jobDisableParameter != null)
 1758            {
 01759                _requestContent = SafeJsonConvert.SerializeObject(jobDisableParameter, Client.SerializationSettings);
 01760                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01761                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1762            }
 1763            // Set Credentials
 01764            if (Client.Credentials != null)
 1765            {
 01766                cancellationToken.ThrowIfCancellationRequested();
 01767                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1768            }
 1769            // Send Request
 01770            if (_shouldTrace)
 1771            {
 01772                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1773            }
 01774            cancellationToken.ThrowIfCancellationRequested();
 01775            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01776            if (_shouldTrace)
 1777            {
 01778                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1779            }
 01780            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01781            cancellationToken.ThrowIfCancellationRequested();
 01782            string _responseContent = null;
 01783            if ((int)_statusCode != 202)
 1784            {
 01785                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1786                try
 1787                {
 01788                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01789                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01790                    if (_errorBody != null)
 1791                    {
 01792                        ex.Body = _errorBody;
 1793                    }
 01794                }
 01795                catch (JsonException)
 1796                {
 1797                    // Ignore the exception
 01798                }
 01799                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01800                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01801                if (_shouldTrace)
 1802                {
 01803                    ServiceClientTracing.Error(_invocationId, ex);
 1804                }
 01805                _httpRequest.Dispose();
 01806                if (_httpResponse != null)
 1807                {
 01808                    _httpResponse.Dispose();
 1809                }
 01810                throw ex;
 1811            }
 1812            // Create Result
 01813            var _result = new AzureOperationHeaderResponse<JobDisableHeaders>();
 01814            _result.Request = _httpRequest;
 01815            _result.Response = _httpResponse;
 01816            if (_httpResponse.Headers.Contains("request-id"))
 1817            {
 01818                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1819            }
 1820            try
 1821            {
 01822                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobDisableHeaders>(JsonSerializer.Create(Cli
 01823            }
 01824            catch (JsonException ex)
 1825            {
 01826                _httpRequest.Dispose();
 01827                if (_httpResponse != null)
 1828                {
 01829                    _httpResponse.Dispose();
 1830                }
 01831                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1832            }
 01833            if (_shouldTrace)
 1834            {
 01835                ServiceClientTracing.Exit(_invocationId, _result);
 1836            }
 01837            return _result;
 01838        }
 1839
 1840        /// <summary>
 1841        /// Enables the specified Job, allowing new Tasks to run.
 1842        /// </summary>
 1843        /// <remarks>
 1844        /// When you call this API, the Batch service sets a disabled Job to the
 1845        /// enabling state. After the this operation is completed, the Job moves to the
 1846        /// active state, and scheduling of new Tasks under the Job resumes. The Batch
 1847        /// service does not allow a Task to remain in the active state for more than
 1848        /// 180 days. Therefore, if you enable a Job containing active Tasks which were
 1849        /// added more than 180 days ago, those Tasks will not run.
 1850        /// </remarks>
 1851        /// <param name='jobId'>
 1852        /// The ID of the Job to enable.
 1853        /// </param>
 1854        /// <param name='jobEnableOptions'>
 1855        /// Additional parameters for the operation
 1856        /// </param>
 1857        /// <param name='customHeaders'>
 1858        /// Headers that will be added to request.
 1859        /// </param>
 1860        /// <param name='cancellationToken'>
 1861        /// The cancellation token.
 1862        /// </param>
 1863        /// <exception cref="BatchErrorException">
 1864        /// Thrown when the operation returned an invalid status code
 1865        /// </exception>
 1866        /// <exception cref="ValidationException">
 1867        /// Thrown when a required parameter is null
 1868        /// </exception>
 1869        /// <exception cref="System.ArgumentNullException">
 1870        /// Thrown when a required parameter is null
 1871        /// </exception>
 1872        /// <return>
 1873        /// A response object containing the response body and response headers.
 1874        /// </return>
 1875        public async Task<AzureOperationHeaderResponse<JobEnableHeaders>> EnableWithHttpMessagesAsync(string jobId, JobE
 1876        {
 01877            if (Client.BatchUrl == null)
 1878            {
 01879                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1880            }
 01881            if (jobId == null)
 1882            {
 01883                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 1884            }
 01885            if (Client.ApiVersion == null)
 1886            {
 01887                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1888            }
 01889            int? timeout = default(int?);
 01890            if (jobEnableOptions != null)
 1891            {
 01892                timeout = jobEnableOptions.Timeout;
 1893            }
 01894            System.Guid? clientRequestId = default(System.Guid?);
 01895            if (jobEnableOptions != null)
 1896            {
 01897                clientRequestId = jobEnableOptions.ClientRequestId;
 1898            }
 01899            bool? returnClientRequestId = default(bool?);
 01900            if (jobEnableOptions != null)
 1901            {
 01902                returnClientRequestId = jobEnableOptions.ReturnClientRequestId;
 1903            }
 01904            System.DateTime? ocpDate = default(System.DateTime?);
 01905            if (jobEnableOptions != null)
 1906            {
 01907                ocpDate = jobEnableOptions.OcpDate;
 1908            }
 01909            string ifMatch = default(string);
 01910            if (jobEnableOptions != null)
 1911            {
 01912                ifMatch = jobEnableOptions.IfMatch;
 1913            }
 01914            string ifNoneMatch = default(string);
 01915            if (jobEnableOptions != null)
 1916            {
 01917                ifNoneMatch = jobEnableOptions.IfNoneMatch;
 1918            }
 01919            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01920            if (jobEnableOptions != null)
 1921            {
 01922                ifModifiedSince = jobEnableOptions.IfModifiedSince;
 1923            }
 01924            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01925            if (jobEnableOptions != null)
 1926            {
 01927                ifUnmodifiedSince = jobEnableOptions.IfUnmodifiedSince;
 1928            }
 1929            // Tracing
 01930            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01931            string _invocationId = null;
 01932            if (_shouldTrace)
 1933            {
 01934                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01935                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01936                tracingParameters.Add("jobId", jobId);
 01937                tracingParameters.Add("timeout", timeout);
 01938                tracingParameters.Add("clientRequestId", clientRequestId);
 01939                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01940                tracingParameters.Add("ocpDate", ocpDate);
 01941                tracingParameters.Add("ifMatch", ifMatch);
 01942                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01943                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01944                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01945                tracingParameters.Add("cancellationToken", cancellationToken);
 01946                ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters);
 1947            }
 1948            // Construct URL
 01949            var _baseUrl = Client.BaseUri;
 01950            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/enable";
 01951            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01952            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 01953            List<string> _queryParameters = new List<string>();
 01954            if (Client.ApiVersion != null)
 1955            {
 01956                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1957            }
 01958            if (timeout != null)
 1959            {
 01960                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1961            }
 01962            if (_queryParameters.Count > 0)
 1963            {
 01964                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1965            }
 1966            // Create HTTP transport objects
 01967            var _httpRequest = new HttpRequestMessage();
 01968            HttpResponseMessage _httpResponse = null;
 01969            _httpRequest.Method = new HttpMethod("POST");
 01970            _httpRequest.RequestUri = new System.Uri(_url);
 1971            // Set Headers
 01972            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1973            {
 01974                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1975            }
 01976            if (Client.AcceptLanguage != null)
 1977            {
 01978                if (_httpRequest.Headers.Contains("accept-language"))
 1979                {
 01980                    _httpRequest.Headers.Remove("accept-language");
 1981                }
 01982                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1983            }
 01984            if (clientRequestId != null)
 1985            {
 01986                if (_httpRequest.Headers.Contains("client-request-id"))
 1987                {
 01988                    _httpRequest.Headers.Remove("client-request-id");
 1989                }
 01990                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1991            }
 01992            if (returnClientRequestId != null)
 1993            {
 01994                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1995                {
 01996                    _httpRequest.Headers.Remove("return-client-request-id");
 1997                }
 01998                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1999            }
 02000            if (ocpDate != null)
 2001            {
 02002                if (_httpRequest.Headers.Contains("ocp-date"))
 2003                {
 02004                    _httpRequest.Headers.Remove("ocp-date");
 2005                }
 02006                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2007            }
 02008            if (ifMatch != null)
 2009            {
 02010                if (_httpRequest.Headers.Contains("If-Match"))
 2011                {
 02012                    _httpRequest.Headers.Remove("If-Match");
 2013                }
 02014                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 2015            }
 02016            if (ifNoneMatch != null)
 2017            {
 02018                if (_httpRequest.Headers.Contains("If-None-Match"))
 2019                {
 02020                    _httpRequest.Headers.Remove("If-None-Match");
 2021                }
 02022                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 2023            }
 02024            if (ifModifiedSince != null)
 2025            {
 02026                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 2027                {
 02028                    _httpRequest.Headers.Remove("If-Modified-Since");
 2029                }
 02030                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 2031            }
 02032            if (ifUnmodifiedSince != null)
 2033            {
 02034                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 2035                {
 02036                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 2037                }
 02038                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 2039            }
 2040
 2041
 02042            if (customHeaders != null)
 2043            {
 02044                foreach(var _header in customHeaders)
 2045                {
 02046                    if (_httpRequest.Headers.Contains(_header.Key))
 2047                    {
 02048                        _httpRequest.Headers.Remove(_header.Key);
 2049                    }
 02050                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2051                }
 2052            }
 2053
 2054            // Serialize Request
 02055            string _requestContent = null;
 2056            // Set Credentials
 02057            if (Client.Credentials != null)
 2058            {
 02059                cancellationToken.ThrowIfCancellationRequested();
 02060                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2061            }
 2062            // Send Request
 02063            if (_shouldTrace)
 2064            {
 02065                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2066            }
 02067            cancellationToken.ThrowIfCancellationRequested();
 02068            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02069            if (_shouldTrace)
 2070            {
 02071                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2072            }
 02073            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02074            cancellationToken.ThrowIfCancellationRequested();
 02075            string _responseContent = null;
 02076            if ((int)_statusCode != 202)
 2077            {
 02078                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2079                try
 2080                {
 02081                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02082                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02083                    if (_errorBody != null)
 2084                    {
 02085                        ex.Body = _errorBody;
 2086                    }
 02087                }
 02088                catch (JsonException)
 2089                {
 2090                    // Ignore the exception
 02091                }
 02092                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02093                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02094                if (_shouldTrace)
 2095                {
 02096                    ServiceClientTracing.Error(_invocationId, ex);
 2097                }
 02098                _httpRequest.Dispose();
 02099                if (_httpResponse != null)
 2100                {
 02101                    _httpResponse.Dispose();
 2102                }
 02103                throw ex;
 2104            }
 2105            // Create Result
 02106            var _result = new AzureOperationHeaderResponse<JobEnableHeaders>();
 02107            _result.Request = _httpRequest;
 02108            _result.Response = _httpResponse;
 02109            if (_httpResponse.Headers.Contains("request-id"))
 2110            {
 02111                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2112            }
 2113            try
 2114            {
 02115                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobEnableHeaders>(JsonSerializer.Create(Clie
 02116            }
 02117            catch (JsonException ex)
 2118            {
 02119                _httpRequest.Dispose();
 02120                if (_httpResponse != null)
 2121                {
 02122                    _httpResponse.Dispose();
 2123                }
 02124                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2125            }
 02126            if (_shouldTrace)
 2127            {
 02128                ServiceClientTracing.Exit(_invocationId, _result);
 2129            }
 02130            return _result;
 02131        }
 2132
 2133        /// <summary>
 2134        /// Terminates the specified Job, marking it as completed.
 2135        /// </summary>
 2136        /// <remarks>
 2137        /// When a Terminate Job request is received, the Batch service sets the Job to
 2138        /// the terminating state. The Batch service then terminates any running Tasks
 2139        /// associated with the Job and runs any required Job release Tasks. Then the
 2140        /// Job moves into the completed state. If there are any Tasks in the Job in
 2141        /// the active state, they will remain in the active state. Once a Job is
 2142        /// terminated, new Tasks cannot be added and any remaining active Tasks will
 2143        /// not be scheduled.
 2144        /// </remarks>
 2145        /// <param name='jobId'>
 2146        /// The ID of the Job to terminate.
 2147        /// </param>
 2148        /// <param name='terminateReason'>
 2149        /// The text you want to appear as the Job's TerminateReason. The default is
 2150        /// 'UserTerminate'.
 2151        /// </param>
 2152        /// <param name='jobTerminateOptions'>
 2153        /// Additional parameters for the operation
 2154        /// </param>
 2155        /// <param name='customHeaders'>
 2156        /// Headers that will be added to request.
 2157        /// </param>
 2158        /// <param name='cancellationToken'>
 2159        /// The cancellation token.
 2160        /// </param>
 2161        /// <exception cref="BatchErrorException">
 2162        /// Thrown when the operation returned an invalid status code
 2163        /// </exception>
 2164        /// <exception cref="ValidationException">
 2165        /// Thrown when a required parameter is null
 2166        /// </exception>
 2167        /// <exception cref="System.ArgumentNullException">
 2168        /// Thrown when a required parameter is null
 2169        /// </exception>
 2170        /// <return>
 2171        /// A response object containing the response body and response headers.
 2172        /// </return>
 2173        public async Task<AzureOperationHeaderResponse<JobTerminateHeaders>> TerminateWithHttpMessagesAsync(string jobId
 2174        {
 02175            if (Client.BatchUrl == null)
 2176            {
 02177                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2178            }
 02179            if (jobId == null)
 2180            {
 02181                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 2182            }
 02183            if (Client.ApiVersion == null)
 2184            {
 02185                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2186            }
 02187            int? timeout = default(int?);
 02188            if (jobTerminateOptions != null)
 2189            {
 02190                timeout = jobTerminateOptions.Timeout;
 2191            }
 02192            System.Guid? clientRequestId = default(System.Guid?);
 02193            if (jobTerminateOptions != null)
 2194            {
 02195                clientRequestId = jobTerminateOptions.ClientRequestId;
 2196            }
 02197            bool? returnClientRequestId = default(bool?);
 02198            if (jobTerminateOptions != null)
 2199            {
 02200                returnClientRequestId = jobTerminateOptions.ReturnClientRequestId;
 2201            }
 02202            System.DateTime? ocpDate = default(System.DateTime?);
 02203            if (jobTerminateOptions != null)
 2204            {
 02205                ocpDate = jobTerminateOptions.OcpDate;
 2206            }
 02207            string ifMatch = default(string);
 02208            if (jobTerminateOptions != null)
 2209            {
 02210                ifMatch = jobTerminateOptions.IfMatch;
 2211            }
 02212            string ifNoneMatch = default(string);
 02213            if (jobTerminateOptions != null)
 2214            {
 02215                ifNoneMatch = jobTerminateOptions.IfNoneMatch;
 2216            }
 02217            System.DateTime? ifModifiedSince = default(System.DateTime?);
 02218            if (jobTerminateOptions != null)
 2219            {
 02220                ifModifiedSince = jobTerminateOptions.IfModifiedSince;
 2221            }
 02222            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 02223            if (jobTerminateOptions != null)
 2224            {
 02225                ifUnmodifiedSince = jobTerminateOptions.IfUnmodifiedSince;
 2226            }
 02227            JobTerminateParameter jobTerminateParameter = default(JobTerminateParameter);
 02228            if (terminateReason != null)
 2229            {
 02230                jobTerminateParameter = new JobTerminateParameter();
 02231                jobTerminateParameter.TerminateReason = terminateReason;
 2232            }
 2233            // Tracing
 02234            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02235            string _invocationId = null;
 02236            if (_shouldTrace)
 2237            {
 02238                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02239                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02240                tracingParameters.Add("jobId", jobId);
 02241                tracingParameters.Add("timeout", timeout);
 02242                tracingParameters.Add("clientRequestId", clientRequestId);
 02243                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02244                tracingParameters.Add("ocpDate", ocpDate);
 02245                tracingParameters.Add("ifMatch", ifMatch);
 02246                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 02247                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 02248                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 02249                tracingParameters.Add("jobTerminateParameter", jobTerminateParameter);
 02250                tracingParameters.Add("cancellationToken", cancellationToken);
 02251                ServiceClientTracing.Enter(_invocationId, this, "Terminate", tracingParameters);
 2252            }
 2253            // Construct URL
 02254            var _baseUrl = Client.BaseUri;
 02255            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/terminate";
 02256            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02257            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 02258            List<string> _queryParameters = new List<string>();
 02259            if (Client.ApiVersion != null)
 2260            {
 02261                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2262            }
 02263            if (timeout != null)
 2264            {
 02265                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2266            }
 02267            if (_queryParameters.Count > 0)
 2268            {
 02269                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2270            }
 2271            // Create HTTP transport objects
 02272            var _httpRequest = new HttpRequestMessage();
 02273            HttpResponseMessage _httpResponse = null;
 02274            _httpRequest.Method = new HttpMethod("POST");
 02275            _httpRequest.RequestUri = new System.Uri(_url);
 2276            // Set Headers
 02277            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2278            {
 02279                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2280            }
 02281            if (Client.AcceptLanguage != null)
 2282            {
 02283                if (_httpRequest.Headers.Contains("accept-language"))
 2284                {
 02285                    _httpRequest.Headers.Remove("accept-language");
 2286                }
 02287                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2288            }
 02289            if (clientRequestId != null)
 2290            {
 02291                if (_httpRequest.Headers.Contains("client-request-id"))
 2292                {
 02293                    _httpRequest.Headers.Remove("client-request-id");
 2294                }
 02295                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2296            }
 02297            if (returnClientRequestId != null)
 2298            {
 02299                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2300                {
 02301                    _httpRequest.Headers.Remove("return-client-request-id");
 2302                }
 02303                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2304            }
 02305            if (ocpDate != null)
 2306            {
 02307                if (_httpRequest.Headers.Contains("ocp-date"))
 2308                {
 02309                    _httpRequest.Headers.Remove("ocp-date");
 2310                }
 02311                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2312            }
 02313            if (ifMatch != null)
 2314            {
 02315                if (_httpRequest.Headers.Contains("If-Match"))
 2316                {
 02317                    _httpRequest.Headers.Remove("If-Match");
 2318                }
 02319                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 2320            }
 02321            if (ifNoneMatch != null)
 2322            {
 02323                if (_httpRequest.Headers.Contains("If-None-Match"))
 2324                {
 02325                    _httpRequest.Headers.Remove("If-None-Match");
 2326                }
 02327                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 2328            }
 02329            if (ifModifiedSince != null)
 2330            {
 02331                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 2332                {
 02333                    _httpRequest.Headers.Remove("If-Modified-Since");
 2334                }
 02335                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 2336            }
 02337            if (ifUnmodifiedSince != null)
 2338            {
 02339                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 2340                {
 02341                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 2342                }
 02343                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 2344            }
 2345
 2346
 02347            if (customHeaders != null)
 2348            {
 02349                foreach(var _header in customHeaders)
 2350                {
 02351                    if (_httpRequest.Headers.Contains(_header.Key))
 2352                    {
 02353                        _httpRequest.Headers.Remove(_header.Key);
 2354                    }
 02355                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2356                }
 2357            }
 2358
 2359            // Serialize Request
 02360            string _requestContent = null;
 02361            if(jobTerminateParameter != null)
 2362            {
 02363                _requestContent = SafeJsonConvert.SerializeObject(jobTerminateParameter, Client.SerializationSettings);
 02364                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 02365                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2366            }
 2367            // Set Credentials
 02368            if (Client.Credentials != null)
 2369            {
 02370                cancellationToken.ThrowIfCancellationRequested();
 02371                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2372            }
 2373            // Send Request
 02374            if (_shouldTrace)
 2375            {
 02376                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2377            }
 02378            cancellationToken.ThrowIfCancellationRequested();
 02379            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02380            if (_shouldTrace)
 2381            {
 02382                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2383            }
 02384            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02385            cancellationToken.ThrowIfCancellationRequested();
 02386            string _responseContent = null;
 02387            if ((int)_statusCode != 202)
 2388            {
 02389                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2390                try
 2391                {
 02392                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02393                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02394                    if (_errorBody != null)
 2395                    {
 02396                        ex.Body = _errorBody;
 2397                    }
 02398                }
 02399                catch (JsonException)
 2400                {
 2401                    // Ignore the exception
 02402                }
 02403                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02404                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02405                if (_shouldTrace)
 2406                {
 02407                    ServiceClientTracing.Error(_invocationId, ex);
 2408                }
 02409                _httpRequest.Dispose();
 02410                if (_httpResponse != null)
 2411                {
 02412                    _httpResponse.Dispose();
 2413                }
 02414                throw ex;
 2415            }
 2416            // Create Result
 02417            var _result = new AzureOperationHeaderResponse<JobTerminateHeaders>();
 02418            _result.Request = _httpRequest;
 02419            _result.Response = _httpResponse;
 02420            if (_httpResponse.Headers.Contains("request-id"))
 2421            {
 02422                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2423            }
 2424            try
 2425            {
 02426                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobTerminateHeaders>(JsonSerializer.Create(C
 02427            }
 02428            catch (JsonException ex)
 2429            {
 02430                _httpRequest.Dispose();
 02431                if (_httpResponse != null)
 2432                {
 02433                    _httpResponse.Dispose();
 2434                }
 02435                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2436            }
 02437            if (_shouldTrace)
 2438            {
 02439                ServiceClientTracing.Exit(_invocationId, _result);
 2440            }
 02441            return _result;
 02442        }
 2443
 2444        /// <summary>
 2445        /// Adds a Job to the specified Account.
 2446        /// </summary>
 2447        /// <remarks>
 2448        /// The Batch service supports two ways to control the work done as part of a
 2449        /// Job. In the first approach, the user specifies a Job Manager Task. The
 2450        /// Batch service launches this Task when it is ready to start the Job. The Job
 2451        /// Manager Task controls all other Tasks that run under this Job, by using the
 2452        /// Task APIs. In the second approach, the user directly controls the execution
 2453        /// of Tasks under an active Job, by using the Task APIs. Also note: when
 2454        /// naming Jobs, avoid including sensitive information such as user names or
 2455        /// secret project names. This information may appear in telemetry logs
 2456        /// accessible to Microsoft Support engineers.
 2457        /// </remarks>
 2458        /// <param name='job'>
 2459        /// The Job to be added.
 2460        /// </param>
 2461        /// <param name='jobAddOptions'>
 2462        /// Additional parameters for the operation
 2463        /// </param>
 2464        /// <param name='customHeaders'>
 2465        /// Headers that will be added to request.
 2466        /// </param>
 2467        /// <param name='cancellationToken'>
 2468        /// The cancellation token.
 2469        /// </param>
 2470        /// <exception cref="BatchErrorException">
 2471        /// Thrown when the operation returned an invalid status code
 2472        /// </exception>
 2473        /// <exception cref="ValidationException">
 2474        /// Thrown when a required parameter is null
 2475        /// </exception>
 2476        /// <exception cref="System.ArgumentNullException">
 2477        /// Thrown when a required parameter is null
 2478        /// </exception>
 2479        /// <return>
 2480        /// A response object containing the response body and response headers.
 2481        /// </return>
 2482        public async Task<AzureOperationHeaderResponse<JobAddHeaders>> AddWithHttpMessagesAsync(JobAddParameter job, Job
 2483        {
 02484            if (Client.BatchUrl == null)
 2485            {
 02486                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2487            }
 02488            if (job == null)
 2489            {
 02490                throw new ValidationException(ValidationRules.CannotBeNull, "job");
 2491            }
 02492            if (Client.ApiVersion == null)
 2493            {
 02494                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2495            }
 02496            int? timeout = default(int?);
 02497            if (jobAddOptions != null)
 2498            {
 02499                timeout = jobAddOptions.Timeout;
 2500            }
 02501            System.Guid? clientRequestId = default(System.Guid?);
 02502            if (jobAddOptions != null)
 2503            {
 02504                clientRequestId = jobAddOptions.ClientRequestId;
 2505            }
 02506            bool? returnClientRequestId = default(bool?);
 02507            if (jobAddOptions != null)
 2508            {
 02509                returnClientRequestId = jobAddOptions.ReturnClientRequestId;
 2510            }
 02511            System.DateTime? ocpDate = default(System.DateTime?);
 02512            if (jobAddOptions != null)
 2513            {
 02514                ocpDate = jobAddOptions.OcpDate;
 2515            }
 2516            // Tracing
 02517            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02518            string _invocationId = null;
 02519            if (_shouldTrace)
 2520            {
 02521                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02522                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02523                tracingParameters.Add("job", job);
 02524                tracingParameters.Add("timeout", timeout);
 02525                tracingParameters.Add("clientRequestId", clientRequestId);
 02526                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02527                tracingParameters.Add("ocpDate", ocpDate);
 02528                tracingParameters.Add("cancellationToken", cancellationToken);
 02529                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 2530            }
 2531            // Construct URL
 02532            var _baseUrl = Client.BaseUri;
 02533            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs";
 02534            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02535            List<string> _queryParameters = new List<string>();
 02536            if (Client.ApiVersion != null)
 2537            {
 02538                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2539            }
 02540            if (timeout != null)
 2541            {
 02542                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2543            }
 02544            if (_queryParameters.Count > 0)
 2545            {
 02546                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2547            }
 2548            // Create HTTP transport objects
 02549            var _httpRequest = new HttpRequestMessage();
 02550            HttpResponseMessage _httpResponse = null;
 02551            _httpRequest.Method = new HttpMethod("POST");
 02552            _httpRequest.RequestUri = new System.Uri(_url);
 2553            // Set Headers
 02554            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2555            {
 02556                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2557            }
 02558            if (Client.AcceptLanguage != null)
 2559            {
 02560                if (_httpRequest.Headers.Contains("accept-language"))
 2561                {
 02562                    _httpRequest.Headers.Remove("accept-language");
 2563                }
 02564                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2565            }
 02566            if (clientRequestId != null)
 2567            {
 02568                if (_httpRequest.Headers.Contains("client-request-id"))
 2569                {
 02570                    _httpRequest.Headers.Remove("client-request-id");
 2571                }
 02572                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2573            }
 02574            if (returnClientRequestId != null)
 2575            {
 02576                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2577                {
 02578                    _httpRequest.Headers.Remove("return-client-request-id");
 2579                }
 02580                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2581            }
 02582            if (ocpDate != null)
 2583            {
 02584                if (_httpRequest.Headers.Contains("ocp-date"))
 2585                {
 02586                    _httpRequest.Headers.Remove("ocp-date");
 2587                }
 02588                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2589            }
 2590
 2591
 02592            if (customHeaders != null)
 2593            {
 02594                foreach(var _header in customHeaders)
 2595                {
 02596                    if (_httpRequest.Headers.Contains(_header.Key))
 2597                    {
 02598                        _httpRequest.Headers.Remove(_header.Key);
 2599                    }
 02600                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2601                }
 2602            }
 2603
 2604            // Serialize Request
 02605            string _requestContent = null;
 02606            if(job != null)
 2607            {
 02608                _requestContent = SafeJsonConvert.SerializeObject(job, Client.SerializationSettings);
 02609                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 02610                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2611            }
 2612            // Set Credentials
 02613            if (Client.Credentials != null)
 2614            {
 02615                cancellationToken.ThrowIfCancellationRequested();
 02616                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2617            }
 2618            // Send Request
 02619            if (_shouldTrace)
 2620            {
 02621                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2622            }
 02623            cancellationToken.ThrowIfCancellationRequested();
 02624            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02625            if (_shouldTrace)
 2626            {
 02627                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2628            }
 02629            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02630            cancellationToken.ThrowIfCancellationRequested();
 02631            string _responseContent = null;
 02632            if ((int)_statusCode != 201)
 2633            {
 02634                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2635                try
 2636                {
 02637                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02638                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02639                    if (_errorBody != null)
 2640                    {
 02641                        ex.Body = _errorBody;
 2642                    }
 02643                }
 02644                catch (JsonException)
 2645                {
 2646                    // Ignore the exception
 02647                }
 02648                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02649                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02650                if (_shouldTrace)
 2651                {
 02652                    ServiceClientTracing.Error(_invocationId, ex);
 2653                }
 02654                _httpRequest.Dispose();
 02655                if (_httpResponse != null)
 2656                {
 02657                    _httpResponse.Dispose();
 2658                }
 02659                throw ex;
 2660            }
 2661            // Create Result
 02662            var _result = new AzureOperationHeaderResponse<JobAddHeaders>();
 02663            _result.Request = _httpRequest;
 02664            _result.Response = _httpResponse;
 02665            if (_httpResponse.Headers.Contains("request-id"))
 2666            {
 02667                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2668            }
 2669            try
 2670            {
 02671                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobAddHeaders>(JsonSerializer.Create(Client.
 02672            }
 02673            catch (JsonException ex)
 2674            {
 02675                _httpRequest.Dispose();
 02676                if (_httpResponse != null)
 2677                {
 02678                    _httpResponse.Dispose();
 2679                }
 02680                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2681            }
 02682            if (_shouldTrace)
 2683            {
 02684                ServiceClientTracing.Exit(_invocationId, _result);
 2685            }
 02686            return _result;
 02687        }
 2688
 2689        /// <summary>
 2690        /// Lists all of the Jobs in the specified Account.
 2691        /// </summary>
 2692        /// <param name='jobListOptions'>
 2693        /// Additional parameters for the operation
 2694        /// </param>
 2695        /// <param name='customHeaders'>
 2696        /// Headers that will be added to request.
 2697        /// </param>
 2698        /// <param name='cancellationToken'>
 2699        /// The cancellation token.
 2700        /// </param>
 2701        /// <exception cref="BatchErrorException">
 2702        /// Thrown when the operation returned an invalid status code
 2703        /// </exception>
 2704        /// <exception cref="SerializationException">
 2705        /// Thrown when unable to deserialize the response
 2706        /// </exception>
 2707        /// <exception cref="ValidationException">
 2708        /// Thrown when a required parameter is null
 2709        /// </exception>
 2710        /// <exception cref="System.ArgumentNullException">
 2711        /// Thrown when a required parameter is null
 2712        /// </exception>
 2713        /// <return>
 2714        /// A response object containing the response body and response headers.
 2715        /// </return>
 2716        public async Task<AzureOperationResponse<IPage<CloudJob>,JobListHeaders>> ListWithHttpMessagesAsync(JobListOptio
 2717        {
 02718            if (Client.BatchUrl == null)
 2719            {
 02720                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2721            }
 02722            if (Client.ApiVersion == null)
 2723            {
 02724                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2725            }
 02726            string filter = default(string);
 02727            if (jobListOptions != null)
 2728            {
 02729                filter = jobListOptions.Filter;
 2730            }
 02731            string select = default(string);
 02732            if (jobListOptions != null)
 2733            {
 02734                select = jobListOptions.Select;
 2735            }
 02736            string expand = default(string);
 02737            if (jobListOptions != null)
 2738            {
 02739                expand = jobListOptions.Expand;
 2740            }
 02741            int? maxResults = default(int?);
 02742            if (jobListOptions != null)
 2743            {
 02744                maxResults = jobListOptions.MaxResults;
 2745            }
 02746            int? timeout = default(int?);
 02747            if (jobListOptions != null)
 2748            {
 02749                timeout = jobListOptions.Timeout;
 2750            }
 02751            System.Guid? clientRequestId = default(System.Guid?);
 02752            if (jobListOptions != null)
 2753            {
 02754                clientRequestId = jobListOptions.ClientRequestId;
 2755            }
 02756            bool? returnClientRequestId = default(bool?);
 02757            if (jobListOptions != null)
 2758            {
 02759                returnClientRequestId = jobListOptions.ReturnClientRequestId;
 2760            }
 02761            System.DateTime? ocpDate = default(System.DateTime?);
 02762            if (jobListOptions != null)
 2763            {
 02764                ocpDate = jobListOptions.OcpDate;
 2765            }
 2766            // Tracing
 02767            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02768            string _invocationId = null;
 02769            if (_shouldTrace)
 2770            {
 02771                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02772                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02773                tracingParameters.Add("filter", filter);
 02774                tracingParameters.Add("select", select);
 02775                tracingParameters.Add("expand", expand);
 02776                tracingParameters.Add("maxResults", maxResults);
 02777                tracingParameters.Add("timeout", timeout);
 02778                tracingParameters.Add("clientRequestId", clientRequestId);
 02779                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02780                tracingParameters.Add("ocpDate", ocpDate);
 02781                tracingParameters.Add("cancellationToken", cancellationToken);
 02782                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 2783            }
 2784            // Construct URL
 02785            var _baseUrl = Client.BaseUri;
 02786            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs";
 02787            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02788            List<string> _queryParameters = new List<string>();
 02789            if (Client.ApiVersion != null)
 2790            {
 02791                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2792            }
 02793            if (filter != null)
 2794            {
 02795                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 2796            }
 02797            if (select != null)
 2798            {
 02799                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 2800            }
 02801            if (expand != null)
 2802            {
 02803                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
 2804            }
 02805            if (maxResults != null)
 2806            {
 02807                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 2808            }
 02809            if (timeout != null)
 2810            {
 02811                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2812            }
 02813            if (_queryParameters.Count > 0)
 2814            {
 02815                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2816            }
 2817            // Create HTTP transport objects
 02818            var _httpRequest = new HttpRequestMessage();
 02819            HttpResponseMessage _httpResponse = null;
 02820            _httpRequest.Method = new HttpMethod("GET");
 02821            _httpRequest.RequestUri = new System.Uri(_url);
 2822            // Set Headers
 02823            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2824            {
 02825                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2826            }
 02827            if (Client.AcceptLanguage != null)
 2828            {
 02829                if (_httpRequest.Headers.Contains("accept-language"))
 2830                {
 02831                    _httpRequest.Headers.Remove("accept-language");
 2832                }
 02833                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2834            }
 02835            if (clientRequestId != null)
 2836            {
 02837                if (_httpRequest.Headers.Contains("client-request-id"))
 2838                {
 02839                    _httpRequest.Headers.Remove("client-request-id");
 2840                }
 02841                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2842            }
 02843            if (returnClientRequestId != null)
 2844            {
 02845                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2846                {
 02847                    _httpRequest.Headers.Remove("return-client-request-id");
 2848                }
 02849                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2850            }
 02851            if (ocpDate != null)
 2852            {
 02853                if (_httpRequest.Headers.Contains("ocp-date"))
 2854                {
 02855                    _httpRequest.Headers.Remove("ocp-date");
 2856                }
 02857                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2858            }
 2859
 2860
 02861            if (customHeaders != null)
 2862            {
 02863                foreach(var _header in customHeaders)
 2864                {
 02865                    if (_httpRequest.Headers.Contains(_header.Key))
 2866                    {
 02867                        _httpRequest.Headers.Remove(_header.Key);
 2868                    }
 02869                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2870                }
 2871            }
 2872
 2873            // Serialize Request
 02874            string _requestContent = null;
 2875            // Set Credentials
 02876            if (Client.Credentials != null)
 2877            {
 02878                cancellationToken.ThrowIfCancellationRequested();
 02879                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2880            }
 2881            // Send Request
 02882            if (_shouldTrace)
 2883            {
 02884                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2885            }
 02886            cancellationToken.ThrowIfCancellationRequested();
 02887            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02888            if (_shouldTrace)
 2889            {
 02890                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2891            }
 02892            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02893            cancellationToken.ThrowIfCancellationRequested();
 02894            string _responseContent = null;
 02895            if ((int)_statusCode != 200)
 2896            {
 02897                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2898                try
 2899                {
 02900                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02901                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02902                    if (_errorBody != null)
 2903                    {
 02904                        ex.Body = _errorBody;
 2905                    }
 02906                }
 02907                catch (JsonException)
 2908                {
 2909                    // Ignore the exception
 02910                }
 02911                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02912                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02913                if (_shouldTrace)
 2914                {
 02915                    ServiceClientTracing.Error(_invocationId, ex);
 2916                }
 02917                _httpRequest.Dispose();
 02918                if (_httpResponse != null)
 2919                {
 02920                    _httpResponse.Dispose();
 2921                }
 02922                throw ex;
 2923            }
 2924            // Create Result
 02925            var _result = new AzureOperationResponse<IPage<CloudJob>,JobListHeaders>();
 02926            _result.Request = _httpRequest;
 02927            _result.Response = _httpResponse;
 02928            if (_httpResponse.Headers.Contains("request-id"))
 2929            {
 02930                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2931            }
 2932            // Deserialize Response
 02933            if ((int)_statusCode == 200)
 2934            {
 02935                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2936                try
 2937                {
 02938                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJob>>(_responseContent, Client.Deserializ
 02939                }
 02940                catch (JsonException ex)
 2941                {
 02942                    _httpRequest.Dispose();
 02943                    if (_httpResponse != null)
 2944                    {
 02945                        _httpResponse.Dispose();
 2946                    }
 02947                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2948                }
 2949            }
 2950            try
 2951            {
 02952                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListHeaders>(JsonSerializer.Create(Client
 02953            }
 02954            catch (JsonException ex)
 2955            {
 02956                _httpRequest.Dispose();
 02957                if (_httpResponse != null)
 2958                {
 02959                    _httpResponse.Dispose();
 2960                }
 02961                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2962            }
 02963            if (_shouldTrace)
 2964            {
 02965                ServiceClientTracing.Exit(_invocationId, _result);
 2966            }
 02967            return _result;
 02968        }
 2969
 2970        /// <summary>
 2971        /// Lists the Jobs that have been created under the specified Job Schedule.
 2972        /// </summary>
 2973        /// <param name='jobScheduleId'>
 2974        /// The ID of the Job Schedule from which you want to get a list of Jobs.
 2975        /// </param>
 2976        /// <param name='jobListFromJobScheduleOptions'>
 2977        /// Additional parameters for the operation
 2978        /// </param>
 2979        /// <param name='customHeaders'>
 2980        /// Headers that will be added to request.
 2981        /// </param>
 2982        /// <param name='cancellationToken'>
 2983        /// The cancellation token.
 2984        /// </param>
 2985        /// <exception cref="BatchErrorException">
 2986        /// Thrown when the operation returned an invalid status code
 2987        /// </exception>
 2988        /// <exception cref="SerializationException">
 2989        /// Thrown when unable to deserialize the response
 2990        /// </exception>
 2991        /// <exception cref="ValidationException">
 2992        /// Thrown when a required parameter is null
 2993        /// </exception>
 2994        /// <exception cref="System.ArgumentNullException">
 2995        /// Thrown when a required parameter is null
 2996        /// </exception>
 2997        /// <return>
 2998        /// A response object containing the response body and response headers.
 2999        /// </return>
 3000        public async Task<AzureOperationResponse<IPage<CloudJob>,JobListFromJobScheduleHeaders>> ListFromJobScheduleWith
 3001        {
 03002            if (Client.BatchUrl == null)
 3003            {
 03004                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 3005            }
 03006            if (jobScheduleId == null)
 3007            {
 03008                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 3009            }
 03010            if (Client.ApiVersion == null)
 3011            {
 03012                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 3013            }
 03014            string filter = default(string);
 03015            if (jobListFromJobScheduleOptions != null)
 3016            {
 03017                filter = jobListFromJobScheduleOptions.Filter;
 3018            }
 03019            string select = default(string);
 03020            if (jobListFromJobScheduleOptions != null)
 3021            {
 03022                select = jobListFromJobScheduleOptions.Select;
 3023            }
 03024            string expand = default(string);
 03025            if (jobListFromJobScheduleOptions != null)
 3026            {
 03027                expand = jobListFromJobScheduleOptions.Expand;
 3028            }
 03029            int? maxResults = default(int?);
 03030            if (jobListFromJobScheduleOptions != null)
 3031            {
 03032                maxResults = jobListFromJobScheduleOptions.MaxResults;
 3033            }
 03034            int? timeout = default(int?);
 03035            if (jobListFromJobScheduleOptions != null)
 3036            {
 03037                timeout = jobListFromJobScheduleOptions.Timeout;
 3038            }
 03039            System.Guid? clientRequestId = default(System.Guid?);
 03040            if (jobListFromJobScheduleOptions != null)
 3041            {
 03042                clientRequestId = jobListFromJobScheduleOptions.ClientRequestId;
 3043            }
 03044            bool? returnClientRequestId = default(bool?);
 03045            if (jobListFromJobScheduleOptions != null)
 3046            {
 03047                returnClientRequestId = jobListFromJobScheduleOptions.ReturnClientRequestId;
 3048            }
 03049            System.DateTime? ocpDate = default(System.DateTime?);
 03050            if (jobListFromJobScheduleOptions != null)
 3051            {
 03052                ocpDate = jobListFromJobScheduleOptions.OcpDate;
 3053            }
 3054            // Tracing
 03055            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03056            string _invocationId = null;
 03057            if (_shouldTrace)
 3058            {
 03059                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03060                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03061                tracingParameters.Add("jobScheduleId", jobScheduleId);
 03062                tracingParameters.Add("filter", filter);
 03063                tracingParameters.Add("select", select);
 03064                tracingParameters.Add("expand", expand);
 03065                tracingParameters.Add("maxResults", maxResults);
 03066                tracingParameters.Add("timeout", timeout);
 03067                tracingParameters.Add("clientRequestId", clientRequestId);
 03068                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03069                tracingParameters.Add("ocpDate", ocpDate);
 03070                tracingParameters.Add("cancellationToken", cancellationToken);
 03071                ServiceClientTracing.Enter(_invocationId, this, "ListFromJobSchedule", tracingParameters);
 3072            }
 3073            // Construct URL
 03074            var _baseUrl = Client.BaseUri;
 03075            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/jobs";
 03076            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 03077            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 03078            List<string> _queryParameters = new List<string>();
 03079            if (Client.ApiVersion != null)
 3080            {
 03081                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 3082            }
 03083            if (filter != null)
 3084            {
 03085                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 3086            }
 03087            if (select != null)
 3088            {
 03089                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 3090            }
 03091            if (expand != null)
 3092            {
 03093                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
 3094            }
 03095            if (maxResults != null)
 3096            {
 03097                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 3098            }
 03099            if (timeout != null)
 3100            {
 03101                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 3102            }
 03103            if (_queryParameters.Count > 0)
 3104            {
 03105                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3106            }
 3107            // Create HTTP transport objects
 03108            var _httpRequest = new HttpRequestMessage();
 03109            HttpResponseMessage _httpResponse = null;
 03110            _httpRequest.Method = new HttpMethod("GET");
 03111            _httpRequest.RequestUri = new System.Uri(_url);
 3112            // Set Headers
 03113            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3114            {
 03115                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3116            }
 03117            if (Client.AcceptLanguage != null)
 3118            {
 03119                if (_httpRequest.Headers.Contains("accept-language"))
 3120                {
 03121                    _httpRequest.Headers.Remove("accept-language");
 3122                }
 03123                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3124            }
 03125            if (clientRequestId != null)
 3126            {
 03127                if (_httpRequest.Headers.Contains("client-request-id"))
 3128                {
 03129                    _httpRequest.Headers.Remove("client-request-id");
 3130                }
 03131                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3132            }
 03133            if (returnClientRequestId != null)
 3134            {
 03135                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3136                {
 03137                    _httpRequest.Headers.Remove("return-client-request-id");
 3138                }
 03139                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3140            }
 03141            if (ocpDate != null)
 3142            {
 03143                if (_httpRequest.Headers.Contains("ocp-date"))
 3144                {
 03145                    _httpRequest.Headers.Remove("ocp-date");
 3146                }
 03147                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3148            }
 3149
 3150
 03151            if (customHeaders != null)
 3152            {
 03153                foreach(var _header in customHeaders)
 3154                {
 03155                    if (_httpRequest.Headers.Contains(_header.Key))
 3156                    {
 03157                        _httpRequest.Headers.Remove(_header.Key);
 3158                    }
 03159                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3160                }
 3161            }
 3162
 3163            // Serialize Request
 03164            string _requestContent = null;
 3165            // Set Credentials
 03166            if (Client.Credentials != null)
 3167            {
 03168                cancellationToken.ThrowIfCancellationRequested();
 03169                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3170            }
 3171            // Send Request
 03172            if (_shouldTrace)
 3173            {
 03174                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3175            }
 03176            cancellationToken.ThrowIfCancellationRequested();
 03177            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03178            if (_shouldTrace)
 3179            {
 03180                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3181            }
 03182            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03183            cancellationToken.ThrowIfCancellationRequested();
 03184            string _responseContent = null;
 03185            if ((int)_statusCode != 200)
 3186            {
 03187                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3188                try
 3189                {
 03190                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03191                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03192                    if (_errorBody != null)
 3193                    {
 03194                        ex.Body = _errorBody;
 3195                    }
 03196                }
 03197                catch (JsonException)
 3198                {
 3199                    // Ignore the exception
 03200                }
 03201                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03202                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03203                if (_shouldTrace)
 3204                {
 03205                    ServiceClientTracing.Error(_invocationId, ex);
 3206                }
 03207                _httpRequest.Dispose();
 03208                if (_httpResponse != null)
 3209                {
 03210                    _httpResponse.Dispose();
 3211                }
 03212                throw ex;
 3213            }
 3214            // Create Result
 03215            var _result = new AzureOperationResponse<IPage<CloudJob>,JobListFromJobScheduleHeaders>();
 03216            _result.Request = _httpRequest;
 03217            _result.Response = _httpResponse;
 03218            if (_httpResponse.Headers.Contains("request-id"))
 3219            {
 03220                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3221            }
 3222            // Deserialize Response
 03223            if ((int)_statusCode == 200)
 3224            {
 03225                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3226                try
 3227                {
 03228                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJob>>(_responseContent, Client.Deserializ
 03229                }
 03230                catch (JsonException ex)
 3231                {
 03232                    _httpRequest.Dispose();
 03233                    if (_httpResponse != null)
 3234                    {
 03235                        _httpResponse.Dispose();
 3236                    }
 03237                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3238                }
 3239            }
 3240            try
 3241            {
 03242                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListFromJobScheduleHeaders>(JsonSerialize
 03243            }
 03244            catch (JsonException ex)
 3245            {
 03246                _httpRequest.Dispose();
 03247                if (_httpResponse != null)
 3248                {
 03249                    _httpResponse.Dispose();
 3250                }
 03251                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3252            }
 03253            if (_shouldTrace)
 3254            {
 03255                ServiceClientTracing.Exit(_invocationId, _result);
 3256            }
 03257            return _result;
 03258        }
 3259
 3260        /// <summary>
 3261        /// Lists the execution status of the Job Preparation and Job Release Task for
 3262        /// the specified Job across the Compute Nodes where the Job has run.
 3263        /// </summary>
 3264        /// <remarks>
 3265        /// This API returns the Job Preparation and Job Release Task status on all
 3266        /// Compute Nodes that have run the Job Preparation or Job Release Task. This
 3267        /// includes Compute Nodes which have since been removed from the Pool. If this
 3268        /// API is invoked on a Job which has no Job Preparation or Job Release Task,
 3269        /// the Batch service returns HTTP status code 409 (Conflict) with an error
 3270        /// code of JobPreparationTaskNotSpecified.
 3271        /// </remarks>
 3272        /// <param name='jobId'>
 3273        /// The ID of the Job.
 3274        /// </param>
 3275        /// <param name='jobListPreparationAndReleaseTaskStatusOptions'>
 3276        /// Additional parameters for the operation
 3277        /// </param>
 3278        /// <param name='customHeaders'>
 3279        /// Headers that will be added to request.
 3280        /// </param>
 3281        /// <param name='cancellationToken'>
 3282        /// The cancellation token.
 3283        /// </param>
 3284        /// <exception cref="BatchErrorException">
 3285        /// Thrown when the operation returned an invalid status code
 3286        /// </exception>
 3287        /// <exception cref="SerializationException">
 3288        /// Thrown when unable to deserialize the response
 3289        /// </exception>
 3290        /// <exception cref="ValidationException">
 3291        /// Thrown when a required parameter is null
 3292        /// </exception>
 3293        /// <exception cref="System.ArgumentNullException">
 3294        /// Thrown when a required parameter is null
 3295        /// </exception>
 3296        /// <return>
 3297        /// A response object containing the response body and response headers.
 3298        /// </return>
 3299        public async Task<AzureOperationResponse<IPage<JobPreparationAndReleaseTaskExecutionInformation>,JobListPreparat
 3300        {
 03301            if (Client.BatchUrl == null)
 3302            {
 03303                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 3304            }
 03305            if (jobId == null)
 3306            {
 03307                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 3308            }
 03309            if (Client.ApiVersion == null)
 3310            {
 03311                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 3312            }
 03313            string filter = default(string);
 03314            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3315            {
 03316                filter = jobListPreparationAndReleaseTaskStatusOptions.Filter;
 3317            }
 03318            string select = default(string);
 03319            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3320            {
 03321                select = jobListPreparationAndReleaseTaskStatusOptions.Select;
 3322            }
 03323            int? maxResults = default(int?);
 03324            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3325            {
 03326                maxResults = jobListPreparationAndReleaseTaskStatusOptions.MaxResults;
 3327            }
 03328            int? timeout = default(int?);
 03329            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3330            {
 03331                timeout = jobListPreparationAndReleaseTaskStatusOptions.Timeout;
 3332            }
 03333            System.Guid? clientRequestId = default(System.Guid?);
 03334            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3335            {
 03336                clientRequestId = jobListPreparationAndReleaseTaskStatusOptions.ClientRequestId;
 3337            }
 03338            bool? returnClientRequestId = default(bool?);
 03339            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3340            {
 03341                returnClientRequestId = jobListPreparationAndReleaseTaskStatusOptions.ReturnClientRequestId;
 3342            }
 03343            System.DateTime? ocpDate = default(System.DateTime?);
 03344            if (jobListPreparationAndReleaseTaskStatusOptions != null)
 3345            {
 03346                ocpDate = jobListPreparationAndReleaseTaskStatusOptions.OcpDate;
 3347            }
 3348            // Tracing
 03349            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03350            string _invocationId = null;
 03351            if (_shouldTrace)
 3352            {
 03353                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03354                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03355                tracingParameters.Add("jobId", jobId);
 03356                tracingParameters.Add("filter", filter);
 03357                tracingParameters.Add("select", select);
 03358                tracingParameters.Add("maxResults", maxResults);
 03359                tracingParameters.Add("timeout", timeout);
 03360                tracingParameters.Add("clientRequestId", clientRequestId);
 03361                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03362                tracingParameters.Add("ocpDate", ocpDate);
 03363                tracingParameters.Add("cancellationToken", cancellationToken);
 03364                ServiceClientTracing.Enter(_invocationId, this, "ListPreparationAndReleaseTaskStatus", tracingParameters
 3365            }
 3366            // Construct URL
 03367            var _baseUrl = Client.BaseUri;
 03368            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/jobpreparationandreleasetaskstatus
 03369            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 03370            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 03371            List<string> _queryParameters = new List<string>();
 03372            if (Client.ApiVersion != null)
 3373            {
 03374                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 3375            }
 03376            if (filter != null)
 3377            {
 03378                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 3379            }
 03380            if (select != null)
 3381            {
 03382                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 3383            }
 03384            if (maxResults != null)
 3385            {
 03386                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 3387            }
 03388            if (timeout != null)
 3389            {
 03390                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 3391            }
 03392            if (_queryParameters.Count > 0)
 3393            {
 03394                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3395            }
 3396            // Create HTTP transport objects
 03397            var _httpRequest = new HttpRequestMessage();
 03398            HttpResponseMessage _httpResponse = null;
 03399            _httpRequest.Method = new HttpMethod("GET");
 03400            _httpRequest.RequestUri = new System.Uri(_url);
 3401            // Set Headers
 03402            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3403            {
 03404                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3405            }
 03406            if (Client.AcceptLanguage != null)
 3407            {
 03408                if (_httpRequest.Headers.Contains("accept-language"))
 3409                {
 03410                    _httpRequest.Headers.Remove("accept-language");
 3411                }
 03412                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3413            }
 03414            if (clientRequestId != null)
 3415            {
 03416                if (_httpRequest.Headers.Contains("client-request-id"))
 3417                {
 03418                    _httpRequest.Headers.Remove("client-request-id");
 3419                }
 03420                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3421            }
 03422            if (returnClientRequestId != null)
 3423            {
 03424                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3425                {
 03426                    _httpRequest.Headers.Remove("return-client-request-id");
 3427                }
 03428                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3429            }
 03430            if (ocpDate != null)
 3431            {
 03432                if (_httpRequest.Headers.Contains("ocp-date"))
 3433                {
 03434                    _httpRequest.Headers.Remove("ocp-date");
 3435                }
 03436                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3437            }
 3438
 3439
 03440            if (customHeaders != null)
 3441            {
 03442                foreach(var _header in customHeaders)
 3443                {
 03444                    if (_httpRequest.Headers.Contains(_header.Key))
 3445                    {
 03446                        _httpRequest.Headers.Remove(_header.Key);
 3447                    }
 03448                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3449                }
 3450            }
 3451
 3452            // Serialize Request
 03453            string _requestContent = null;
 3454            // Set Credentials
 03455            if (Client.Credentials != null)
 3456            {
 03457                cancellationToken.ThrowIfCancellationRequested();
 03458                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3459            }
 3460            // Send Request
 03461            if (_shouldTrace)
 3462            {
 03463                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3464            }
 03465            cancellationToken.ThrowIfCancellationRequested();
 03466            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03467            if (_shouldTrace)
 3468            {
 03469                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3470            }
 03471            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03472            cancellationToken.ThrowIfCancellationRequested();
 03473            string _responseContent = null;
 03474            if ((int)_statusCode != 200)
 3475            {
 03476                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3477                try
 3478                {
 03479                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03480                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03481                    if (_errorBody != null)
 3482                    {
 03483                        ex.Body = _errorBody;
 3484                    }
 03485                }
 03486                catch (JsonException)
 3487                {
 3488                    // Ignore the exception
 03489                }
 03490                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03491                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03492                if (_shouldTrace)
 3493                {
 03494                    ServiceClientTracing.Error(_invocationId, ex);
 3495                }
 03496                _httpRequest.Dispose();
 03497                if (_httpResponse != null)
 3498                {
 03499                    _httpResponse.Dispose();
 3500                }
 03501                throw ex;
 3502            }
 3503            // Create Result
 03504            var _result = new AzureOperationResponse<IPage<JobPreparationAndReleaseTaskExecutionInformation>,JobListPrep
 03505            _result.Request = _httpRequest;
 03506            _result.Response = _httpResponse;
 03507            if (_httpResponse.Headers.Contains("request-id"))
 3508            {
 03509                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3510            }
 3511            // Deserialize Response
 03512            if ((int)_statusCode == 200)
 3513            {
 03514                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3515                try
 3516                {
 03517                    _result.Body = SafeJsonConvert.DeserializeObject<Page<JobPreparationAndReleaseTaskExecutionInformati
 03518                }
 03519                catch (JsonException ex)
 3520                {
 03521                    _httpRequest.Dispose();
 03522                    if (_httpResponse != null)
 3523                    {
 03524                        _httpResponse.Dispose();
 3525                    }
 03526                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3527                }
 3528            }
 3529            try
 3530            {
 03531                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListPreparationAndReleaseTaskStatusHeader
 03532            }
 03533            catch (JsonException ex)
 3534            {
 03535                _httpRequest.Dispose();
 03536                if (_httpResponse != null)
 3537                {
 03538                    _httpResponse.Dispose();
 3539                }
 03540                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3541            }
 03542            if (_shouldTrace)
 3543            {
 03544                ServiceClientTracing.Exit(_invocationId, _result);
 3545            }
 03546            return _result;
 03547        }
 3548
 3549        /// <summary>
 3550        /// Gets the Task counts for the specified Job.
 3551        /// </summary>
 3552        /// <remarks>
 3553        /// Task counts provide a count of the Tasks by active, running or completed
 3554        /// Task state, and a count of Tasks which succeeded or failed. Tasks in the
 3555        /// preparing state are counted as running.
 3556        /// </remarks>
 3557        /// <param name='jobId'>
 3558        /// The ID of the Job.
 3559        /// </param>
 3560        /// <param name='jobGetTaskCountsOptions'>
 3561        /// Additional parameters for the operation
 3562        /// </param>
 3563        /// <param name='customHeaders'>
 3564        /// Headers that will be added to request.
 3565        /// </param>
 3566        /// <param name='cancellationToken'>
 3567        /// The cancellation token.
 3568        /// </param>
 3569        /// <exception cref="BatchErrorException">
 3570        /// Thrown when the operation returned an invalid status code
 3571        /// </exception>
 3572        /// <exception cref="SerializationException">
 3573        /// Thrown when unable to deserialize the response
 3574        /// </exception>
 3575        /// <exception cref="ValidationException">
 3576        /// Thrown when a required parameter is null
 3577        /// </exception>
 3578        /// <exception cref="System.ArgumentNullException">
 3579        /// Thrown when a required parameter is null
 3580        /// </exception>
 3581        /// <return>
 3582        /// A response object containing the response body and response headers.
 3583        /// </return>
 3584        public async Task<AzureOperationResponse<TaskCounts,JobGetTaskCountsHeaders>> GetTaskCountsWithHttpMessagesAsync
 3585        {
 03586            if (Client.BatchUrl == null)
 3587            {
 03588                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 3589            }
 03590            if (jobId == null)
 3591            {
 03592                throw new ValidationException(ValidationRules.CannotBeNull, "jobId");
 3593            }
 03594            if (Client.ApiVersion == null)
 3595            {
 03596                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 3597            }
 03598            int? timeout = default(int?);
 03599            if (jobGetTaskCountsOptions != null)
 3600            {
 03601                timeout = jobGetTaskCountsOptions.Timeout;
 3602            }
 03603            System.Guid? clientRequestId = default(System.Guid?);
 03604            if (jobGetTaskCountsOptions != null)
 3605            {
 03606                clientRequestId = jobGetTaskCountsOptions.ClientRequestId;
 3607            }
 03608            bool? returnClientRequestId = default(bool?);
 03609            if (jobGetTaskCountsOptions != null)
 3610            {
 03611                returnClientRequestId = jobGetTaskCountsOptions.ReturnClientRequestId;
 3612            }
 03613            System.DateTime? ocpDate = default(System.DateTime?);
 03614            if (jobGetTaskCountsOptions != null)
 3615            {
 03616                ocpDate = jobGetTaskCountsOptions.OcpDate;
 3617            }
 3618            // Tracing
 03619            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03620            string _invocationId = null;
 03621            if (_shouldTrace)
 3622            {
 03623                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03624                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03625                tracingParameters.Add("jobId", jobId);
 03626                tracingParameters.Add("timeout", timeout);
 03627                tracingParameters.Add("clientRequestId", clientRequestId);
 03628                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03629                tracingParameters.Add("ocpDate", ocpDate);
 03630                tracingParameters.Add("cancellationToken", cancellationToken);
 03631                ServiceClientTracing.Enter(_invocationId, this, "GetTaskCounts", tracingParameters);
 3632            }
 3633            // Construct URL
 03634            var _baseUrl = Client.BaseUri;
 03635            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/taskcounts";
 03636            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 03637            _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId));
 03638            List<string> _queryParameters = new List<string>();
 03639            if (Client.ApiVersion != null)
 3640            {
 03641                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 3642            }
 03643            if (timeout != null)
 3644            {
 03645                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 3646            }
 03647            if (_queryParameters.Count > 0)
 3648            {
 03649                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3650            }
 3651            // Create HTTP transport objects
 03652            var _httpRequest = new HttpRequestMessage();
 03653            HttpResponseMessage _httpResponse = null;
 03654            _httpRequest.Method = new HttpMethod("GET");
 03655            _httpRequest.RequestUri = new System.Uri(_url);
 3656            // Set Headers
 03657            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3658            {
 03659                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3660            }
 03661            if (Client.AcceptLanguage != null)
 3662            {
 03663                if (_httpRequest.Headers.Contains("accept-language"))
 3664                {
 03665                    _httpRequest.Headers.Remove("accept-language");
 3666                }
 03667                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3668            }
 03669            if (clientRequestId != null)
 3670            {
 03671                if (_httpRequest.Headers.Contains("client-request-id"))
 3672                {
 03673                    _httpRequest.Headers.Remove("client-request-id");
 3674                }
 03675                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3676            }
 03677            if (returnClientRequestId != null)
 3678            {
 03679                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3680                {
 03681                    _httpRequest.Headers.Remove("return-client-request-id");
 3682                }
 03683                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3684            }
 03685            if (ocpDate != null)
 3686            {
 03687                if (_httpRequest.Headers.Contains("ocp-date"))
 3688                {
 03689                    _httpRequest.Headers.Remove("ocp-date");
 3690                }
 03691                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3692            }
 3693
 3694
 03695            if (customHeaders != null)
 3696            {
 03697                foreach(var _header in customHeaders)
 3698                {
 03699                    if (_httpRequest.Headers.Contains(_header.Key))
 3700                    {
 03701                        _httpRequest.Headers.Remove(_header.Key);
 3702                    }
 03703                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3704                }
 3705            }
 3706
 3707            // Serialize Request
 03708            string _requestContent = null;
 3709            // Set Credentials
 03710            if (Client.Credentials != null)
 3711            {
 03712                cancellationToken.ThrowIfCancellationRequested();
 03713                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3714            }
 3715            // Send Request
 03716            if (_shouldTrace)
 3717            {
 03718                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3719            }
 03720            cancellationToken.ThrowIfCancellationRequested();
 03721            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03722            if (_shouldTrace)
 3723            {
 03724                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3725            }
 03726            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03727            cancellationToken.ThrowIfCancellationRequested();
 03728            string _responseContent = null;
 03729            if ((int)_statusCode != 200)
 3730            {
 03731                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3732                try
 3733                {
 03734                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03735                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03736                    if (_errorBody != null)
 3737                    {
 03738                        ex.Body = _errorBody;
 3739                    }
 03740                }
 03741                catch (JsonException)
 3742                {
 3743                    // Ignore the exception
 03744                }
 03745                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03746                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03747                if (_shouldTrace)
 3748                {
 03749                    ServiceClientTracing.Error(_invocationId, ex);
 3750                }
 03751                _httpRequest.Dispose();
 03752                if (_httpResponse != null)
 3753                {
 03754                    _httpResponse.Dispose();
 3755                }
 03756                throw ex;
 3757            }
 3758            // Create Result
 03759            var _result = new AzureOperationResponse<TaskCounts,JobGetTaskCountsHeaders>();
 03760            _result.Request = _httpRequest;
 03761            _result.Response = _httpResponse;
 03762            if (_httpResponse.Headers.Contains("request-id"))
 3763            {
 03764                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3765            }
 3766            // Deserialize Response
 03767            if ((int)_statusCode == 200)
 3768            {
 03769                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3770                try
 3771                {
 03772                    _result.Body = SafeJsonConvert.DeserializeObject<TaskCounts>(_responseContent, Client.Deserializatio
 03773                }
 03774                catch (JsonException ex)
 3775                {
 03776                    _httpRequest.Dispose();
 03777                    if (_httpResponse != null)
 3778                    {
 03779                        _httpResponse.Dispose();
 3780                    }
 03781                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3782                }
 3783            }
 3784            try
 3785            {
 03786                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobGetTaskCountsHeaders>(JsonSerializer.Crea
 03787            }
 03788            catch (JsonException ex)
 3789            {
 03790                _httpRequest.Dispose();
 03791                if (_httpResponse != null)
 3792                {
 03793                    _httpResponse.Dispose();
 3794                }
 03795                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3796            }
 03797            if (_shouldTrace)
 3798            {
 03799                ServiceClientTracing.Exit(_invocationId, _result);
 3800            }
 03801            return _result;
 03802        }
 3803
 3804        /// <summary>
 3805        /// Lists all of the Jobs in the specified Account.
 3806        /// </summary>
 3807        /// <param name='nextPageLink'>
 3808        /// The NextLink from the previous successful call to List operation.
 3809        /// </param>
 3810        /// <param name='jobListNextOptions'>
 3811        /// Additional parameters for the operation
 3812        /// </param>
 3813        /// <param name='customHeaders'>
 3814        /// Headers that will be added to request.
 3815        /// </param>
 3816        /// <param name='cancellationToken'>
 3817        /// The cancellation token.
 3818        /// </param>
 3819        /// <exception cref="BatchErrorException">
 3820        /// Thrown when the operation returned an invalid status code
 3821        /// </exception>
 3822        /// <exception cref="SerializationException">
 3823        /// Thrown when unable to deserialize the response
 3824        /// </exception>
 3825        /// <exception cref="ValidationException">
 3826        /// Thrown when a required parameter is null
 3827        /// </exception>
 3828        /// <exception cref="System.ArgumentNullException">
 3829        /// Thrown when a required parameter is null
 3830        /// </exception>
 3831        /// <return>
 3832        /// A response object containing the response body and response headers.
 3833        /// </return>
 3834        public async Task<AzureOperationResponse<IPage<CloudJob>,JobListHeaders>> ListNextWithHttpMessagesAsync(string n
 3835        {
 03836            if (nextPageLink == null)
 3837            {
 03838                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 3839            }
 03840            System.Guid? clientRequestId = default(System.Guid?);
 03841            if (jobListNextOptions != null)
 3842            {
 03843                clientRequestId = jobListNextOptions.ClientRequestId;
 3844            }
 03845            bool? returnClientRequestId = default(bool?);
 03846            if (jobListNextOptions != null)
 3847            {
 03848                returnClientRequestId = jobListNextOptions.ReturnClientRequestId;
 3849            }
 03850            System.DateTime? ocpDate = default(System.DateTime?);
 03851            if (jobListNextOptions != null)
 3852            {
 03853                ocpDate = jobListNextOptions.OcpDate;
 3854            }
 3855            // Tracing
 03856            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03857            string _invocationId = null;
 03858            if (_shouldTrace)
 3859            {
 03860                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03861                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03862                tracingParameters.Add("nextPageLink", nextPageLink);
 03863                tracingParameters.Add("clientRequestId", clientRequestId);
 03864                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03865                tracingParameters.Add("ocpDate", ocpDate);
 03866                tracingParameters.Add("cancellationToken", cancellationToken);
 03867                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 3868            }
 3869            // Construct URL
 03870            string _url = "{nextLink}";
 03871            _url = _url.Replace("{nextLink}", nextPageLink);
 03872            List<string> _queryParameters = new List<string>();
 03873            if (_queryParameters.Count > 0)
 3874            {
 03875                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3876            }
 3877            // Create HTTP transport objects
 03878            var _httpRequest = new HttpRequestMessage();
 03879            HttpResponseMessage _httpResponse = null;
 03880            _httpRequest.Method = new HttpMethod("GET");
 03881            _httpRequest.RequestUri = new System.Uri(_url);
 3882            // Set Headers
 03883            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3884            {
 03885                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3886            }
 03887            if (Client.AcceptLanguage != null)
 3888            {
 03889                if (_httpRequest.Headers.Contains("accept-language"))
 3890                {
 03891                    _httpRequest.Headers.Remove("accept-language");
 3892                }
 03893                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3894            }
 03895            if (clientRequestId != null)
 3896            {
 03897                if (_httpRequest.Headers.Contains("client-request-id"))
 3898                {
 03899                    _httpRequest.Headers.Remove("client-request-id");
 3900                }
 03901                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3902            }
 03903            if (returnClientRequestId != null)
 3904            {
 03905                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3906                {
 03907                    _httpRequest.Headers.Remove("return-client-request-id");
 3908                }
 03909                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3910            }
 03911            if (ocpDate != null)
 3912            {
 03913                if (_httpRequest.Headers.Contains("ocp-date"))
 3914                {
 03915                    _httpRequest.Headers.Remove("ocp-date");
 3916                }
 03917                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3918            }
 3919
 3920
 03921            if (customHeaders != null)
 3922            {
 03923                foreach(var _header in customHeaders)
 3924                {
 03925                    if (_httpRequest.Headers.Contains(_header.Key))
 3926                    {
 03927                        _httpRequest.Headers.Remove(_header.Key);
 3928                    }
 03929                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3930                }
 3931            }
 3932
 3933            // Serialize Request
 03934            string _requestContent = null;
 3935            // Set Credentials
 03936            if (Client.Credentials != null)
 3937            {
 03938                cancellationToken.ThrowIfCancellationRequested();
 03939                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3940            }
 3941            // Send Request
 03942            if (_shouldTrace)
 3943            {
 03944                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3945            }
 03946            cancellationToken.ThrowIfCancellationRequested();
 03947            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03948            if (_shouldTrace)
 3949            {
 03950                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3951            }
 03952            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03953            cancellationToken.ThrowIfCancellationRequested();
 03954            string _responseContent = null;
 03955            if ((int)_statusCode != 200)
 3956            {
 03957                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3958                try
 3959                {
 03960                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03961                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03962                    if (_errorBody != null)
 3963                    {
 03964                        ex.Body = _errorBody;
 3965                    }
 03966                }
 03967                catch (JsonException)
 3968                {
 3969                    // Ignore the exception
 03970                }
 03971                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03972                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03973                if (_shouldTrace)
 3974                {
 03975                    ServiceClientTracing.Error(_invocationId, ex);
 3976                }
 03977                _httpRequest.Dispose();
 03978                if (_httpResponse != null)
 3979                {
 03980                    _httpResponse.Dispose();
 3981                }
 03982                throw ex;
 3983            }
 3984            // Create Result
 03985            var _result = new AzureOperationResponse<IPage<CloudJob>,JobListHeaders>();
 03986            _result.Request = _httpRequest;
 03987            _result.Response = _httpResponse;
 03988            if (_httpResponse.Headers.Contains("request-id"))
 3989            {
 03990                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3991            }
 3992            // Deserialize Response
 03993            if ((int)_statusCode == 200)
 3994            {
 03995                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3996                try
 3997                {
 03998                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJob>>(_responseContent, Client.Deserializ
 03999                }
 04000                catch (JsonException ex)
 4001                {
 04002                    _httpRequest.Dispose();
 04003                    if (_httpResponse != null)
 4004                    {
 04005                        _httpResponse.Dispose();
 4006                    }
 04007                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4008                }
 4009            }
 4010            try
 4011            {
 04012                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListHeaders>(JsonSerializer.Create(Client
 04013            }
 04014            catch (JsonException ex)
 4015            {
 04016                _httpRequest.Dispose();
 04017                if (_httpResponse != null)
 4018                {
 04019                    _httpResponse.Dispose();
 4020                }
 04021                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 4022            }
 04023            if (_shouldTrace)
 4024            {
 04025                ServiceClientTracing.Exit(_invocationId, _result);
 4026            }
 04027            return _result;
 04028        }
 4029
 4030        /// <summary>
 4031        /// Lists the Jobs that have been created under the specified Job Schedule.
 4032        /// </summary>
 4033        /// <param name='nextPageLink'>
 4034        /// The NextLink from the previous successful call to List operation.
 4035        /// </param>
 4036        /// <param name='jobListFromJobScheduleNextOptions'>
 4037        /// Additional parameters for the operation
 4038        /// </param>
 4039        /// <param name='customHeaders'>
 4040        /// Headers that will be added to request.
 4041        /// </param>
 4042        /// <param name='cancellationToken'>
 4043        /// The cancellation token.
 4044        /// </param>
 4045        /// <exception cref="BatchErrorException">
 4046        /// Thrown when the operation returned an invalid status code
 4047        /// </exception>
 4048        /// <exception cref="SerializationException">
 4049        /// Thrown when unable to deserialize the response
 4050        /// </exception>
 4051        /// <exception cref="ValidationException">
 4052        /// Thrown when a required parameter is null
 4053        /// </exception>
 4054        /// <exception cref="System.ArgumentNullException">
 4055        /// Thrown when a required parameter is null
 4056        /// </exception>
 4057        /// <return>
 4058        /// A response object containing the response body and response headers.
 4059        /// </return>
 4060        public async Task<AzureOperationResponse<IPage<CloudJob>,JobListFromJobScheduleHeaders>> ListFromJobScheduleNext
 4061        {
 04062            if (nextPageLink == null)
 4063            {
 04064                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 4065            }
 04066            System.Guid? clientRequestId = default(System.Guid?);
 04067            if (jobListFromJobScheduleNextOptions != null)
 4068            {
 04069                clientRequestId = jobListFromJobScheduleNextOptions.ClientRequestId;
 4070            }
 04071            bool? returnClientRequestId = default(bool?);
 04072            if (jobListFromJobScheduleNextOptions != null)
 4073            {
 04074                returnClientRequestId = jobListFromJobScheduleNextOptions.ReturnClientRequestId;
 4075            }
 04076            System.DateTime? ocpDate = default(System.DateTime?);
 04077            if (jobListFromJobScheduleNextOptions != null)
 4078            {
 04079                ocpDate = jobListFromJobScheduleNextOptions.OcpDate;
 4080            }
 4081            // Tracing
 04082            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04083            string _invocationId = null;
 04084            if (_shouldTrace)
 4085            {
 04086                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04087                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04088                tracingParameters.Add("nextPageLink", nextPageLink);
 04089                tracingParameters.Add("clientRequestId", clientRequestId);
 04090                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 04091                tracingParameters.Add("ocpDate", ocpDate);
 04092                tracingParameters.Add("cancellationToken", cancellationToken);
 04093                ServiceClientTracing.Enter(_invocationId, this, "ListFromJobScheduleNext", tracingParameters);
 4094            }
 4095            // Construct URL
 04096            string _url = "{nextLink}";
 04097            _url = _url.Replace("{nextLink}", nextPageLink);
 04098            List<string> _queryParameters = new List<string>();
 04099            if (_queryParameters.Count > 0)
 4100            {
 04101                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 4102            }
 4103            // Create HTTP transport objects
 04104            var _httpRequest = new HttpRequestMessage();
 04105            HttpResponseMessage _httpResponse = null;
 04106            _httpRequest.Method = new HttpMethod("GET");
 04107            _httpRequest.RequestUri = new System.Uri(_url);
 4108            // Set Headers
 04109            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 4110            {
 04111                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 4112            }
 04113            if (Client.AcceptLanguage != null)
 4114            {
 04115                if (_httpRequest.Headers.Contains("accept-language"))
 4116                {
 04117                    _httpRequest.Headers.Remove("accept-language");
 4118                }
 04119                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 4120            }
 04121            if (clientRequestId != null)
 4122            {
 04123                if (_httpRequest.Headers.Contains("client-request-id"))
 4124                {
 04125                    _httpRequest.Headers.Remove("client-request-id");
 4126                }
 04127                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 4128            }
 04129            if (returnClientRequestId != null)
 4130            {
 04131                if (_httpRequest.Headers.Contains("return-client-request-id"))
 4132                {
 04133                    _httpRequest.Headers.Remove("return-client-request-id");
 4134                }
 04135                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 4136            }
 04137            if (ocpDate != null)
 4138            {
 04139                if (_httpRequest.Headers.Contains("ocp-date"))
 4140                {
 04141                    _httpRequest.Headers.Remove("ocp-date");
 4142                }
 04143                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 4144            }
 4145
 4146
 04147            if (customHeaders != null)
 4148            {
 04149                foreach(var _header in customHeaders)
 4150                {
 04151                    if (_httpRequest.Headers.Contains(_header.Key))
 4152                    {
 04153                        _httpRequest.Headers.Remove(_header.Key);
 4154                    }
 04155                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4156                }
 4157            }
 4158
 4159            // Serialize Request
 04160            string _requestContent = null;
 4161            // Set Credentials
 04162            if (Client.Credentials != null)
 4163            {
 04164                cancellationToken.ThrowIfCancellationRequested();
 04165                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4166            }
 4167            // Send Request
 04168            if (_shouldTrace)
 4169            {
 04170                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4171            }
 04172            cancellationToken.ThrowIfCancellationRequested();
 04173            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04174            if (_shouldTrace)
 4175            {
 04176                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4177            }
 04178            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04179            cancellationToken.ThrowIfCancellationRequested();
 04180            string _responseContent = null;
 04181            if ((int)_statusCode != 200)
 4182            {
 04183                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 4184                try
 4185                {
 04186                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04187                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 04188                    if (_errorBody != null)
 4189                    {
 04190                        ex.Body = _errorBody;
 4191                    }
 04192                }
 04193                catch (JsonException)
 4194                {
 4195                    // Ignore the exception
 04196                }
 04197                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04198                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04199                if (_shouldTrace)
 4200                {
 04201                    ServiceClientTracing.Error(_invocationId, ex);
 4202                }
 04203                _httpRequest.Dispose();
 04204                if (_httpResponse != null)
 4205                {
 04206                    _httpResponse.Dispose();
 4207                }
 04208                throw ex;
 4209            }
 4210            // Create Result
 04211            var _result = new AzureOperationResponse<IPage<CloudJob>,JobListFromJobScheduleHeaders>();
 04212            _result.Request = _httpRequest;
 04213            _result.Response = _httpResponse;
 04214            if (_httpResponse.Headers.Contains("request-id"))
 4215            {
 04216                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 4217            }
 4218            // Deserialize Response
 04219            if ((int)_statusCode == 200)
 4220            {
 04221                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4222                try
 4223                {
 04224                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJob>>(_responseContent, Client.Deserializ
 04225                }
 04226                catch (JsonException ex)
 4227                {
 04228                    _httpRequest.Dispose();
 04229                    if (_httpResponse != null)
 4230                    {
 04231                        _httpResponse.Dispose();
 4232                    }
 04233                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4234                }
 4235            }
 4236            try
 4237            {
 04238                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListFromJobScheduleHeaders>(JsonSerialize
 04239            }
 04240            catch (JsonException ex)
 4241            {
 04242                _httpRequest.Dispose();
 04243                if (_httpResponse != null)
 4244                {
 04245                    _httpResponse.Dispose();
 4246                }
 04247                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 4248            }
 04249            if (_shouldTrace)
 4250            {
 04251                ServiceClientTracing.Exit(_invocationId, _result);
 4252            }
 04253            return _result;
 04254        }
 4255
 4256        /// <summary>
 4257        /// Lists the execution status of the Job Preparation and Job Release Task for
 4258        /// the specified Job across the Compute Nodes where the Job has run.
 4259        /// </summary>
 4260        /// <remarks>
 4261        /// This API returns the Job Preparation and Job Release Task status on all
 4262        /// Compute Nodes that have run the Job Preparation or Job Release Task. This
 4263        /// includes Compute Nodes which have since been removed from the Pool. If this
 4264        /// API is invoked on a Job which has no Job Preparation or Job Release Task,
 4265        /// the Batch service returns HTTP status code 409 (Conflict) with an error
 4266        /// code of JobPreparationTaskNotSpecified.
 4267        /// </remarks>
 4268        /// <param name='nextPageLink'>
 4269        /// The NextLink from the previous successful call to List operation.
 4270        /// </param>
 4271        /// <param name='jobListPreparationAndReleaseTaskStatusNextOptions'>
 4272        /// Additional parameters for the operation
 4273        /// </param>
 4274        /// <param name='customHeaders'>
 4275        /// Headers that will be added to request.
 4276        /// </param>
 4277        /// <param name='cancellationToken'>
 4278        /// The cancellation token.
 4279        /// </param>
 4280        /// <exception cref="BatchErrorException">
 4281        /// Thrown when the operation returned an invalid status code
 4282        /// </exception>
 4283        /// <exception cref="SerializationException">
 4284        /// Thrown when unable to deserialize the response
 4285        /// </exception>
 4286        /// <exception cref="ValidationException">
 4287        /// Thrown when a required parameter is null
 4288        /// </exception>
 4289        /// <exception cref="System.ArgumentNullException">
 4290        /// Thrown when a required parameter is null
 4291        /// </exception>
 4292        /// <return>
 4293        /// A response object containing the response body and response headers.
 4294        /// </return>
 4295        public async Task<AzureOperationResponse<IPage<JobPreparationAndReleaseTaskExecutionInformation>,JobListPreparat
 4296        {
 04297            if (nextPageLink == null)
 4298            {
 04299                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 4300            }
 04301            System.Guid? clientRequestId = default(System.Guid?);
 04302            if (jobListPreparationAndReleaseTaskStatusNextOptions != null)
 4303            {
 04304                clientRequestId = jobListPreparationAndReleaseTaskStatusNextOptions.ClientRequestId;
 4305            }
 04306            bool? returnClientRequestId = default(bool?);
 04307            if (jobListPreparationAndReleaseTaskStatusNextOptions != null)
 4308            {
 04309                returnClientRequestId = jobListPreparationAndReleaseTaskStatusNextOptions.ReturnClientRequestId;
 4310            }
 04311            System.DateTime? ocpDate = default(System.DateTime?);
 04312            if (jobListPreparationAndReleaseTaskStatusNextOptions != null)
 4313            {
 04314                ocpDate = jobListPreparationAndReleaseTaskStatusNextOptions.OcpDate;
 4315            }
 4316            // Tracing
 04317            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04318            string _invocationId = null;
 04319            if (_shouldTrace)
 4320            {
 04321                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04322                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04323                tracingParameters.Add("nextPageLink", nextPageLink);
 04324                tracingParameters.Add("clientRequestId", clientRequestId);
 04325                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 04326                tracingParameters.Add("ocpDate", ocpDate);
 04327                tracingParameters.Add("cancellationToken", cancellationToken);
 04328                ServiceClientTracing.Enter(_invocationId, this, "ListPreparationAndReleaseTaskStatusNext", tracingParame
 4329            }
 4330            // Construct URL
 04331            string _url = "{nextLink}";
 04332            _url = _url.Replace("{nextLink}", nextPageLink);
 04333            List<string> _queryParameters = new List<string>();
 04334            if (_queryParameters.Count > 0)
 4335            {
 04336                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 4337            }
 4338            // Create HTTP transport objects
 04339            var _httpRequest = new HttpRequestMessage();
 04340            HttpResponseMessage _httpResponse = null;
 04341            _httpRequest.Method = new HttpMethod("GET");
 04342            _httpRequest.RequestUri = new System.Uri(_url);
 4343            // Set Headers
 04344            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 4345            {
 04346                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 4347            }
 04348            if (Client.AcceptLanguage != null)
 4349            {
 04350                if (_httpRequest.Headers.Contains("accept-language"))
 4351                {
 04352                    _httpRequest.Headers.Remove("accept-language");
 4353                }
 04354                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 4355            }
 04356            if (clientRequestId != null)
 4357            {
 04358                if (_httpRequest.Headers.Contains("client-request-id"))
 4359                {
 04360                    _httpRequest.Headers.Remove("client-request-id");
 4361                }
 04362                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 4363            }
 04364            if (returnClientRequestId != null)
 4365            {
 04366                if (_httpRequest.Headers.Contains("return-client-request-id"))
 4367                {
 04368                    _httpRequest.Headers.Remove("return-client-request-id");
 4369                }
 04370                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 4371            }
 04372            if (ocpDate != null)
 4373            {
 04374                if (_httpRequest.Headers.Contains("ocp-date"))
 4375                {
 04376                    _httpRequest.Headers.Remove("ocp-date");
 4377                }
 04378                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 4379            }
 4380
 4381
 04382            if (customHeaders != null)
 4383            {
 04384                foreach(var _header in customHeaders)
 4385                {
 04386                    if (_httpRequest.Headers.Contains(_header.Key))
 4387                    {
 04388                        _httpRequest.Headers.Remove(_header.Key);
 4389                    }
 04390                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4391                }
 4392            }
 4393
 4394            // Serialize Request
 04395            string _requestContent = null;
 4396            // Set Credentials
 04397            if (Client.Credentials != null)
 4398            {
 04399                cancellationToken.ThrowIfCancellationRequested();
 04400                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4401            }
 4402            // Send Request
 04403            if (_shouldTrace)
 4404            {
 04405                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4406            }
 04407            cancellationToken.ThrowIfCancellationRequested();
 04408            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04409            if (_shouldTrace)
 4410            {
 04411                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4412            }
 04413            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04414            cancellationToken.ThrowIfCancellationRequested();
 04415            string _responseContent = null;
 04416            if ((int)_statusCode != 200)
 4417            {
 04418                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 4419                try
 4420                {
 04421                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04422                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 04423                    if (_errorBody != null)
 4424                    {
 04425                        ex.Body = _errorBody;
 4426                    }
 04427                }
 04428                catch (JsonException)
 4429                {
 4430                    // Ignore the exception
 04431                }
 04432                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04433                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04434                if (_shouldTrace)
 4435                {
 04436                    ServiceClientTracing.Error(_invocationId, ex);
 4437                }
 04438                _httpRequest.Dispose();
 04439                if (_httpResponse != null)
 4440                {
 04441                    _httpResponse.Dispose();
 4442                }
 04443                throw ex;
 4444            }
 4445            // Create Result
 04446            var _result = new AzureOperationResponse<IPage<JobPreparationAndReleaseTaskExecutionInformation>,JobListPrep
 04447            _result.Request = _httpRequest;
 04448            _result.Response = _httpResponse;
 04449            if (_httpResponse.Headers.Contains("request-id"))
 4450            {
 04451                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 4452            }
 4453            // Deserialize Response
 04454            if ((int)_statusCode == 200)
 4455            {
 04456                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4457                try
 4458                {
 04459                    _result.Body = SafeJsonConvert.DeserializeObject<Page<JobPreparationAndReleaseTaskExecutionInformati
 04460                }
 04461                catch (JsonException ex)
 4462                {
 04463                    _httpRequest.Dispose();
 04464                    if (_httpResponse != null)
 4465                    {
 04466                        _httpResponse.Dispose();
 4467                    }
 04468                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4469                }
 4470            }
 4471            try
 4472            {
 04473                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobListPreparationAndReleaseTaskStatusHeader
 04474            }
 04475            catch (JsonException ex)
 4476            {
 04477                _httpRequest.Dispose();
 04478                if (_httpResponse != null)
 4479                {
 04480                    _httpResponse.Dispose();
 4481                }
 04482                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 4483            }
 04484            if (_shouldTrace)
 4485            {
 04486                ServiceClientTracing.Exit(_invocationId, _result);
 4487            }
 04488            return _result;
 04489        }
 4490
 4491    }
 4492}