< Summary

Class:Microsoft.Azure.Batch.Protocol.JobScheduleOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\JobScheduleOperations.cs
Covered lines:8
Uncovered lines:1571
Coverable lines:1579
Total lines:3171
Line coverage:0.5% (8 of 1579)
Covered branches:3
Total branches:1020
Branch coverage:0.2% (3 of 1020)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
ExistsWithHttpMessagesAsync()-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%
ListNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\GeneratedProtocol\JobScheduleOperations.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    /// JobScheduleOperations operations.
 28    /// </summary>
 29    internal partial class JobScheduleOperations : IServiceOperations<BatchServiceClient>, IJobScheduleOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the JobScheduleOperations 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 JobScheduleOperations(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        /// Checks the specified Job Schedule exists.
 56        /// </summary>
 57        /// <param name='jobScheduleId'>
 58        /// The ID of the Job Schedule which you want to check.
 59        /// </param>
 60        /// <param name='jobScheduleExistsOptions'>
 61        /// Additional parameters for the operation
 62        /// </param>
 63        /// <param name='customHeaders'>
 64        /// Headers that will be added to request.
 65        /// </param>
 66        /// <param name='cancellationToken'>
 67        /// The cancellation token.
 68        /// </param>
 69        /// <exception cref="BatchErrorException">
 70        /// Thrown when the operation returned an invalid status code
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationResponse<bool,JobScheduleExistsHeaders>> ExistsWithHttpMessagesAsync(string jobS
 82        {
 083            if (Client.BatchUrl == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 86            }
 087            if (jobScheduleId == null)
 88            {
 089                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 90            }
 091            if (Client.ApiVersion == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 94            }
 095            int? timeout = default(int?);
 096            if (jobScheduleExistsOptions != null)
 97            {
 098                timeout = jobScheduleExistsOptions.Timeout;
 99            }
 0100            System.Guid? clientRequestId = default(System.Guid?);
 0101            if (jobScheduleExistsOptions != null)
 102            {
 0103                clientRequestId = jobScheduleExistsOptions.ClientRequestId;
 104            }
 0105            bool? returnClientRequestId = default(bool?);
 0106            if (jobScheduleExistsOptions != null)
 107            {
 0108                returnClientRequestId = jobScheduleExistsOptions.ReturnClientRequestId;
 109            }
 0110            System.DateTime? ocpDate = default(System.DateTime?);
 0111            if (jobScheduleExistsOptions != null)
 112            {
 0113                ocpDate = jobScheduleExistsOptions.OcpDate;
 114            }
 0115            string ifMatch = default(string);
 0116            if (jobScheduleExistsOptions != null)
 117            {
 0118                ifMatch = jobScheduleExistsOptions.IfMatch;
 119            }
 0120            string ifNoneMatch = default(string);
 0121            if (jobScheduleExistsOptions != null)
 122            {
 0123                ifNoneMatch = jobScheduleExistsOptions.IfNoneMatch;
 124            }
 0125            System.DateTime? ifModifiedSince = default(System.DateTime?);
 0126            if (jobScheduleExistsOptions != null)
 127            {
 0128                ifModifiedSince = jobScheduleExistsOptions.IfModifiedSince;
 129            }
 0130            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 0131            if (jobScheduleExistsOptions != null)
 132            {
 0133                ifUnmodifiedSince = jobScheduleExistsOptions.IfUnmodifiedSince;
 134            }
 135            // Tracing
 0136            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0137            string _invocationId = null;
 0138            if (_shouldTrace)
 139            {
 0140                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0141                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0142                tracingParameters.Add("jobScheduleId", jobScheduleId);
 0143                tracingParameters.Add("timeout", timeout);
 0144                tracingParameters.Add("clientRequestId", clientRequestId);
 0145                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0146                tracingParameters.Add("ocpDate", ocpDate);
 0147                tracingParameters.Add("ifMatch", ifMatch);
 0148                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0149                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0150                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0151                tracingParameters.Add("cancellationToken", cancellationToken);
 0152                ServiceClientTracing.Enter(_invocationId, this, "Exists", tracingParameters);
 153            }
 154            // Construct URL
 0155            var _baseUrl = Client.BaseUri;
 0156            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}";
 0157            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0158            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 0159            List<string> _queryParameters = new List<string>();
 0160            if (Client.ApiVersion != null)
 161            {
 0162                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 163            }
 0164            if (timeout != null)
 165            {
 0166                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 167            }
 0168            if (_queryParameters.Count > 0)
 169            {
 0170                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 171            }
 172            // Create HTTP transport objects
 0173            var _httpRequest = new HttpRequestMessage();
 0174            HttpResponseMessage _httpResponse = null;
 0175            _httpRequest.Method = new HttpMethod("HEAD");
 0176            _httpRequest.RequestUri = new System.Uri(_url);
 177            // Set Headers
 0178            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 179            {
 0180                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 181            }
 0182            if (Client.AcceptLanguage != null)
 183            {
 0184                if (_httpRequest.Headers.Contains("accept-language"))
 185                {
 0186                    _httpRequest.Headers.Remove("accept-language");
 187                }
 0188                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 189            }
 0190            if (clientRequestId != null)
 191            {
 0192                if (_httpRequest.Headers.Contains("client-request-id"))
 193                {
 0194                    _httpRequest.Headers.Remove("client-request-id");
 195                }
 0196                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 197            }
 0198            if (returnClientRequestId != null)
 199            {
 0200                if (_httpRequest.Headers.Contains("return-client-request-id"))
 201                {
 0202                    _httpRequest.Headers.Remove("return-client-request-id");
 203                }
 0204                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 205            }
 0206            if (ocpDate != null)
 207            {
 0208                if (_httpRequest.Headers.Contains("ocp-date"))
 209                {
 0210                    _httpRequest.Headers.Remove("ocp-date");
 211                }
 0212                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 213            }
 0214            if (ifMatch != null)
 215            {
 0216                if (_httpRequest.Headers.Contains("If-Match"))
 217                {
 0218                    _httpRequest.Headers.Remove("If-Match");
 219                }
 0220                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 221            }
 0222            if (ifNoneMatch != null)
 223            {
 0224                if (_httpRequest.Headers.Contains("If-None-Match"))
 225                {
 0226                    _httpRequest.Headers.Remove("If-None-Match");
 227                }
 0228                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 229            }
 0230            if (ifModifiedSince != null)
 231            {
 0232                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 233                {
 0234                    _httpRequest.Headers.Remove("If-Modified-Since");
 235                }
 0236                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 237            }
 0238            if (ifUnmodifiedSince != null)
 239            {
 0240                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 241                {
 0242                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 243                }
 0244                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 245            }
 246
 247
 0248            if (customHeaders != null)
 249            {
 0250                foreach(var _header in customHeaders)
 251                {
 0252                    if (_httpRequest.Headers.Contains(_header.Key))
 253                    {
 0254                        _httpRequest.Headers.Remove(_header.Key);
 255                    }
 0256                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 257                }
 258            }
 259
 260            // Serialize Request
 0261            string _requestContent = null;
 262            // Set Credentials
 0263            if (Client.Credentials != null)
 264            {
 0265                cancellationToken.ThrowIfCancellationRequested();
 0266                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 267            }
 268            // Send Request
 0269            if (_shouldTrace)
 270            {
 0271                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 272            }
 0273            cancellationToken.ThrowIfCancellationRequested();
 0274            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 0275            if (_shouldTrace)
 276            {
 0277                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 278            }
 0279            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0280            cancellationToken.ThrowIfCancellationRequested();
 0281            string _responseContent = null;
 0282            if ((int)_statusCode != 200 && (int)_statusCode != 404)
 283            {
 0284                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 285                try
 286                {
 0287                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0288                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0289                    if (_errorBody != null)
 290                    {
 0291                        ex.Body = _errorBody;
 292                    }
 0293                }
 0294                catch (JsonException)
 295                {
 296                    // Ignore the exception
 0297                }
 0298                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0299                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0300                if (_shouldTrace)
 301                {
 0302                    ServiceClientTracing.Error(_invocationId, ex);
 303                }
 0304                _httpRequest.Dispose();
 0305                if (_httpResponse != null)
 306                {
 0307                    _httpResponse.Dispose();
 308                }
 0309                throw ex;
 310            }
 311            // Create Result
 0312            var _result = new AzureOperationResponse<bool,JobScheduleExistsHeaders>();
 0313            _result.Request = _httpRequest;
 0314            _result.Response = _httpResponse;
 0315            _result.Body = _statusCode == System.Net.HttpStatusCode.OK;
 0316            if (_httpResponse.Headers.Contains("request-id"))
 317            {
 0318                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 319            }
 320            try
 321            {
 0322                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleExistsHeaders>(JsonSerializer.Cre
 0323            }
 0324            catch (JsonException ex)
 325            {
 0326                _httpRequest.Dispose();
 0327                if (_httpResponse != null)
 328                {
 0329                    _httpResponse.Dispose();
 330                }
 0331                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 332            }
 0333            if (_shouldTrace)
 334            {
 0335                ServiceClientTracing.Exit(_invocationId, _result);
 336            }
 0337            return _result;
 0338        }
 339
 340        /// <summary>
 341        /// Deletes a Job Schedule from the specified Account.
 342        /// </summary>
 343        /// <remarks>
 344        /// When you delete a Job Schedule, this also deletes all Jobs and Tasks under
 345        /// that schedule. When Tasks are deleted, all the files in their working
 346        /// directories on the Compute Nodes are also deleted (the retention period is
 347        /// ignored). The Job Schedule statistics are no longer accessible once the Job
 348        /// Schedule is deleted, though they are still counted towards Account lifetime
 349        /// statistics.
 350        /// </remarks>
 351        /// <param name='jobScheduleId'>
 352        /// The ID of the Job Schedule to delete.
 353        /// </param>
 354        /// <param name='jobScheduleDeleteOptions'>
 355        /// Additional parameters for the operation
 356        /// </param>
 357        /// <param name='customHeaders'>
 358        /// Headers that will be added to request.
 359        /// </param>
 360        /// <param name='cancellationToken'>
 361        /// The cancellation token.
 362        /// </param>
 363        /// <exception cref="BatchErrorException">
 364        /// Thrown when the operation returned an invalid status code
 365        /// </exception>
 366        /// <exception cref="ValidationException">
 367        /// Thrown when a required parameter is null
 368        /// </exception>
 369        /// <exception cref="System.ArgumentNullException">
 370        /// Thrown when a required parameter is null
 371        /// </exception>
 372        /// <return>
 373        /// A response object containing the response body and response headers.
 374        /// </return>
 375        public async Task<AzureOperationHeaderResponse<JobScheduleDeleteHeaders>> DeleteWithHttpMessagesAsync(string job
 376        {
 0377            if (Client.BatchUrl == null)
 378            {
 0379                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 380            }
 0381            if (jobScheduleId == null)
 382            {
 0383                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 384            }
 0385            if (Client.ApiVersion == null)
 386            {
 0387                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 388            }
 0389            int? timeout = default(int?);
 0390            if (jobScheduleDeleteOptions != null)
 391            {
 0392                timeout = jobScheduleDeleteOptions.Timeout;
 393            }
 0394            System.Guid? clientRequestId = default(System.Guid?);
 0395            if (jobScheduleDeleteOptions != null)
 396            {
 0397                clientRequestId = jobScheduleDeleteOptions.ClientRequestId;
 398            }
 0399            bool? returnClientRequestId = default(bool?);
 0400            if (jobScheduleDeleteOptions != null)
 401            {
 0402                returnClientRequestId = jobScheduleDeleteOptions.ReturnClientRequestId;
 403            }
 0404            System.DateTime? ocpDate = default(System.DateTime?);
 0405            if (jobScheduleDeleteOptions != null)
 406            {
 0407                ocpDate = jobScheduleDeleteOptions.OcpDate;
 408            }
 0409            string ifMatch = default(string);
 0410            if (jobScheduleDeleteOptions != null)
 411            {
 0412                ifMatch = jobScheduleDeleteOptions.IfMatch;
 413            }
 0414            string ifNoneMatch = default(string);
 0415            if (jobScheduleDeleteOptions != null)
 416            {
 0417                ifNoneMatch = jobScheduleDeleteOptions.IfNoneMatch;
 418            }
 0419            System.DateTime? ifModifiedSince = default(System.DateTime?);
 0420            if (jobScheduleDeleteOptions != null)
 421            {
 0422                ifModifiedSince = jobScheduleDeleteOptions.IfModifiedSince;
 423            }
 0424            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 0425            if (jobScheduleDeleteOptions != null)
 426            {
 0427                ifUnmodifiedSince = jobScheduleDeleteOptions.IfUnmodifiedSince;
 428            }
 429            // Tracing
 0430            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0431            string _invocationId = null;
 0432            if (_shouldTrace)
 433            {
 0434                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0435                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0436                tracingParameters.Add("jobScheduleId", jobScheduleId);
 0437                tracingParameters.Add("timeout", timeout);
 0438                tracingParameters.Add("clientRequestId", clientRequestId);
 0439                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0440                tracingParameters.Add("ocpDate", ocpDate);
 0441                tracingParameters.Add("ifMatch", ifMatch);
 0442                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0443                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0444                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0445                tracingParameters.Add("cancellationToken", cancellationToken);
 0446                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 447            }
 448            // Construct URL
 0449            var _baseUrl = Client.BaseUri;
 0450            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}";
 0451            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0452            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 0453            List<string> _queryParameters = new List<string>();
 0454            if (Client.ApiVersion != null)
 455            {
 0456                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 457            }
 0458            if (timeout != null)
 459            {
 0460                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 461            }
 0462            if (_queryParameters.Count > 0)
 463            {
 0464                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 465            }
 466            // Create HTTP transport objects
 0467            var _httpRequest = new HttpRequestMessage();
 0468            HttpResponseMessage _httpResponse = null;
 0469            _httpRequest.Method = new HttpMethod("DELETE");
 0470            _httpRequest.RequestUri = new System.Uri(_url);
 471            // Set Headers
 0472            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 473            {
 0474                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 475            }
 0476            if (Client.AcceptLanguage != null)
 477            {
 0478                if (_httpRequest.Headers.Contains("accept-language"))
 479                {
 0480                    _httpRequest.Headers.Remove("accept-language");
 481                }
 0482                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 483            }
 0484            if (clientRequestId != null)
 485            {
 0486                if (_httpRequest.Headers.Contains("client-request-id"))
 487                {
 0488                    _httpRequest.Headers.Remove("client-request-id");
 489                }
 0490                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 491            }
 0492            if (returnClientRequestId != null)
 493            {
 0494                if (_httpRequest.Headers.Contains("return-client-request-id"))
 495                {
 0496                    _httpRequest.Headers.Remove("return-client-request-id");
 497                }
 0498                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 499            }
 0500            if (ocpDate != null)
 501            {
 0502                if (_httpRequest.Headers.Contains("ocp-date"))
 503                {
 0504                    _httpRequest.Headers.Remove("ocp-date");
 505                }
 0506                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 507            }
 0508            if (ifMatch != null)
 509            {
 0510                if (_httpRequest.Headers.Contains("If-Match"))
 511                {
 0512                    _httpRequest.Headers.Remove("If-Match");
 513                }
 0514                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 515            }
 0516            if (ifNoneMatch != null)
 517            {
 0518                if (_httpRequest.Headers.Contains("If-None-Match"))
 519                {
 0520                    _httpRequest.Headers.Remove("If-None-Match");
 521                }
 0522                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 523            }
 0524            if (ifModifiedSince != null)
 525            {
 0526                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 527                {
 0528                    _httpRequest.Headers.Remove("If-Modified-Since");
 529                }
 0530                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 531            }
 0532            if (ifUnmodifiedSince != null)
 533            {
 0534                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 535                {
 0536                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 537                }
 0538                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 539            }
 540
 541
 0542            if (customHeaders != null)
 543            {
 0544                foreach(var _header in customHeaders)
 545                {
 0546                    if (_httpRequest.Headers.Contains(_header.Key))
 547                    {
 0548                        _httpRequest.Headers.Remove(_header.Key);
 549                    }
 0550                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 551                }
 552            }
 553
 554            // Serialize Request
 0555            string _requestContent = null;
 556            // Set Credentials
 0557            if (Client.Credentials != null)
 558            {
 0559                cancellationToken.ThrowIfCancellationRequested();
 0560                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 561            }
 562            // Send Request
 0563            if (_shouldTrace)
 564            {
 0565                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 566            }
 0567            cancellationToken.ThrowIfCancellationRequested();
 0568            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0569            if (_shouldTrace)
 570            {
 0571                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 572            }
 0573            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0574            cancellationToken.ThrowIfCancellationRequested();
 0575            string _responseContent = null;
 0576            if ((int)_statusCode != 202)
 577            {
 0578                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 579                try
 580                {
 0581                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0582                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0583                    if (_errorBody != null)
 584                    {
 0585                        ex.Body = _errorBody;
 586                    }
 0587                }
 0588                catch (JsonException)
 589                {
 590                    // Ignore the exception
 0591                }
 0592                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0593                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0594                if (_shouldTrace)
 595                {
 0596                    ServiceClientTracing.Error(_invocationId, ex);
 597                }
 0598                _httpRequest.Dispose();
 0599                if (_httpResponse != null)
 600                {
 0601                    _httpResponse.Dispose();
 602                }
 0603                throw ex;
 604            }
 605            // Create Result
 0606            var _result = new AzureOperationHeaderResponse<JobScheduleDeleteHeaders>();
 0607            _result.Request = _httpRequest;
 0608            _result.Response = _httpResponse;
 0609            if (_httpResponse.Headers.Contains("request-id"))
 610            {
 0611                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 612            }
 613            try
 614            {
 0615                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleDeleteHeaders>(JsonSerializer.Cre
 0616            }
 0617            catch (JsonException ex)
 618            {
 0619                _httpRequest.Dispose();
 0620                if (_httpResponse != null)
 621                {
 0622                    _httpResponse.Dispose();
 623                }
 0624                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 625            }
 0626            if (_shouldTrace)
 627            {
 0628                ServiceClientTracing.Exit(_invocationId, _result);
 629            }
 0630            return _result;
 0631        }
 632
 633        /// <summary>
 634        /// Gets information about the specified Job Schedule.
 635        /// </summary>
 636        /// <param name='jobScheduleId'>
 637        /// The ID of the Job Schedule to get.
 638        /// </param>
 639        /// <param name='jobScheduleGetOptions'>
 640        /// Additional parameters for the operation
 641        /// </param>
 642        /// <param name='customHeaders'>
 643        /// Headers that will be added to request.
 644        /// </param>
 645        /// <param name='cancellationToken'>
 646        /// The cancellation token.
 647        /// </param>
 648        /// <exception cref="BatchErrorException">
 649        /// Thrown when the operation returned an invalid status code
 650        /// </exception>
 651        /// <exception cref="SerializationException">
 652        /// Thrown when unable to deserialize the response
 653        /// </exception>
 654        /// <exception cref="ValidationException">
 655        /// Thrown when a required parameter is null
 656        /// </exception>
 657        /// <exception cref="System.ArgumentNullException">
 658        /// Thrown when a required parameter is null
 659        /// </exception>
 660        /// <return>
 661        /// A response object containing the response body and response headers.
 662        /// </return>
 663        public async Task<AzureOperationResponse<CloudJobSchedule,JobScheduleGetHeaders>> GetWithHttpMessagesAsync(strin
 664        {
 1665            if (Client.BatchUrl == null)
 666            {
 0667                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 668            }
 1669            if (jobScheduleId == null)
 670            {
 1671                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 672            }
 0673            if (Client.ApiVersion == null)
 674            {
 0675                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 676            }
 0677            string select = default(string);
 0678            if (jobScheduleGetOptions != null)
 679            {
 0680                select = jobScheduleGetOptions.Select;
 681            }
 0682            string expand = default(string);
 0683            if (jobScheduleGetOptions != null)
 684            {
 0685                expand = jobScheduleGetOptions.Expand;
 686            }
 0687            int? timeout = default(int?);
 0688            if (jobScheduleGetOptions != null)
 689            {
 0690                timeout = jobScheduleGetOptions.Timeout;
 691            }
 0692            System.Guid? clientRequestId = default(System.Guid?);
 0693            if (jobScheduleGetOptions != null)
 694            {
 0695                clientRequestId = jobScheduleGetOptions.ClientRequestId;
 696            }
 0697            bool? returnClientRequestId = default(bool?);
 0698            if (jobScheduleGetOptions != null)
 699            {
 0700                returnClientRequestId = jobScheduleGetOptions.ReturnClientRequestId;
 701            }
 0702            System.DateTime? ocpDate = default(System.DateTime?);
 0703            if (jobScheduleGetOptions != null)
 704            {
 0705                ocpDate = jobScheduleGetOptions.OcpDate;
 706            }
 0707            string ifMatch = default(string);
 0708            if (jobScheduleGetOptions != null)
 709            {
 0710                ifMatch = jobScheduleGetOptions.IfMatch;
 711            }
 0712            string ifNoneMatch = default(string);
 0713            if (jobScheduleGetOptions != null)
 714            {
 0715                ifNoneMatch = jobScheduleGetOptions.IfNoneMatch;
 716            }
 0717            System.DateTime? ifModifiedSince = default(System.DateTime?);
 0718            if (jobScheduleGetOptions != null)
 719            {
 0720                ifModifiedSince = jobScheduleGetOptions.IfModifiedSince;
 721            }
 0722            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 0723            if (jobScheduleGetOptions != null)
 724            {
 0725                ifUnmodifiedSince = jobScheduleGetOptions.IfUnmodifiedSince;
 726            }
 727            // Tracing
 0728            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0729            string _invocationId = null;
 0730            if (_shouldTrace)
 731            {
 0732                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0733                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0734                tracingParameters.Add("jobScheduleId", jobScheduleId);
 0735                tracingParameters.Add("select", select);
 0736                tracingParameters.Add("expand", expand);
 0737                tracingParameters.Add("timeout", timeout);
 0738                tracingParameters.Add("clientRequestId", clientRequestId);
 0739                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 0740                tracingParameters.Add("ocpDate", ocpDate);
 0741                tracingParameters.Add("ifMatch", ifMatch);
 0742                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0743                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 0744                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 0745                tracingParameters.Add("cancellationToken", cancellationToken);
 0746                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 747            }
 748            // Construct URL
 0749            var _baseUrl = Client.BaseUri;
 0750            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}";
 0751            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 0752            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 0753            List<string> _queryParameters = new List<string>();
 0754            if (Client.ApiVersion != null)
 755            {
 0756                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 757            }
 0758            if (select != null)
 759            {
 0760                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 761            }
 0762            if (expand != null)
 763            {
 0764                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
 765            }
 0766            if (timeout != null)
 767            {
 0768                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 769            }
 0770            if (_queryParameters.Count > 0)
 771            {
 0772                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 773            }
 774            // Create HTTP transport objects
 0775            var _httpRequest = new HttpRequestMessage();
 0776            HttpResponseMessage _httpResponse = null;
 0777            _httpRequest.Method = new HttpMethod("GET");
 0778            _httpRequest.RequestUri = new System.Uri(_url);
 779            // Set Headers
 0780            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 781            {
 0782                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 783            }
 0784            if (Client.AcceptLanguage != null)
 785            {
 0786                if (_httpRequest.Headers.Contains("accept-language"))
 787                {
 0788                    _httpRequest.Headers.Remove("accept-language");
 789                }
 0790                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 791            }
 0792            if (clientRequestId != null)
 793            {
 0794                if (_httpRequest.Headers.Contains("client-request-id"))
 795                {
 0796                    _httpRequest.Headers.Remove("client-request-id");
 797                }
 0798                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 799            }
 0800            if (returnClientRequestId != null)
 801            {
 0802                if (_httpRequest.Headers.Contains("return-client-request-id"))
 803                {
 0804                    _httpRequest.Headers.Remove("return-client-request-id");
 805                }
 0806                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 807            }
 0808            if (ocpDate != null)
 809            {
 0810                if (_httpRequest.Headers.Contains("ocp-date"))
 811                {
 0812                    _httpRequest.Headers.Remove("ocp-date");
 813                }
 0814                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 815            }
 0816            if (ifMatch != null)
 817            {
 0818                if (_httpRequest.Headers.Contains("If-Match"))
 819                {
 0820                    _httpRequest.Headers.Remove("If-Match");
 821                }
 0822                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 823            }
 0824            if (ifNoneMatch != null)
 825            {
 0826                if (_httpRequest.Headers.Contains("If-None-Match"))
 827                {
 0828                    _httpRequest.Headers.Remove("If-None-Match");
 829                }
 0830                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 831            }
 0832            if (ifModifiedSince != null)
 833            {
 0834                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 835                {
 0836                    _httpRequest.Headers.Remove("If-Modified-Since");
 837                }
 0838                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 839            }
 0840            if (ifUnmodifiedSince != null)
 841            {
 0842                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 843                {
 0844                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 845                }
 0846                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 847            }
 848
 849
 0850            if (customHeaders != null)
 851            {
 0852                foreach(var _header in customHeaders)
 853                {
 0854                    if (_httpRequest.Headers.Contains(_header.Key))
 855                    {
 0856                        _httpRequest.Headers.Remove(_header.Key);
 857                    }
 0858                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 859                }
 860            }
 861
 862            // Serialize Request
 0863            string _requestContent = null;
 864            // Set Credentials
 0865            if (Client.Credentials != null)
 866            {
 0867                cancellationToken.ThrowIfCancellationRequested();
 0868                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 869            }
 870            // Send Request
 0871            if (_shouldTrace)
 872            {
 0873                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 874            }
 0875            cancellationToken.ThrowIfCancellationRequested();
 0876            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0877            if (_shouldTrace)
 878            {
 0879                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 880            }
 0881            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0882            cancellationToken.ThrowIfCancellationRequested();
 0883            string _responseContent = null;
 0884            if ((int)_statusCode != 200)
 885            {
 0886                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 887                try
 888                {
 0889                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0890                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 0891                    if (_errorBody != null)
 892                    {
 0893                        ex.Body = _errorBody;
 894                    }
 0895                }
 0896                catch (JsonException)
 897                {
 898                    // Ignore the exception
 0899                }
 0900                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0901                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0902                if (_shouldTrace)
 903                {
 0904                    ServiceClientTracing.Error(_invocationId, ex);
 905                }
 0906                _httpRequest.Dispose();
 0907                if (_httpResponse != null)
 908                {
 0909                    _httpResponse.Dispose();
 910                }
 0911                throw ex;
 912            }
 913            // Create Result
 0914            var _result = new AzureOperationResponse<CloudJobSchedule,JobScheduleGetHeaders>();
 0915            _result.Request = _httpRequest;
 0916            _result.Response = _httpResponse;
 0917            if (_httpResponse.Headers.Contains("request-id"))
 918            {
 0919                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 920            }
 921            // Deserialize Response
 0922            if ((int)_statusCode == 200)
 923            {
 0924                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 925                try
 926                {
 0927                    _result.Body = SafeJsonConvert.DeserializeObject<CloudJobSchedule>(_responseContent, Client.Deserial
 0928                }
 0929                catch (JsonException ex)
 930                {
 0931                    _httpRequest.Dispose();
 0932                    if (_httpResponse != null)
 933                    {
 0934                        _httpResponse.Dispose();
 935                    }
 0936                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 937                }
 938            }
 939            try
 940            {
 0941                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleGetHeaders>(JsonSerializer.Create
 0942            }
 0943            catch (JsonException ex)
 944            {
 0945                _httpRequest.Dispose();
 0946                if (_httpResponse != null)
 947                {
 0948                    _httpResponse.Dispose();
 949                }
 0950                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 951            }
 0952            if (_shouldTrace)
 953            {
 0954                ServiceClientTracing.Exit(_invocationId, _result);
 955            }
 0956            return _result;
 0957        }
 958
 959        /// <summary>
 960        /// Updates the properties of the specified Job Schedule.
 961        /// </summary>
 962        /// <remarks>
 963        /// This replaces only the Job Schedule properties specified in the request.
 964        /// For example, if the schedule property is not specified with this request,
 965        /// then the Batch service will keep the existing schedule. Changes to a Job
 966        /// Schedule only impact Jobs created by the schedule after the update has
 967        /// taken place; currently running Jobs are unaffected.
 968        /// </remarks>
 969        /// <param name='jobScheduleId'>
 970        /// The ID of the Job Schedule to update.
 971        /// </param>
 972        /// <param name='jobSchedulePatchParameter'>
 973        /// The parameters for the request.
 974        /// </param>
 975        /// <param name='jobSchedulePatchOptions'>
 976        /// Additional parameters for the operation
 977        /// </param>
 978        /// <param name='customHeaders'>
 979        /// Headers that will be added to request.
 980        /// </param>
 981        /// <param name='cancellationToken'>
 982        /// The cancellation token.
 983        /// </param>
 984        /// <exception cref="BatchErrorException">
 985        /// Thrown when the operation returned an invalid status code
 986        /// </exception>
 987        /// <exception cref="ValidationException">
 988        /// Thrown when a required parameter is null
 989        /// </exception>
 990        /// <exception cref="System.ArgumentNullException">
 991        /// Thrown when a required parameter is null
 992        /// </exception>
 993        /// <return>
 994        /// A response object containing the response body and response headers.
 995        /// </return>
 996        public async Task<AzureOperationHeaderResponse<JobSchedulePatchHeaders>> PatchWithHttpMessagesAsync(string jobSc
 997        {
 0998            if (Client.BatchUrl == null)
 999            {
 01000                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1001            }
 01002            if (jobScheduleId == null)
 1003            {
 01004                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 1005            }
 01006            if (jobSchedulePatchParameter == null)
 1007            {
 01008                throw new ValidationException(ValidationRules.CannotBeNull, "jobSchedulePatchParameter");
 1009            }
 01010            if (Client.ApiVersion == null)
 1011            {
 01012                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1013            }
 01014            int? timeout = default(int?);
 01015            if (jobSchedulePatchOptions != null)
 1016            {
 01017                timeout = jobSchedulePatchOptions.Timeout;
 1018            }
 01019            System.Guid? clientRequestId = default(System.Guid?);
 01020            if (jobSchedulePatchOptions != null)
 1021            {
 01022                clientRequestId = jobSchedulePatchOptions.ClientRequestId;
 1023            }
 01024            bool? returnClientRequestId = default(bool?);
 01025            if (jobSchedulePatchOptions != null)
 1026            {
 01027                returnClientRequestId = jobSchedulePatchOptions.ReturnClientRequestId;
 1028            }
 01029            System.DateTime? ocpDate = default(System.DateTime?);
 01030            if (jobSchedulePatchOptions != null)
 1031            {
 01032                ocpDate = jobSchedulePatchOptions.OcpDate;
 1033            }
 01034            string ifMatch = default(string);
 01035            if (jobSchedulePatchOptions != null)
 1036            {
 01037                ifMatch = jobSchedulePatchOptions.IfMatch;
 1038            }
 01039            string ifNoneMatch = default(string);
 01040            if (jobSchedulePatchOptions != null)
 1041            {
 01042                ifNoneMatch = jobSchedulePatchOptions.IfNoneMatch;
 1043            }
 01044            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01045            if (jobSchedulePatchOptions != null)
 1046            {
 01047                ifModifiedSince = jobSchedulePatchOptions.IfModifiedSince;
 1048            }
 01049            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01050            if (jobSchedulePatchOptions != null)
 1051            {
 01052                ifUnmodifiedSince = jobSchedulePatchOptions.IfUnmodifiedSince;
 1053            }
 1054            // Tracing
 01055            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01056            string _invocationId = null;
 01057            if (_shouldTrace)
 1058            {
 01059                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01060                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01061                tracingParameters.Add("jobScheduleId", jobScheduleId);
 01062                tracingParameters.Add("jobSchedulePatchParameter", jobSchedulePatchParameter);
 01063                tracingParameters.Add("timeout", timeout);
 01064                tracingParameters.Add("clientRequestId", clientRequestId);
 01065                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01066                tracingParameters.Add("ocpDate", ocpDate);
 01067                tracingParameters.Add("ifMatch", ifMatch);
 01068                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01069                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01070                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01071                tracingParameters.Add("cancellationToken", cancellationToken);
 01072                ServiceClientTracing.Enter(_invocationId, this, "Patch", tracingParameters);
 1073            }
 1074            // Construct URL
 01075            var _baseUrl = Client.BaseUri;
 01076            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}";
 01077            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01078            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 01079            List<string> _queryParameters = new List<string>();
 01080            if (Client.ApiVersion != null)
 1081            {
 01082                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1083            }
 01084            if (timeout != null)
 1085            {
 01086                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1087            }
 01088            if (_queryParameters.Count > 0)
 1089            {
 01090                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1091            }
 1092            // Create HTTP transport objects
 01093            var _httpRequest = new HttpRequestMessage();
 01094            HttpResponseMessage _httpResponse = null;
 01095            _httpRequest.Method = new HttpMethod("PATCH");
 01096            _httpRequest.RequestUri = new System.Uri(_url);
 1097            // Set Headers
 01098            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1099            {
 01100                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1101            }
 01102            if (Client.AcceptLanguage != null)
 1103            {
 01104                if (_httpRequest.Headers.Contains("accept-language"))
 1105                {
 01106                    _httpRequest.Headers.Remove("accept-language");
 1107                }
 01108                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1109            }
 01110            if (clientRequestId != null)
 1111            {
 01112                if (_httpRequest.Headers.Contains("client-request-id"))
 1113                {
 01114                    _httpRequest.Headers.Remove("client-request-id");
 1115                }
 01116                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1117            }
 01118            if (returnClientRequestId != null)
 1119            {
 01120                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1121                {
 01122                    _httpRequest.Headers.Remove("return-client-request-id");
 1123                }
 01124                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1125            }
 01126            if (ocpDate != null)
 1127            {
 01128                if (_httpRequest.Headers.Contains("ocp-date"))
 1129                {
 01130                    _httpRequest.Headers.Remove("ocp-date");
 1131                }
 01132                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1133            }
 01134            if (ifMatch != null)
 1135            {
 01136                if (_httpRequest.Headers.Contains("If-Match"))
 1137                {
 01138                    _httpRequest.Headers.Remove("If-Match");
 1139                }
 01140                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1141            }
 01142            if (ifNoneMatch != null)
 1143            {
 01144                if (_httpRequest.Headers.Contains("If-None-Match"))
 1145                {
 01146                    _httpRequest.Headers.Remove("If-None-Match");
 1147                }
 01148                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1149            }
 01150            if (ifModifiedSince != null)
 1151            {
 01152                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1153                {
 01154                    _httpRequest.Headers.Remove("If-Modified-Since");
 1155                }
 01156                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1157            }
 01158            if (ifUnmodifiedSince != null)
 1159            {
 01160                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1161                {
 01162                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1163                }
 01164                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1165            }
 1166
 1167
 01168            if (customHeaders != null)
 1169            {
 01170                foreach(var _header in customHeaders)
 1171                {
 01172                    if (_httpRequest.Headers.Contains(_header.Key))
 1173                    {
 01174                        _httpRequest.Headers.Remove(_header.Key);
 1175                    }
 01176                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1177                }
 1178            }
 1179
 1180            // Serialize Request
 01181            string _requestContent = null;
 01182            if(jobSchedulePatchParameter != null)
 1183            {
 01184                _requestContent = SafeJsonConvert.SerializeObject(jobSchedulePatchParameter, Client.SerializationSetting
 01185                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01186                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1187            }
 1188            // Set Credentials
 01189            if (Client.Credentials != null)
 1190            {
 01191                cancellationToken.ThrowIfCancellationRequested();
 01192                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1193            }
 1194            // Send Request
 01195            if (_shouldTrace)
 1196            {
 01197                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1198            }
 01199            cancellationToken.ThrowIfCancellationRequested();
 01200            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01201            if (_shouldTrace)
 1202            {
 01203                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1204            }
 01205            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01206            cancellationToken.ThrowIfCancellationRequested();
 01207            string _responseContent = null;
 01208            if ((int)_statusCode != 200)
 1209            {
 01210                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1211                try
 1212                {
 01213                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01214                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01215                    if (_errorBody != null)
 1216                    {
 01217                        ex.Body = _errorBody;
 1218                    }
 01219                }
 01220                catch (JsonException)
 1221                {
 1222                    // Ignore the exception
 01223                }
 01224                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01225                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01226                if (_shouldTrace)
 1227                {
 01228                    ServiceClientTracing.Error(_invocationId, ex);
 1229                }
 01230                _httpRequest.Dispose();
 01231                if (_httpResponse != null)
 1232                {
 01233                    _httpResponse.Dispose();
 1234                }
 01235                throw ex;
 1236            }
 1237            // Create Result
 01238            var _result = new AzureOperationHeaderResponse<JobSchedulePatchHeaders>();
 01239            _result.Request = _httpRequest;
 01240            _result.Response = _httpResponse;
 01241            if (_httpResponse.Headers.Contains("request-id"))
 1242            {
 01243                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1244            }
 1245            try
 1246            {
 01247                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobSchedulePatchHeaders>(JsonSerializer.Crea
 01248            }
 01249            catch (JsonException ex)
 1250            {
 01251                _httpRequest.Dispose();
 01252                if (_httpResponse != null)
 1253                {
 01254                    _httpResponse.Dispose();
 1255                }
 01256                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1257            }
 01258            if (_shouldTrace)
 1259            {
 01260                ServiceClientTracing.Exit(_invocationId, _result);
 1261            }
 01262            return _result;
 01263        }
 1264
 1265        /// <summary>
 1266        /// Updates the properties of the specified Job Schedule.
 1267        /// </summary>
 1268        /// <remarks>
 1269        /// This fully replaces all the updatable properties of the Job Schedule. For
 1270        /// example, if the schedule property is not specified with this request, then
 1271        /// the Batch service will remove the existing schedule. Changes to a Job
 1272        /// Schedule only impact Jobs created by the schedule after the update has
 1273        /// taken place; currently running Jobs are unaffected.
 1274        /// </remarks>
 1275        /// <param name='jobScheduleId'>
 1276        /// The ID of the Job Schedule to update.
 1277        /// </param>
 1278        /// <param name='jobScheduleUpdateParameter'>
 1279        /// The parameters for the request.
 1280        /// </param>
 1281        /// <param name='jobScheduleUpdateOptions'>
 1282        /// Additional parameters for the operation
 1283        /// </param>
 1284        /// <param name='customHeaders'>
 1285        /// Headers that will be added to request.
 1286        /// </param>
 1287        /// <param name='cancellationToken'>
 1288        /// The cancellation token.
 1289        /// </param>
 1290        /// <exception cref="BatchErrorException">
 1291        /// Thrown when the operation returned an invalid status code
 1292        /// </exception>
 1293        /// <exception cref="ValidationException">
 1294        /// Thrown when a required parameter is null
 1295        /// </exception>
 1296        /// <exception cref="System.ArgumentNullException">
 1297        /// Thrown when a required parameter is null
 1298        /// </exception>
 1299        /// <return>
 1300        /// A response object containing the response body and response headers.
 1301        /// </return>
 1302        public async Task<AzureOperationHeaderResponse<JobScheduleUpdateHeaders>> UpdateWithHttpMessagesAsync(string job
 1303        {
 01304            if (Client.BatchUrl == null)
 1305            {
 01306                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1307            }
 01308            if (jobScheduleId == null)
 1309            {
 01310                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 1311            }
 01312            if (jobScheduleUpdateParameter == null)
 1313            {
 01314                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleUpdateParameter");
 1315            }
 01316            if (Client.ApiVersion == null)
 1317            {
 01318                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1319            }
 01320            int? timeout = default(int?);
 01321            if (jobScheduleUpdateOptions != null)
 1322            {
 01323                timeout = jobScheduleUpdateOptions.Timeout;
 1324            }
 01325            System.Guid? clientRequestId = default(System.Guid?);
 01326            if (jobScheduleUpdateOptions != null)
 1327            {
 01328                clientRequestId = jobScheduleUpdateOptions.ClientRequestId;
 1329            }
 01330            bool? returnClientRequestId = default(bool?);
 01331            if (jobScheduleUpdateOptions != null)
 1332            {
 01333                returnClientRequestId = jobScheduleUpdateOptions.ReturnClientRequestId;
 1334            }
 01335            System.DateTime? ocpDate = default(System.DateTime?);
 01336            if (jobScheduleUpdateOptions != null)
 1337            {
 01338                ocpDate = jobScheduleUpdateOptions.OcpDate;
 1339            }
 01340            string ifMatch = default(string);
 01341            if (jobScheduleUpdateOptions != null)
 1342            {
 01343                ifMatch = jobScheduleUpdateOptions.IfMatch;
 1344            }
 01345            string ifNoneMatch = default(string);
 01346            if (jobScheduleUpdateOptions != null)
 1347            {
 01348                ifNoneMatch = jobScheduleUpdateOptions.IfNoneMatch;
 1349            }
 01350            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01351            if (jobScheduleUpdateOptions != null)
 1352            {
 01353                ifModifiedSince = jobScheduleUpdateOptions.IfModifiedSince;
 1354            }
 01355            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01356            if (jobScheduleUpdateOptions != null)
 1357            {
 01358                ifUnmodifiedSince = jobScheduleUpdateOptions.IfUnmodifiedSince;
 1359            }
 1360            // Tracing
 01361            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01362            string _invocationId = null;
 01363            if (_shouldTrace)
 1364            {
 01365                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01366                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01367                tracingParameters.Add("jobScheduleId", jobScheduleId);
 01368                tracingParameters.Add("jobScheduleUpdateParameter", jobScheduleUpdateParameter);
 01369                tracingParameters.Add("timeout", timeout);
 01370                tracingParameters.Add("clientRequestId", clientRequestId);
 01371                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01372                tracingParameters.Add("ocpDate", ocpDate);
 01373                tracingParameters.Add("ifMatch", ifMatch);
 01374                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01375                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01376                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01377                tracingParameters.Add("cancellationToken", cancellationToken);
 01378                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 1379            }
 1380            // Construct URL
 01381            var _baseUrl = Client.BaseUri;
 01382            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}";
 01383            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01384            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 01385            List<string> _queryParameters = new List<string>();
 01386            if (Client.ApiVersion != null)
 1387            {
 01388                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1389            }
 01390            if (timeout != null)
 1391            {
 01392                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1393            }
 01394            if (_queryParameters.Count > 0)
 1395            {
 01396                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1397            }
 1398            // Create HTTP transport objects
 01399            var _httpRequest = new HttpRequestMessage();
 01400            HttpResponseMessage _httpResponse = null;
 01401            _httpRequest.Method = new HttpMethod("PUT");
 01402            _httpRequest.RequestUri = new System.Uri(_url);
 1403            // Set Headers
 01404            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1405            {
 01406                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1407            }
 01408            if (Client.AcceptLanguage != null)
 1409            {
 01410                if (_httpRequest.Headers.Contains("accept-language"))
 1411                {
 01412                    _httpRequest.Headers.Remove("accept-language");
 1413                }
 01414                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1415            }
 01416            if (clientRequestId != null)
 1417            {
 01418                if (_httpRequest.Headers.Contains("client-request-id"))
 1419                {
 01420                    _httpRequest.Headers.Remove("client-request-id");
 1421                }
 01422                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1423            }
 01424            if (returnClientRequestId != null)
 1425            {
 01426                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1427                {
 01428                    _httpRequest.Headers.Remove("return-client-request-id");
 1429                }
 01430                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1431            }
 01432            if (ocpDate != null)
 1433            {
 01434                if (_httpRequest.Headers.Contains("ocp-date"))
 1435                {
 01436                    _httpRequest.Headers.Remove("ocp-date");
 1437                }
 01438                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1439            }
 01440            if (ifMatch != null)
 1441            {
 01442                if (_httpRequest.Headers.Contains("If-Match"))
 1443                {
 01444                    _httpRequest.Headers.Remove("If-Match");
 1445                }
 01446                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1447            }
 01448            if (ifNoneMatch != null)
 1449            {
 01450                if (_httpRequest.Headers.Contains("If-None-Match"))
 1451                {
 01452                    _httpRequest.Headers.Remove("If-None-Match");
 1453                }
 01454                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1455            }
 01456            if (ifModifiedSince != null)
 1457            {
 01458                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1459                {
 01460                    _httpRequest.Headers.Remove("If-Modified-Since");
 1461                }
 01462                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1463            }
 01464            if (ifUnmodifiedSince != null)
 1465            {
 01466                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1467                {
 01468                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1469                }
 01470                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1471            }
 1472
 1473
 01474            if (customHeaders != null)
 1475            {
 01476                foreach(var _header in customHeaders)
 1477                {
 01478                    if (_httpRequest.Headers.Contains(_header.Key))
 1479                    {
 01480                        _httpRequest.Headers.Remove(_header.Key);
 1481                    }
 01482                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1483                }
 1484            }
 1485
 1486            // Serialize Request
 01487            string _requestContent = null;
 01488            if(jobScheduleUpdateParameter != null)
 1489            {
 01490                _requestContent = SafeJsonConvert.SerializeObject(jobScheduleUpdateParameter, Client.SerializationSettin
 01491                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01492                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1493            }
 1494            // Set Credentials
 01495            if (Client.Credentials != null)
 1496            {
 01497                cancellationToken.ThrowIfCancellationRequested();
 01498                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1499            }
 1500            // Send Request
 01501            if (_shouldTrace)
 1502            {
 01503                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1504            }
 01505            cancellationToken.ThrowIfCancellationRequested();
 01506            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01507            if (_shouldTrace)
 1508            {
 01509                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1510            }
 01511            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01512            cancellationToken.ThrowIfCancellationRequested();
 01513            string _responseContent = null;
 01514            if ((int)_statusCode != 200)
 1515            {
 01516                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1517                try
 1518                {
 01519                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01520                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01521                    if (_errorBody != null)
 1522                    {
 01523                        ex.Body = _errorBody;
 1524                    }
 01525                }
 01526                catch (JsonException)
 1527                {
 1528                    // Ignore the exception
 01529                }
 01530                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01531                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01532                if (_shouldTrace)
 1533                {
 01534                    ServiceClientTracing.Error(_invocationId, ex);
 1535                }
 01536                _httpRequest.Dispose();
 01537                if (_httpResponse != null)
 1538                {
 01539                    _httpResponse.Dispose();
 1540                }
 01541                throw ex;
 1542            }
 1543            // Create Result
 01544            var _result = new AzureOperationHeaderResponse<JobScheduleUpdateHeaders>();
 01545            _result.Request = _httpRequest;
 01546            _result.Response = _httpResponse;
 01547            if (_httpResponse.Headers.Contains("request-id"))
 1548            {
 01549                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1550            }
 1551            try
 1552            {
 01553                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleUpdateHeaders>(JsonSerializer.Cre
 01554            }
 01555            catch (JsonException ex)
 1556            {
 01557                _httpRequest.Dispose();
 01558                if (_httpResponse != null)
 1559                {
 01560                    _httpResponse.Dispose();
 1561                }
 01562                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1563            }
 01564            if (_shouldTrace)
 1565            {
 01566                ServiceClientTracing.Exit(_invocationId, _result);
 1567            }
 01568            return _result;
 01569        }
 1570
 1571        /// <summary>
 1572        /// Disables a Job Schedule.
 1573        /// </summary>
 1574        /// <remarks>
 1575        /// No new Jobs will be created until the Job Schedule is enabled again.
 1576        /// </remarks>
 1577        /// <param name='jobScheduleId'>
 1578        /// The ID of the Job Schedule to disable.
 1579        /// </param>
 1580        /// <param name='jobScheduleDisableOptions'>
 1581        /// Additional parameters for the operation
 1582        /// </param>
 1583        /// <param name='customHeaders'>
 1584        /// Headers that will be added to request.
 1585        /// </param>
 1586        /// <param name='cancellationToken'>
 1587        /// The cancellation token.
 1588        /// </param>
 1589        /// <exception cref="BatchErrorException">
 1590        /// Thrown when the operation returned an invalid status code
 1591        /// </exception>
 1592        /// <exception cref="ValidationException">
 1593        /// Thrown when a required parameter is null
 1594        /// </exception>
 1595        /// <exception cref="System.ArgumentNullException">
 1596        /// Thrown when a required parameter is null
 1597        /// </exception>
 1598        /// <return>
 1599        /// A response object containing the response body and response headers.
 1600        /// </return>
 1601        public async Task<AzureOperationHeaderResponse<JobScheduleDisableHeaders>> DisableWithHttpMessagesAsync(string j
 1602        {
 01603            if (Client.BatchUrl == null)
 1604            {
 01605                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1606            }
 01607            if (jobScheduleId == null)
 1608            {
 01609                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 1610            }
 01611            if (Client.ApiVersion == null)
 1612            {
 01613                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1614            }
 01615            int? timeout = default(int?);
 01616            if (jobScheduleDisableOptions != null)
 1617            {
 01618                timeout = jobScheduleDisableOptions.Timeout;
 1619            }
 01620            System.Guid? clientRequestId = default(System.Guid?);
 01621            if (jobScheduleDisableOptions != null)
 1622            {
 01623                clientRequestId = jobScheduleDisableOptions.ClientRequestId;
 1624            }
 01625            bool? returnClientRequestId = default(bool?);
 01626            if (jobScheduleDisableOptions != null)
 1627            {
 01628                returnClientRequestId = jobScheduleDisableOptions.ReturnClientRequestId;
 1629            }
 01630            System.DateTime? ocpDate = default(System.DateTime?);
 01631            if (jobScheduleDisableOptions != null)
 1632            {
 01633                ocpDate = jobScheduleDisableOptions.OcpDate;
 1634            }
 01635            string ifMatch = default(string);
 01636            if (jobScheduleDisableOptions != null)
 1637            {
 01638                ifMatch = jobScheduleDisableOptions.IfMatch;
 1639            }
 01640            string ifNoneMatch = default(string);
 01641            if (jobScheduleDisableOptions != null)
 1642            {
 01643                ifNoneMatch = jobScheduleDisableOptions.IfNoneMatch;
 1644            }
 01645            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01646            if (jobScheduleDisableOptions != null)
 1647            {
 01648                ifModifiedSince = jobScheduleDisableOptions.IfModifiedSince;
 1649            }
 01650            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01651            if (jobScheduleDisableOptions != null)
 1652            {
 01653                ifUnmodifiedSince = jobScheduleDisableOptions.IfUnmodifiedSince;
 1654            }
 1655            // Tracing
 01656            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01657            string _invocationId = null;
 01658            if (_shouldTrace)
 1659            {
 01660                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01661                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01662                tracingParameters.Add("jobScheduleId", jobScheduleId);
 01663                tracingParameters.Add("timeout", timeout);
 01664                tracingParameters.Add("clientRequestId", clientRequestId);
 01665                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01666                tracingParameters.Add("ocpDate", ocpDate);
 01667                tracingParameters.Add("ifMatch", ifMatch);
 01668                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01669                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01670                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01671                tracingParameters.Add("cancellationToken", cancellationToken);
 01672                ServiceClientTracing.Enter(_invocationId, this, "Disable", tracingParameters);
 1673            }
 1674            // Construct URL
 01675            var _baseUrl = Client.BaseUri;
 01676            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/disable";
 01677            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01678            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 01679            List<string> _queryParameters = new List<string>();
 01680            if (Client.ApiVersion != null)
 1681            {
 01682                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1683            }
 01684            if (timeout != null)
 1685            {
 01686                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1687            }
 01688            if (_queryParameters.Count > 0)
 1689            {
 01690                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1691            }
 1692            // Create HTTP transport objects
 01693            var _httpRequest = new HttpRequestMessage();
 01694            HttpResponseMessage _httpResponse = null;
 01695            _httpRequest.Method = new HttpMethod("POST");
 01696            _httpRequest.RequestUri = new System.Uri(_url);
 1697            // Set Headers
 01698            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1699            {
 01700                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1701            }
 01702            if (Client.AcceptLanguage != null)
 1703            {
 01704                if (_httpRequest.Headers.Contains("accept-language"))
 1705                {
 01706                    _httpRequest.Headers.Remove("accept-language");
 1707                }
 01708                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1709            }
 01710            if (clientRequestId != null)
 1711            {
 01712                if (_httpRequest.Headers.Contains("client-request-id"))
 1713                {
 01714                    _httpRequest.Headers.Remove("client-request-id");
 1715                }
 01716                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 1717            }
 01718            if (returnClientRequestId != null)
 1719            {
 01720                if (_httpRequest.Headers.Contains("return-client-request-id"))
 1721                {
 01722                    _httpRequest.Headers.Remove("return-client-request-id");
 1723                }
 01724                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 1725            }
 01726            if (ocpDate != null)
 1727            {
 01728                if (_httpRequest.Headers.Contains("ocp-date"))
 1729                {
 01730                    _httpRequest.Headers.Remove("ocp-date");
 1731                }
 01732                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 1733            }
 01734            if (ifMatch != null)
 1735            {
 01736                if (_httpRequest.Headers.Contains("If-Match"))
 1737                {
 01738                    _httpRequest.Headers.Remove("If-Match");
 1739                }
 01740                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 1741            }
 01742            if (ifNoneMatch != null)
 1743            {
 01744                if (_httpRequest.Headers.Contains("If-None-Match"))
 1745                {
 01746                    _httpRequest.Headers.Remove("If-None-Match");
 1747                }
 01748                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 1749            }
 01750            if (ifModifiedSince != null)
 1751            {
 01752                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 1753                {
 01754                    _httpRequest.Headers.Remove("If-Modified-Since");
 1755                }
 01756                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 1757            }
 01758            if (ifUnmodifiedSince != null)
 1759            {
 01760                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 1761                {
 01762                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 1763                }
 01764                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 1765            }
 1766
 1767
 01768            if (customHeaders != null)
 1769            {
 01770                foreach(var _header in customHeaders)
 1771                {
 01772                    if (_httpRequest.Headers.Contains(_header.Key))
 1773                    {
 01774                        _httpRequest.Headers.Remove(_header.Key);
 1775                    }
 01776                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1777                }
 1778            }
 1779
 1780            // Serialize Request
 01781            string _requestContent = null;
 1782            // Set Credentials
 01783            if (Client.Credentials != null)
 1784            {
 01785                cancellationToken.ThrowIfCancellationRequested();
 01786                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1787            }
 1788            // Send Request
 01789            if (_shouldTrace)
 1790            {
 01791                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1792            }
 01793            cancellationToken.ThrowIfCancellationRequested();
 01794            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01795            if (_shouldTrace)
 1796            {
 01797                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1798            }
 01799            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01800            cancellationToken.ThrowIfCancellationRequested();
 01801            string _responseContent = null;
 01802            if ((int)_statusCode != 204)
 1803            {
 01804                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1805                try
 1806                {
 01807                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01808                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 01809                    if (_errorBody != null)
 1810                    {
 01811                        ex.Body = _errorBody;
 1812                    }
 01813                }
 01814                catch (JsonException)
 1815                {
 1816                    // Ignore the exception
 01817                }
 01818                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01819                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01820                if (_shouldTrace)
 1821                {
 01822                    ServiceClientTracing.Error(_invocationId, ex);
 1823                }
 01824                _httpRequest.Dispose();
 01825                if (_httpResponse != null)
 1826                {
 01827                    _httpResponse.Dispose();
 1828                }
 01829                throw ex;
 1830            }
 1831            // Create Result
 01832            var _result = new AzureOperationHeaderResponse<JobScheduleDisableHeaders>();
 01833            _result.Request = _httpRequest;
 01834            _result.Response = _httpResponse;
 01835            if (_httpResponse.Headers.Contains("request-id"))
 1836            {
 01837                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1838            }
 1839            try
 1840            {
 01841                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleDisableHeaders>(JsonSerializer.Cr
 01842            }
 01843            catch (JsonException ex)
 1844            {
 01845                _httpRequest.Dispose();
 01846                if (_httpResponse != null)
 1847                {
 01848                    _httpResponse.Dispose();
 1849                }
 01850                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 1851            }
 01852            if (_shouldTrace)
 1853            {
 01854                ServiceClientTracing.Exit(_invocationId, _result);
 1855            }
 01856            return _result;
 01857        }
 1858
 1859        /// <summary>
 1860        /// Enables a Job Schedule.
 1861        /// </summary>
 1862        /// <param name='jobScheduleId'>
 1863        /// The ID of the Job Schedule to enable.
 1864        /// </param>
 1865        /// <param name='jobScheduleEnableOptions'>
 1866        /// Additional parameters for the operation
 1867        /// </param>
 1868        /// <param name='customHeaders'>
 1869        /// Headers that will be added to request.
 1870        /// </param>
 1871        /// <param name='cancellationToken'>
 1872        /// The cancellation token.
 1873        /// </param>
 1874        /// <exception cref="BatchErrorException">
 1875        /// Thrown when the operation returned an invalid status code
 1876        /// </exception>
 1877        /// <exception cref="ValidationException">
 1878        /// Thrown when a required parameter is null
 1879        /// </exception>
 1880        /// <exception cref="System.ArgumentNullException">
 1881        /// Thrown when a required parameter is null
 1882        /// </exception>
 1883        /// <return>
 1884        /// A response object containing the response body and response headers.
 1885        /// </return>
 1886        public async Task<AzureOperationHeaderResponse<JobScheduleEnableHeaders>> EnableWithHttpMessagesAsync(string job
 1887        {
 01888            if (Client.BatchUrl == null)
 1889            {
 01890                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 1891            }
 01892            if (jobScheduleId == null)
 1893            {
 01894                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 1895            }
 01896            if (Client.ApiVersion == null)
 1897            {
 01898                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1899            }
 01900            int? timeout = default(int?);
 01901            if (jobScheduleEnableOptions != null)
 1902            {
 01903                timeout = jobScheduleEnableOptions.Timeout;
 1904            }
 01905            System.Guid? clientRequestId = default(System.Guid?);
 01906            if (jobScheduleEnableOptions != null)
 1907            {
 01908                clientRequestId = jobScheduleEnableOptions.ClientRequestId;
 1909            }
 01910            bool? returnClientRequestId = default(bool?);
 01911            if (jobScheduleEnableOptions != null)
 1912            {
 01913                returnClientRequestId = jobScheduleEnableOptions.ReturnClientRequestId;
 1914            }
 01915            System.DateTime? ocpDate = default(System.DateTime?);
 01916            if (jobScheduleEnableOptions != null)
 1917            {
 01918                ocpDate = jobScheduleEnableOptions.OcpDate;
 1919            }
 01920            string ifMatch = default(string);
 01921            if (jobScheduleEnableOptions != null)
 1922            {
 01923                ifMatch = jobScheduleEnableOptions.IfMatch;
 1924            }
 01925            string ifNoneMatch = default(string);
 01926            if (jobScheduleEnableOptions != null)
 1927            {
 01928                ifNoneMatch = jobScheduleEnableOptions.IfNoneMatch;
 1929            }
 01930            System.DateTime? ifModifiedSince = default(System.DateTime?);
 01931            if (jobScheduleEnableOptions != null)
 1932            {
 01933                ifModifiedSince = jobScheduleEnableOptions.IfModifiedSince;
 1934            }
 01935            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 01936            if (jobScheduleEnableOptions != null)
 1937            {
 01938                ifUnmodifiedSince = jobScheduleEnableOptions.IfUnmodifiedSince;
 1939            }
 1940            // Tracing
 01941            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01942            string _invocationId = null;
 01943            if (_shouldTrace)
 1944            {
 01945                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01946                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01947                tracingParameters.Add("jobScheduleId", jobScheduleId);
 01948                tracingParameters.Add("timeout", timeout);
 01949                tracingParameters.Add("clientRequestId", clientRequestId);
 01950                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 01951                tracingParameters.Add("ocpDate", ocpDate);
 01952                tracingParameters.Add("ifMatch", ifMatch);
 01953                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 01954                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 01955                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 01956                tracingParameters.Add("cancellationToken", cancellationToken);
 01957                ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters);
 1958            }
 1959            // Construct URL
 01960            var _baseUrl = Client.BaseUri;
 01961            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/enable";
 01962            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 01963            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 01964            List<string> _queryParameters = new List<string>();
 01965            if (Client.ApiVersion != null)
 1966            {
 01967                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1968            }
 01969            if (timeout != null)
 1970            {
 01971                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1972            }
 01973            if (_queryParameters.Count > 0)
 1974            {
 01975                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1976            }
 1977            // Create HTTP transport objects
 01978            var _httpRequest = new HttpRequestMessage();
 01979            HttpResponseMessage _httpResponse = null;
 01980            _httpRequest.Method = new HttpMethod("POST");
 01981            _httpRequest.RequestUri = new System.Uri(_url);
 1982            // Set Headers
 01983            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1984            {
 01985                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1986            }
 01987            if (Client.AcceptLanguage != null)
 1988            {
 01989                if (_httpRequest.Headers.Contains("accept-language"))
 1990                {
 01991                    _httpRequest.Headers.Remove("accept-language");
 1992                }
 01993                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1994            }
 01995            if (clientRequestId != null)
 1996            {
 01997                if (_httpRequest.Headers.Contains("client-request-id"))
 1998                {
 01999                    _httpRequest.Headers.Remove("client-request-id");
 2000                }
 02001                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2002            }
 02003            if (returnClientRequestId != null)
 2004            {
 02005                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2006                {
 02007                    _httpRequest.Headers.Remove("return-client-request-id");
 2008                }
 02009                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2010            }
 02011            if (ocpDate != null)
 2012            {
 02013                if (_httpRequest.Headers.Contains("ocp-date"))
 2014                {
 02015                    _httpRequest.Headers.Remove("ocp-date");
 2016                }
 02017                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2018            }
 02019            if (ifMatch != null)
 2020            {
 02021                if (_httpRequest.Headers.Contains("If-Match"))
 2022                {
 02023                    _httpRequest.Headers.Remove("If-Match");
 2024                }
 02025                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 2026            }
 02027            if (ifNoneMatch != null)
 2028            {
 02029                if (_httpRequest.Headers.Contains("If-None-Match"))
 2030                {
 02031                    _httpRequest.Headers.Remove("If-None-Match");
 2032                }
 02033                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 2034            }
 02035            if (ifModifiedSince != null)
 2036            {
 02037                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 2038                {
 02039                    _httpRequest.Headers.Remove("If-Modified-Since");
 2040                }
 02041                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 2042            }
 02043            if (ifUnmodifiedSince != null)
 2044            {
 02045                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 2046                {
 02047                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 2048                }
 02049                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 2050            }
 2051
 2052
 02053            if (customHeaders != null)
 2054            {
 02055                foreach(var _header in customHeaders)
 2056                {
 02057                    if (_httpRequest.Headers.Contains(_header.Key))
 2058                    {
 02059                        _httpRequest.Headers.Remove(_header.Key);
 2060                    }
 02061                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2062                }
 2063            }
 2064
 2065            // Serialize Request
 02066            string _requestContent = null;
 2067            // Set Credentials
 02068            if (Client.Credentials != null)
 2069            {
 02070                cancellationToken.ThrowIfCancellationRequested();
 02071                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2072            }
 2073            // Send Request
 02074            if (_shouldTrace)
 2075            {
 02076                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2077            }
 02078            cancellationToken.ThrowIfCancellationRequested();
 02079            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02080            if (_shouldTrace)
 2081            {
 02082                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2083            }
 02084            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02085            cancellationToken.ThrowIfCancellationRequested();
 02086            string _responseContent = null;
 02087            if ((int)_statusCode != 204)
 2088            {
 02089                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2090                try
 2091                {
 02092                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02093                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02094                    if (_errorBody != null)
 2095                    {
 02096                        ex.Body = _errorBody;
 2097                    }
 02098                }
 02099                catch (JsonException)
 2100                {
 2101                    // Ignore the exception
 02102                }
 02103                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02104                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02105                if (_shouldTrace)
 2106                {
 02107                    ServiceClientTracing.Error(_invocationId, ex);
 2108                }
 02109                _httpRequest.Dispose();
 02110                if (_httpResponse != null)
 2111                {
 02112                    _httpResponse.Dispose();
 2113                }
 02114                throw ex;
 2115            }
 2116            // Create Result
 02117            var _result = new AzureOperationHeaderResponse<JobScheduleEnableHeaders>();
 02118            _result.Request = _httpRequest;
 02119            _result.Response = _httpResponse;
 02120            if (_httpResponse.Headers.Contains("request-id"))
 2121            {
 02122                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2123            }
 2124            try
 2125            {
 02126                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleEnableHeaders>(JsonSerializer.Cre
 02127            }
 02128            catch (JsonException ex)
 2129            {
 02130                _httpRequest.Dispose();
 02131                if (_httpResponse != null)
 2132                {
 02133                    _httpResponse.Dispose();
 2134                }
 02135                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2136            }
 02137            if (_shouldTrace)
 2138            {
 02139                ServiceClientTracing.Exit(_invocationId, _result);
 2140            }
 02141            return _result;
 02142        }
 2143
 2144        /// <summary>
 2145        /// Terminates a Job Schedule.
 2146        /// </summary>
 2147        /// <param name='jobScheduleId'>
 2148        /// The ID of the Job Schedule to terminates.
 2149        /// </param>
 2150        /// <param name='jobScheduleTerminateOptions'>
 2151        /// Additional parameters for the operation
 2152        /// </param>
 2153        /// <param name='customHeaders'>
 2154        /// Headers that will be added to request.
 2155        /// </param>
 2156        /// <param name='cancellationToken'>
 2157        /// The cancellation token.
 2158        /// </param>
 2159        /// <exception cref="BatchErrorException">
 2160        /// Thrown when the operation returned an invalid status code
 2161        /// </exception>
 2162        /// <exception cref="ValidationException">
 2163        /// Thrown when a required parameter is null
 2164        /// </exception>
 2165        /// <exception cref="System.ArgumentNullException">
 2166        /// Thrown when a required parameter is null
 2167        /// </exception>
 2168        /// <return>
 2169        /// A response object containing the response body and response headers.
 2170        /// </return>
 2171        public async Task<AzureOperationHeaderResponse<JobScheduleTerminateHeaders>> TerminateWithHttpMessagesAsync(stri
 2172        {
 02173            if (Client.BatchUrl == null)
 2174            {
 02175                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2176            }
 02177            if (jobScheduleId == null)
 2178            {
 02179                throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId");
 2180            }
 02181            if (Client.ApiVersion == null)
 2182            {
 02183                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2184            }
 02185            int? timeout = default(int?);
 02186            if (jobScheduleTerminateOptions != null)
 2187            {
 02188                timeout = jobScheduleTerminateOptions.Timeout;
 2189            }
 02190            System.Guid? clientRequestId = default(System.Guid?);
 02191            if (jobScheduleTerminateOptions != null)
 2192            {
 02193                clientRequestId = jobScheduleTerminateOptions.ClientRequestId;
 2194            }
 02195            bool? returnClientRequestId = default(bool?);
 02196            if (jobScheduleTerminateOptions != null)
 2197            {
 02198                returnClientRequestId = jobScheduleTerminateOptions.ReturnClientRequestId;
 2199            }
 02200            System.DateTime? ocpDate = default(System.DateTime?);
 02201            if (jobScheduleTerminateOptions != null)
 2202            {
 02203                ocpDate = jobScheduleTerminateOptions.OcpDate;
 2204            }
 02205            string ifMatch = default(string);
 02206            if (jobScheduleTerminateOptions != null)
 2207            {
 02208                ifMatch = jobScheduleTerminateOptions.IfMatch;
 2209            }
 02210            string ifNoneMatch = default(string);
 02211            if (jobScheduleTerminateOptions != null)
 2212            {
 02213                ifNoneMatch = jobScheduleTerminateOptions.IfNoneMatch;
 2214            }
 02215            System.DateTime? ifModifiedSince = default(System.DateTime?);
 02216            if (jobScheduleTerminateOptions != null)
 2217            {
 02218                ifModifiedSince = jobScheduleTerminateOptions.IfModifiedSince;
 2219            }
 02220            System.DateTime? ifUnmodifiedSince = default(System.DateTime?);
 02221            if (jobScheduleTerminateOptions != null)
 2222            {
 02223                ifUnmodifiedSince = jobScheduleTerminateOptions.IfUnmodifiedSince;
 2224            }
 2225            // Tracing
 02226            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02227            string _invocationId = null;
 02228            if (_shouldTrace)
 2229            {
 02230                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02231                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02232                tracingParameters.Add("jobScheduleId", jobScheduleId);
 02233                tracingParameters.Add("timeout", timeout);
 02234                tracingParameters.Add("clientRequestId", clientRequestId);
 02235                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02236                tracingParameters.Add("ocpDate", ocpDate);
 02237                tracingParameters.Add("ifMatch", ifMatch);
 02238                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 02239                tracingParameters.Add("ifModifiedSince", ifModifiedSince);
 02240                tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince);
 02241                tracingParameters.Add("cancellationToken", cancellationToken);
 02242                ServiceClientTracing.Enter(_invocationId, this, "Terminate", tracingParameters);
 2243            }
 2244            // Construct URL
 02245            var _baseUrl = Client.BaseUri;
 02246            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/terminate";
 02247            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02248            _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId));
 02249            List<string> _queryParameters = new List<string>();
 02250            if (Client.ApiVersion != null)
 2251            {
 02252                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2253            }
 02254            if (timeout != null)
 2255            {
 02256                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2257            }
 02258            if (_queryParameters.Count > 0)
 2259            {
 02260                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2261            }
 2262            // Create HTTP transport objects
 02263            var _httpRequest = new HttpRequestMessage();
 02264            HttpResponseMessage _httpResponse = null;
 02265            _httpRequest.Method = new HttpMethod("POST");
 02266            _httpRequest.RequestUri = new System.Uri(_url);
 2267            // Set Headers
 02268            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2269            {
 02270                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2271            }
 02272            if (Client.AcceptLanguage != null)
 2273            {
 02274                if (_httpRequest.Headers.Contains("accept-language"))
 2275                {
 02276                    _httpRequest.Headers.Remove("accept-language");
 2277                }
 02278                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2279            }
 02280            if (clientRequestId != null)
 2281            {
 02282                if (_httpRequest.Headers.Contains("client-request-id"))
 2283                {
 02284                    _httpRequest.Headers.Remove("client-request-id");
 2285                }
 02286                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2287            }
 02288            if (returnClientRequestId != null)
 2289            {
 02290                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2291                {
 02292                    _httpRequest.Headers.Remove("return-client-request-id");
 2293                }
 02294                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2295            }
 02296            if (ocpDate != null)
 2297            {
 02298                if (_httpRequest.Headers.Contains("ocp-date"))
 2299                {
 02300                    _httpRequest.Headers.Remove("ocp-date");
 2301                }
 02302                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2303            }
 02304            if (ifMatch != null)
 2305            {
 02306                if (_httpRequest.Headers.Contains("If-Match"))
 2307                {
 02308                    _httpRequest.Headers.Remove("If-Match");
 2309                }
 02310                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 2311            }
 02312            if (ifNoneMatch != null)
 2313            {
 02314                if (_httpRequest.Headers.Contains("If-None-Match"))
 2315                {
 02316                    _httpRequest.Headers.Remove("If-None-Match");
 2317                }
 02318                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 2319            }
 02320            if (ifModifiedSince != null)
 2321            {
 02322                if (_httpRequest.Headers.Contains("If-Modified-Since"))
 2323                {
 02324                    _httpRequest.Headers.Remove("If-Modified-Since");
 2325                }
 02326                _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi
 2327            }
 02328            if (ifUnmodifiedSince != null)
 2329            {
 02330                if (_httpRequest.Headers.Contains("If-Unmodified-Since"))
 2331                {
 02332                    _httpRequest.Headers.Remove("If-Unmodified-Since");
 2333                }
 02334                _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn
 2335            }
 2336
 2337
 02338            if (customHeaders != null)
 2339            {
 02340                foreach(var _header in customHeaders)
 2341                {
 02342                    if (_httpRequest.Headers.Contains(_header.Key))
 2343                    {
 02344                        _httpRequest.Headers.Remove(_header.Key);
 2345                    }
 02346                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2347                }
 2348            }
 2349
 2350            // Serialize Request
 02351            string _requestContent = null;
 2352            // Set Credentials
 02353            if (Client.Credentials != null)
 2354            {
 02355                cancellationToken.ThrowIfCancellationRequested();
 02356                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2357            }
 2358            // Send Request
 02359            if (_shouldTrace)
 2360            {
 02361                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2362            }
 02363            cancellationToken.ThrowIfCancellationRequested();
 02364            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02365            if (_shouldTrace)
 2366            {
 02367                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2368            }
 02369            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02370            cancellationToken.ThrowIfCancellationRequested();
 02371            string _responseContent = null;
 02372            if ((int)_statusCode != 202)
 2373            {
 02374                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2375                try
 2376                {
 02377                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02378                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02379                    if (_errorBody != null)
 2380                    {
 02381                        ex.Body = _errorBody;
 2382                    }
 02383                }
 02384                catch (JsonException)
 2385                {
 2386                    // Ignore the exception
 02387                }
 02388                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02389                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02390                if (_shouldTrace)
 2391                {
 02392                    ServiceClientTracing.Error(_invocationId, ex);
 2393                }
 02394                _httpRequest.Dispose();
 02395                if (_httpResponse != null)
 2396                {
 02397                    _httpResponse.Dispose();
 2398                }
 02399                throw ex;
 2400            }
 2401            // Create Result
 02402            var _result = new AzureOperationHeaderResponse<JobScheduleTerminateHeaders>();
 02403            _result.Request = _httpRequest;
 02404            _result.Response = _httpResponse;
 02405            if (_httpResponse.Headers.Contains("request-id"))
 2406            {
 02407                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2408            }
 2409            try
 2410            {
 02411                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleTerminateHeaders>(JsonSerializer.
 02412            }
 02413            catch (JsonException ex)
 2414            {
 02415                _httpRequest.Dispose();
 02416                if (_httpResponse != null)
 2417                {
 02418                    _httpResponse.Dispose();
 2419                }
 02420                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2421            }
 02422            if (_shouldTrace)
 2423            {
 02424                ServiceClientTracing.Exit(_invocationId, _result);
 2425            }
 02426            return _result;
 02427        }
 2428
 2429        /// <summary>
 2430        /// Adds a Job Schedule to the specified Account.
 2431        /// </summary>
 2432        /// <param name='cloudJobSchedule'>
 2433        /// The Job Schedule to be added.
 2434        /// </param>
 2435        /// <param name='jobScheduleAddOptions'>
 2436        /// Additional parameters for the operation
 2437        /// </param>
 2438        /// <param name='customHeaders'>
 2439        /// Headers that will be added to request.
 2440        /// </param>
 2441        /// <param name='cancellationToken'>
 2442        /// The cancellation token.
 2443        /// </param>
 2444        /// <exception cref="BatchErrorException">
 2445        /// Thrown when the operation returned an invalid status code
 2446        /// </exception>
 2447        /// <exception cref="ValidationException">
 2448        /// Thrown when a required parameter is null
 2449        /// </exception>
 2450        /// <exception cref="System.ArgumentNullException">
 2451        /// Thrown when a required parameter is null
 2452        /// </exception>
 2453        /// <return>
 2454        /// A response object containing the response body and response headers.
 2455        /// </return>
 2456        public async Task<AzureOperationHeaderResponse<JobScheduleAddHeaders>> AddWithHttpMessagesAsync(JobScheduleAddPa
 2457        {
 02458            if (Client.BatchUrl == null)
 2459            {
 02460                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2461            }
 02462            if (cloudJobSchedule == null)
 2463            {
 02464                throw new ValidationException(ValidationRules.CannotBeNull, "cloudJobSchedule");
 2465            }
 02466            if (Client.ApiVersion == null)
 2467            {
 02468                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2469            }
 02470            int? timeout = default(int?);
 02471            if (jobScheduleAddOptions != null)
 2472            {
 02473                timeout = jobScheduleAddOptions.Timeout;
 2474            }
 02475            System.Guid? clientRequestId = default(System.Guid?);
 02476            if (jobScheduleAddOptions != null)
 2477            {
 02478                clientRequestId = jobScheduleAddOptions.ClientRequestId;
 2479            }
 02480            bool? returnClientRequestId = default(bool?);
 02481            if (jobScheduleAddOptions != null)
 2482            {
 02483                returnClientRequestId = jobScheduleAddOptions.ReturnClientRequestId;
 2484            }
 02485            System.DateTime? ocpDate = default(System.DateTime?);
 02486            if (jobScheduleAddOptions != null)
 2487            {
 02488                ocpDate = jobScheduleAddOptions.OcpDate;
 2489            }
 2490            // Tracing
 02491            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02492            string _invocationId = null;
 02493            if (_shouldTrace)
 2494            {
 02495                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02496                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02497                tracingParameters.Add("cloudJobSchedule", cloudJobSchedule);
 02498                tracingParameters.Add("timeout", timeout);
 02499                tracingParameters.Add("clientRequestId", clientRequestId);
 02500                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02501                tracingParameters.Add("ocpDate", ocpDate);
 02502                tracingParameters.Add("cancellationToken", cancellationToken);
 02503                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 2504            }
 2505            // Construct URL
 02506            var _baseUrl = Client.BaseUri;
 02507            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules";
 02508            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02509            List<string> _queryParameters = new List<string>();
 02510            if (Client.ApiVersion != null)
 2511            {
 02512                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2513            }
 02514            if (timeout != null)
 2515            {
 02516                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2517            }
 02518            if (_queryParameters.Count > 0)
 2519            {
 02520                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2521            }
 2522            // Create HTTP transport objects
 02523            var _httpRequest = new HttpRequestMessage();
 02524            HttpResponseMessage _httpResponse = null;
 02525            _httpRequest.Method = new HttpMethod("POST");
 02526            _httpRequest.RequestUri = new System.Uri(_url);
 2527            // Set Headers
 02528            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2529            {
 02530                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2531            }
 02532            if (Client.AcceptLanguage != null)
 2533            {
 02534                if (_httpRequest.Headers.Contains("accept-language"))
 2535                {
 02536                    _httpRequest.Headers.Remove("accept-language");
 2537                }
 02538                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2539            }
 02540            if (clientRequestId != null)
 2541            {
 02542                if (_httpRequest.Headers.Contains("client-request-id"))
 2543                {
 02544                    _httpRequest.Headers.Remove("client-request-id");
 2545                }
 02546                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2547            }
 02548            if (returnClientRequestId != null)
 2549            {
 02550                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2551                {
 02552                    _httpRequest.Headers.Remove("return-client-request-id");
 2553                }
 02554                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2555            }
 02556            if (ocpDate != null)
 2557            {
 02558                if (_httpRequest.Headers.Contains("ocp-date"))
 2559                {
 02560                    _httpRequest.Headers.Remove("ocp-date");
 2561                }
 02562                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2563            }
 2564
 2565
 02566            if (customHeaders != null)
 2567            {
 02568                foreach(var _header in customHeaders)
 2569                {
 02570                    if (_httpRequest.Headers.Contains(_header.Key))
 2571                    {
 02572                        _httpRequest.Headers.Remove(_header.Key);
 2573                    }
 02574                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2575                }
 2576            }
 2577
 2578            // Serialize Request
 02579            string _requestContent = null;
 02580            if(cloudJobSchedule != null)
 2581            {
 02582                _requestContent = SafeJsonConvert.SerializeObject(cloudJobSchedule, Client.SerializationSettings);
 02583                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 02584                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2585            }
 2586            // Set Credentials
 02587            if (Client.Credentials != null)
 2588            {
 02589                cancellationToken.ThrowIfCancellationRequested();
 02590                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2591            }
 2592            // Send Request
 02593            if (_shouldTrace)
 2594            {
 02595                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2596            }
 02597            cancellationToken.ThrowIfCancellationRequested();
 02598            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02599            if (_shouldTrace)
 2600            {
 02601                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2602            }
 02603            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02604            cancellationToken.ThrowIfCancellationRequested();
 02605            string _responseContent = null;
 02606            if ((int)_statusCode != 201)
 2607            {
 02608                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2609                try
 2610                {
 02611                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02612                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02613                    if (_errorBody != null)
 2614                    {
 02615                        ex.Body = _errorBody;
 2616                    }
 02617                }
 02618                catch (JsonException)
 2619                {
 2620                    // Ignore the exception
 02621                }
 02622                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02623                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02624                if (_shouldTrace)
 2625                {
 02626                    ServiceClientTracing.Error(_invocationId, ex);
 2627                }
 02628                _httpRequest.Dispose();
 02629                if (_httpResponse != null)
 2630                {
 02631                    _httpResponse.Dispose();
 2632                }
 02633                throw ex;
 2634            }
 2635            // Create Result
 02636            var _result = new AzureOperationHeaderResponse<JobScheduleAddHeaders>();
 02637            _result.Request = _httpRequest;
 02638            _result.Response = _httpResponse;
 02639            if (_httpResponse.Headers.Contains("request-id"))
 2640            {
 02641                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2642            }
 2643            try
 2644            {
 02645                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleAddHeaders>(JsonSerializer.Create
 02646            }
 02647            catch (JsonException ex)
 2648            {
 02649                _httpRequest.Dispose();
 02650                if (_httpResponse != null)
 2651                {
 02652                    _httpResponse.Dispose();
 2653                }
 02654                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2655            }
 02656            if (_shouldTrace)
 2657            {
 02658                ServiceClientTracing.Exit(_invocationId, _result);
 2659            }
 02660            return _result;
 02661        }
 2662
 2663        /// <summary>
 2664        /// Lists all of the Job Schedules in the specified Account.
 2665        /// </summary>
 2666        /// <param name='jobScheduleListOptions'>
 2667        /// Additional parameters for the operation
 2668        /// </param>
 2669        /// <param name='customHeaders'>
 2670        /// Headers that will be added to request.
 2671        /// </param>
 2672        /// <param name='cancellationToken'>
 2673        /// The cancellation token.
 2674        /// </param>
 2675        /// <exception cref="BatchErrorException">
 2676        /// Thrown when the operation returned an invalid status code
 2677        /// </exception>
 2678        /// <exception cref="SerializationException">
 2679        /// Thrown when unable to deserialize the response
 2680        /// </exception>
 2681        /// <exception cref="ValidationException">
 2682        /// Thrown when a required parameter is null
 2683        /// </exception>
 2684        /// <exception cref="System.ArgumentNullException">
 2685        /// Thrown when a required parameter is null
 2686        /// </exception>
 2687        /// <return>
 2688        /// A response object containing the response body and response headers.
 2689        /// </return>
 2690        public async Task<AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>> ListWithHttpMessagesAs
 2691        {
 02692            if (Client.BatchUrl == null)
 2693            {
 02694                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl");
 2695            }
 02696            if (Client.ApiVersion == null)
 2697            {
 02698                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2699            }
 02700            string filter = default(string);
 02701            if (jobScheduleListOptions != null)
 2702            {
 02703                filter = jobScheduleListOptions.Filter;
 2704            }
 02705            string select = default(string);
 02706            if (jobScheduleListOptions != null)
 2707            {
 02708                select = jobScheduleListOptions.Select;
 2709            }
 02710            string expand = default(string);
 02711            if (jobScheduleListOptions != null)
 2712            {
 02713                expand = jobScheduleListOptions.Expand;
 2714            }
 02715            int? maxResults = default(int?);
 02716            if (jobScheduleListOptions != null)
 2717            {
 02718                maxResults = jobScheduleListOptions.MaxResults;
 2719            }
 02720            int? timeout = default(int?);
 02721            if (jobScheduleListOptions != null)
 2722            {
 02723                timeout = jobScheduleListOptions.Timeout;
 2724            }
 02725            System.Guid? clientRequestId = default(System.Guid?);
 02726            if (jobScheduleListOptions != null)
 2727            {
 02728                clientRequestId = jobScheduleListOptions.ClientRequestId;
 2729            }
 02730            bool? returnClientRequestId = default(bool?);
 02731            if (jobScheduleListOptions != null)
 2732            {
 02733                returnClientRequestId = jobScheduleListOptions.ReturnClientRequestId;
 2734            }
 02735            System.DateTime? ocpDate = default(System.DateTime?);
 02736            if (jobScheduleListOptions != null)
 2737            {
 02738                ocpDate = jobScheduleListOptions.OcpDate;
 2739            }
 2740            // Tracing
 02741            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02742            string _invocationId = null;
 02743            if (_shouldTrace)
 2744            {
 02745                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02746                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02747                tracingParameters.Add("filter", filter);
 02748                tracingParameters.Add("select", select);
 02749                tracingParameters.Add("expand", expand);
 02750                tracingParameters.Add("maxResults", maxResults);
 02751                tracingParameters.Add("timeout", timeout);
 02752                tracingParameters.Add("clientRequestId", clientRequestId);
 02753                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 02754                tracingParameters.Add("ocpDate", ocpDate);
 02755                tracingParameters.Add("cancellationToken", cancellationToken);
 02756                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 2757            }
 2758            // Construct URL
 02759            var _baseUrl = Client.BaseUri;
 02760            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules";
 02761            _url = _url.Replace("{batchUrl}", Client.BatchUrl);
 02762            List<string> _queryParameters = new List<string>();
 02763            if (Client.ApiVersion != null)
 2764            {
 02765                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2766            }
 02767            if (filter != null)
 2768            {
 02769                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 2770            }
 02771            if (select != null)
 2772            {
 02773                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select)));
 2774            }
 02775            if (expand != null)
 2776            {
 02777                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
 2778            }
 02779            if (maxResults != null)
 2780            {
 02781                _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 2782            }
 02783            if (timeout != null)
 2784            {
 02785                _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 2786            }
 02787            if (_queryParameters.Count > 0)
 2788            {
 02789                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2790            }
 2791            // Create HTTP transport objects
 02792            var _httpRequest = new HttpRequestMessage();
 02793            HttpResponseMessage _httpResponse = null;
 02794            _httpRequest.Method = new HttpMethod("GET");
 02795            _httpRequest.RequestUri = new System.Uri(_url);
 2796            // Set Headers
 02797            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2798            {
 02799                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 2800            }
 02801            if (Client.AcceptLanguage != null)
 2802            {
 02803                if (_httpRequest.Headers.Contains("accept-language"))
 2804                {
 02805                    _httpRequest.Headers.Remove("accept-language");
 2806                }
 02807                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2808            }
 02809            if (clientRequestId != null)
 2810            {
 02811                if (_httpRequest.Headers.Contains("client-request-id"))
 2812                {
 02813                    _httpRequest.Headers.Remove("client-request-id");
 2814                }
 02815                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 2816            }
 02817            if (returnClientRequestId != null)
 2818            {
 02819                if (_httpRequest.Headers.Contains("return-client-request-id"))
 2820                {
 02821                    _httpRequest.Headers.Remove("return-client-request-id");
 2822                }
 02823                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 2824            }
 02825            if (ocpDate != null)
 2826            {
 02827                if (_httpRequest.Headers.Contains("ocp-date"))
 2828                {
 02829                    _httpRequest.Headers.Remove("ocp-date");
 2830                }
 02831                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 2832            }
 2833
 2834
 02835            if (customHeaders != null)
 2836            {
 02837                foreach(var _header in customHeaders)
 2838                {
 02839                    if (_httpRequest.Headers.Contains(_header.Key))
 2840                    {
 02841                        _httpRequest.Headers.Remove(_header.Key);
 2842                    }
 02843                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2844                }
 2845            }
 2846
 2847            // Serialize Request
 02848            string _requestContent = null;
 2849            // Set Credentials
 02850            if (Client.Credentials != null)
 2851            {
 02852                cancellationToken.ThrowIfCancellationRequested();
 02853                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2854            }
 2855            // Send Request
 02856            if (_shouldTrace)
 2857            {
 02858                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2859            }
 02860            cancellationToken.ThrowIfCancellationRequested();
 02861            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02862            if (_shouldTrace)
 2863            {
 02864                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2865            }
 02866            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02867            cancellationToken.ThrowIfCancellationRequested();
 02868            string _responseContent = null;
 02869            if ((int)_statusCode != 200)
 2870            {
 02871                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2872                try
 2873                {
 02874                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02875                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 02876                    if (_errorBody != null)
 2877                    {
 02878                        ex.Body = _errorBody;
 2879                    }
 02880                }
 02881                catch (JsonException)
 2882                {
 2883                    // Ignore the exception
 02884                }
 02885                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02886                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02887                if (_shouldTrace)
 2888                {
 02889                    ServiceClientTracing.Error(_invocationId, ex);
 2890                }
 02891                _httpRequest.Dispose();
 02892                if (_httpResponse != null)
 2893                {
 02894                    _httpResponse.Dispose();
 2895                }
 02896                throw ex;
 2897            }
 2898            // Create Result
 02899            var _result = new AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>();
 02900            _result.Request = _httpRequest;
 02901            _result.Response = _httpResponse;
 02902            if (_httpResponse.Headers.Contains("request-id"))
 2903            {
 02904                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 2905            }
 2906            // Deserialize Response
 02907            if ((int)_statusCode == 200)
 2908            {
 02909                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2910                try
 2911                {
 02912                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJobSchedule>>(_responseContent, Client.De
 02913                }
 02914                catch (JsonException ex)
 2915                {
 02916                    _httpRequest.Dispose();
 02917                    if (_httpResponse != null)
 2918                    {
 02919                        _httpResponse.Dispose();
 2920                    }
 02921                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2922                }
 2923            }
 2924            try
 2925            {
 02926                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleListHeaders>(JsonSerializer.Creat
 02927            }
 02928            catch (JsonException ex)
 2929            {
 02930                _httpRequest.Dispose();
 02931                if (_httpResponse != null)
 2932                {
 02933                    _httpResponse.Dispose();
 2934                }
 02935                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 2936            }
 02937            if (_shouldTrace)
 2938            {
 02939                ServiceClientTracing.Exit(_invocationId, _result);
 2940            }
 02941            return _result;
 02942        }
 2943
 2944        /// <summary>
 2945        /// Lists all of the Job Schedules in the specified Account.
 2946        /// </summary>
 2947        /// <param name='nextPageLink'>
 2948        /// The NextLink from the previous successful call to List operation.
 2949        /// </param>
 2950        /// <param name='jobScheduleListNextOptions'>
 2951        /// Additional parameters for the operation
 2952        /// </param>
 2953        /// <param name='customHeaders'>
 2954        /// Headers that will be added to request.
 2955        /// </param>
 2956        /// <param name='cancellationToken'>
 2957        /// The cancellation token.
 2958        /// </param>
 2959        /// <exception cref="BatchErrorException">
 2960        /// Thrown when the operation returned an invalid status code
 2961        /// </exception>
 2962        /// <exception cref="SerializationException">
 2963        /// Thrown when unable to deserialize the response
 2964        /// </exception>
 2965        /// <exception cref="ValidationException">
 2966        /// Thrown when a required parameter is null
 2967        /// </exception>
 2968        /// <exception cref="System.ArgumentNullException">
 2969        /// Thrown when a required parameter is null
 2970        /// </exception>
 2971        /// <return>
 2972        /// A response object containing the response body and response headers.
 2973        /// </return>
 2974        public async Task<AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>> ListNextWithHttpMessag
 2975        {
 02976            if (nextPageLink == null)
 2977            {
 02978                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 2979            }
 02980            System.Guid? clientRequestId = default(System.Guid?);
 02981            if (jobScheduleListNextOptions != null)
 2982            {
 02983                clientRequestId = jobScheduleListNextOptions.ClientRequestId;
 2984            }
 02985            bool? returnClientRequestId = default(bool?);
 02986            if (jobScheduleListNextOptions != null)
 2987            {
 02988                returnClientRequestId = jobScheduleListNextOptions.ReturnClientRequestId;
 2989            }
 02990            System.DateTime? ocpDate = default(System.DateTime?);
 02991            if (jobScheduleListNextOptions != null)
 2992            {
 02993                ocpDate = jobScheduleListNextOptions.OcpDate;
 2994            }
 2995            // Tracing
 02996            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02997            string _invocationId = null;
 02998            if (_shouldTrace)
 2999            {
 03000                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03001                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03002                tracingParameters.Add("nextPageLink", nextPageLink);
 03003                tracingParameters.Add("clientRequestId", clientRequestId);
 03004                tracingParameters.Add("returnClientRequestId", returnClientRequestId);
 03005                tracingParameters.Add("ocpDate", ocpDate);
 03006                tracingParameters.Add("cancellationToken", cancellationToken);
 03007                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 3008            }
 3009            // Construct URL
 03010            string _url = "{nextLink}";
 03011            _url = _url.Replace("{nextLink}", nextPageLink);
 03012            List<string> _queryParameters = new List<string>();
 03013            if (_queryParameters.Count > 0)
 3014            {
 03015                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 3016            }
 3017            // Create HTTP transport objects
 03018            var _httpRequest = new HttpRequestMessage();
 03019            HttpResponseMessage _httpResponse = null;
 03020            _httpRequest.Method = new HttpMethod("GET");
 03021            _httpRequest.RequestUri = new System.Uri(_url);
 3022            // Set Headers
 03023            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 3024            {
 03025                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 3026            }
 03027            if (Client.AcceptLanguage != null)
 3028            {
 03029                if (_httpRequest.Headers.Contains("accept-language"))
 3030                {
 03031                    _httpRequest.Headers.Remove("accept-language");
 3032                }
 03033                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 3034            }
 03035            if (clientRequestId != null)
 3036            {
 03037                if (_httpRequest.Headers.Contains("client-request-id"))
 3038                {
 03039                    _httpRequest.Headers.Remove("client-request-id");
 3040                }
 03041                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 3042            }
 03043            if (returnClientRequestId != null)
 3044            {
 03045                if (_httpRequest.Headers.Contains("return-client-request-id"))
 3046                {
 03047                    _httpRequest.Headers.Remove("return-client-request-id");
 3048                }
 03049                _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject
 3050            }
 03051            if (ocpDate != null)
 3052            {
 03053                if (_httpRequest.Headers.Contains("ocp-date"))
 3054                {
 03055                    _httpRequest.Headers.Remove("ocp-date");
 3056                }
 03057                _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da
 3058            }
 3059
 3060
 03061            if (customHeaders != null)
 3062            {
 03063                foreach(var _header in customHeaders)
 3064                {
 03065                    if (_httpRequest.Headers.Contains(_header.Key))
 3066                    {
 03067                        _httpRequest.Headers.Remove(_header.Key);
 3068                    }
 03069                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3070                }
 3071            }
 3072
 3073            // Serialize Request
 03074            string _requestContent = null;
 3075            // Set Credentials
 03076            if (Client.Credentials != null)
 3077            {
 03078                cancellationToken.ThrowIfCancellationRequested();
 03079                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3080            }
 3081            // Send Request
 03082            if (_shouldTrace)
 3083            {
 03084                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3085            }
 03086            cancellationToken.ThrowIfCancellationRequested();
 03087            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03088            if (_shouldTrace)
 3089            {
 03090                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3091            }
 03092            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03093            cancellationToken.ThrowIfCancellationRequested();
 03094            string _responseContent = null;
 03095            if ((int)_statusCode != 200)
 3096            {
 03097                var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 3098                try
 3099                {
 03100                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03101                    BatchError _errorBody =  SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese
 03102                    if (_errorBody != null)
 3103                    {
 03104                        ex.Body = _errorBody;
 3105                    }
 03106                }
 03107                catch (JsonException)
 3108                {
 3109                    // Ignore the exception
 03110                }
 03111                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03112                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03113                if (_shouldTrace)
 3114                {
 03115                    ServiceClientTracing.Error(_invocationId, ex);
 3116                }
 03117                _httpRequest.Dispose();
 03118                if (_httpResponse != null)
 3119                {
 03120                    _httpResponse.Dispose();
 3121                }
 03122                throw ex;
 3123            }
 3124            // Create Result
 03125            var _result = new AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>();
 03126            _result.Request = _httpRequest;
 03127            _result.Response = _httpResponse;
 03128            if (_httpResponse.Headers.Contains("request-id"))
 3129            {
 03130                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 3131            }
 3132            // Deserialize Response
 03133            if ((int)_statusCode == 200)
 3134            {
 03135                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3136                try
 3137                {
 03138                    _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJobSchedule>>(_responseContent, Client.De
 03139                }
 03140                catch (JsonException ex)
 3141                {
 03142                    _httpRequest.Dispose();
 03143                    if (_httpResponse != null)
 3144                    {
 03145                        _httpResponse.Dispose();
 3146                    }
 03147                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3148                }
 3149            }
 3150            try
 3151            {
 03152                _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleListHeaders>(JsonSerializer.Creat
 03153            }
 03154            catch (JsonException ex)
 3155            {
 03156                _httpRequest.Dispose();
 03157                if (_httpResponse != null)
 3158                {
 03159                    _httpResponse.Dispose();
 3160                }
 03161                throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().
 3162            }
 03163            if (_shouldTrace)
 3164            {
 03165                ServiceClientTracing.Exit(_invocationId, _result);
 3166            }
 03167            return _result;
 03168        }
 3169
 3170    }
 3171}