| | 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 | |
|
| | 11 | | namespace 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> |
| 148 | 40 | | internal JobScheduleOperations(BatchServiceClient client) |
| | 41 | | { |
| 148 | 42 | | if (client == null) |
| | 43 | | { |
| 0 | 44 | | throw new System.ArgumentNullException("client"); |
| | 45 | | } |
| 148 | 46 | | Client = client; |
| 148 | 47 | | } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Gets a reference to the BatchServiceClient |
| | 51 | | /// </summary> |
| 141 | 52 | | 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 | | { |
| 0 | 83 | | if (Client.BatchUrl == null) |
| | 84 | | { |
| 0 | 85 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 86 | | } |
| 0 | 87 | | if (jobScheduleId == null) |
| | 88 | | { |
| 0 | 89 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 90 | | } |
| 0 | 91 | | if (Client.ApiVersion == null) |
| | 92 | | { |
| 0 | 93 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 94 | | } |
| 0 | 95 | | int? timeout = default(int?); |
| 0 | 96 | | if (jobScheduleExistsOptions != null) |
| | 97 | | { |
| 0 | 98 | | timeout = jobScheduleExistsOptions.Timeout; |
| | 99 | | } |
| 0 | 100 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 101 | | if (jobScheduleExistsOptions != null) |
| | 102 | | { |
| 0 | 103 | | clientRequestId = jobScheduleExistsOptions.ClientRequestId; |
| | 104 | | } |
| 0 | 105 | | bool? returnClientRequestId = default(bool?); |
| 0 | 106 | | if (jobScheduleExistsOptions != null) |
| | 107 | | { |
| 0 | 108 | | returnClientRequestId = jobScheduleExistsOptions.ReturnClientRequestId; |
| | 109 | | } |
| 0 | 110 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 111 | | if (jobScheduleExistsOptions != null) |
| | 112 | | { |
| 0 | 113 | | ocpDate = jobScheduleExistsOptions.OcpDate; |
| | 114 | | } |
| 0 | 115 | | string ifMatch = default(string); |
| 0 | 116 | | if (jobScheduleExistsOptions != null) |
| | 117 | | { |
| 0 | 118 | | ifMatch = jobScheduleExistsOptions.IfMatch; |
| | 119 | | } |
| 0 | 120 | | string ifNoneMatch = default(string); |
| 0 | 121 | | if (jobScheduleExistsOptions != null) |
| | 122 | | { |
| 0 | 123 | | ifNoneMatch = jobScheduleExistsOptions.IfNoneMatch; |
| | 124 | | } |
| 0 | 125 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 126 | | if (jobScheduleExistsOptions != null) |
| | 127 | | { |
| 0 | 128 | | ifModifiedSince = jobScheduleExistsOptions.IfModifiedSince; |
| | 129 | | } |
| 0 | 130 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 131 | | if (jobScheduleExistsOptions != null) |
| | 132 | | { |
| 0 | 133 | | ifUnmodifiedSince = jobScheduleExistsOptions.IfUnmodifiedSince; |
| | 134 | | } |
| | 135 | | // Tracing |
| 0 | 136 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 137 | | string _invocationId = null; |
| 0 | 138 | | if (_shouldTrace) |
| | 139 | | { |
| 0 | 140 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 141 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 142 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 143 | | tracingParameters.Add("timeout", timeout); |
| 0 | 144 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 145 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 146 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 147 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 148 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 149 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 150 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 151 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 152 | | ServiceClientTracing.Enter(_invocationId, this, "Exists", tracingParameters); |
| | 153 | | } |
| | 154 | | // Construct URL |
| 0 | 155 | | var _baseUrl = Client.BaseUri; |
| 0 | 156 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}"; |
| 0 | 157 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 158 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 159 | | List<string> _queryParameters = new List<string>(); |
| 0 | 160 | | if (Client.ApiVersion != null) |
| | 161 | | { |
| 0 | 162 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 163 | | } |
| 0 | 164 | | if (timeout != null) |
| | 165 | | { |
| 0 | 166 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 167 | | } |
| 0 | 168 | | if (_queryParameters.Count > 0) |
| | 169 | | { |
| 0 | 170 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 171 | | } |
| | 172 | | // Create HTTP transport objects |
| 0 | 173 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 174 | | HttpResponseMessage _httpResponse = null; |
| 0 | 175 | | _httpRequest.Method = new HttpMethod("HEAD"); |
| 0 | 176 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 177 | | // Set Headers |
| 0 | 178 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 179 | | { |
| 0 | 180 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 181 | | } |
| 0 | 182 | | if (Client.AcceptLanguage != null) |
| | 183 | | { |
| 0 | 184 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 185 | | { |
| 0 | 186 | | _httpRequest.Headers.Remove("accept-language"); |
| | 187 | | } |
| 0 | 188 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 189 | | } |
| 0 | 190 | | if (clientRequestId != null) |
| | 191 | | { |
| 0 | 192 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 193 | | { |
| 0 | 194 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 195 | | } |
| 0 | 196 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 197 | | } |
| 0 | 198 | | if (returnClientRequestId != null) |
| | 199 | | { |
| 0 | 200 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 201 | | { |
| 0 | 202 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 203 | | } |
| 0 | 204 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 205 | | } |
| 0 | 206 | | if (ocpDate != null) |
| | 207 | | { |
| 0 | 208 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 209 | | { |
| 0 | 210 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 211 | | } |
| 0 | 212 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 213 | | } |
| 0 | 214 | | if (ifMatch != null) |
| | 215 | | { |
| 0 | 216 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 217 | | { |
| 0 | 218 | | _httpRequest.Headers.Remove("If-Match"); |
| | 219 | | } |
| 0 | 220 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 221 | | } |
| 0 | 222 | | if (ifNoneMatch != null) |
| | 223 | | { |
| 0 | 224 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 225 | | { |
| 0 | 226 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 227 | | } |
| 0 | 228 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 229 | | } |
| 0 | 230 | | if (ifModifiedSince != null) |
| | 231 | | { |
| 0 | 232 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 233 | | { |
| 0 | 234 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 235 | | } |
| 0 | 236 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 237 | | } |
| 0 | 238 | | if (ifUnmodifiedSince != null) |
| | 239 | | { |
| 0 | 240 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 241 | | { |
| 0 | 242 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 243 | | } |
| 0 | 244 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 245 | | } |
| | 246 | |
|
| | 247 | |
|
| 0 | 248 | | if (customHeaders != null) |
| | 249 | | { |
| 0 | 250 | | foreach(var _header in customHeaders) |
| | 251 | | { |
| 0 | 252 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 253 | | { |
| 0 | 254 | | _httpRequest.Headers.Remove(_header.Key); |
| | 255 | | } |
| 0 | 256 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 257 | | } |
| | 258 | | } |
| | 259 | |
|
| | 260 | | // Serialize Request |
| 0 | 261 | | string _requestContent = null; |
| | 262 | | // Set Credentials |
| 0 | 263 | | if (Client.Credentials != null) |
| | 264 | | { |
| 0 | 265 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 266 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 267 | | } |
| | 268 | | // Send Request |
| 0 | 269 | | if (_shouldTrace) |
| | 270 | | { |
| 0 | 271 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 272 | | } |
| 0 | 273 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 274 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons |
| 0 | 275 | | if (_shouldTrace) |
| | 276 | | { |
| 0 | 277 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 278 | | } |
| 0 | 279 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 280 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 281 | | string _responseContent = null; |
| 0 | 282 | | if ((int)_statusCode != 200 && (int)_statusCode != 404) |
| | 283 | | { |
| 0 | 284 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 285 | | try |
| | 286 | | { |
| 0 | 287 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 288 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 289 | | if (_errorBody != null) |
| | 290 | | { |
| 0 | 291 | | ex.Body = _errorBody; |
| | 292 | | } |
| 0 | 293 | | } |
| 0 | 294 | | catch (JsonException) |
| | 295 | | { |
| | 296 | | // Ignore the exception |
| 0 | 297 | | } |
| 0 | 298 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 299 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 300 | | if (_shouldTrace) |
| | 301 | | { |
| 0 | 302 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 303 | | } |
| 0 | 304 | | _httpRequest.Dispose(); |
| 0 | 305 | | if (_httpResponse != null) |
| | 306 | | { |
| 0 | 307 | | _httpResponse.Dispose(); |
| | 308 | | } |
| 0 | 309 | | throw ex; |
| | 310 | | } |
| | 311 | | // Create Result |
| 0 | 312 | | var _result = new AzureOperationResponse<bool,JobScheduleExistsHeaders>(); |
| 0 | 313 | | _result.Request = _httpRequest; |
| 0 | 314 | | _result.Response = _httpResponse; |
| 0 | 315 | | _result.Body = _statusCode == System.Net.HttpStatusCode.OK; |
| 0 | 316 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 317 | | { |
| 0 | 318 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 319 | | } |
| | 320 | | try |
| | 321 | | { |
| 0 | 322 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleExistsHeaders>(JsonSerializer.Cre |
| 0 | 323 | | } |
| 0 | 324 | | catch (JsonException ex) |
| | 325 | | { |
| 0 | 326 | | _httpRequest.Dispose(); |
| 0 | 327 | | if (_httpResponse != null) |
| | 328 | | { |
| 0 | 329 | | _httpResponse.Dispose(); |
| | 330 | | } |
| 0 | 331 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 332 | | } |
| 0 | 333 | | if (_shouldTrace) |
| | 334 | | { |
| 0 | 335 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 336 | | } |
| 0 | 337 | | return _result; |
| 0 | 338 | | } |
| | 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 | | { |
| 0 | 377 | | if (Client.BatchUrl == null) |
| | 378 | | { |
| 0 | 379 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 380 | | } |
| 0 | 381 | | if (jobScheduleId == null) |
| | 382 | | { |
| 0 | 383 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 384 | | } |
| 0 | 385 | | if (Client.ApiVersion == null) |
| | 386 | | { |
| 0 | 387 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 388 | | } |
| 0 | 389 | | int? timeout = default(int?); |
| 0 | 390 | | if (jobScheduleDeleteOptions != null) |
| | 391 | | { |
| 0 | 392 | | timeout = jobScheduleDeleteOptions.Timeout; |
| | 393 | | } |
| 0 | 394 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 395 | | if (jobScheduleDeleteOptions != null) |
| | 396 | | { |
| 0 | 397 | | clientRequestId = jobScheduleDeleteOptions.ClientRequestId; |
| | 398 | | } |
| 0 | 399 | | bool? returnClientRequestId = default(bool?); |
| 0 | 400 | | if (jobScheduleDeleteOptions != null) |
| | 401 | | { |
| 0 | 402 | | returnClientRequestId = jobScheduleDeleteOptions.ReturnClientRequestId; |
| | 403 | | } |
| 0 | 404 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 405 | | if (jobScheduleDeleteOptions != null) |
| | 406 | | { |
| 0 | 407 | | ocpDate = jobScheduleDeleteOptions.OcpDate; |
| | 408 | | } |
| 0 | 409 | | string ifMatch = default(string); |
| 0 | 410 | | if (jobScheduleDeleteOptions != null) |
| | 411 | | { |
| 0 | 412 | | ifMatch = jobScheduleDeleteOptions.IfMatch; |
| | 413 | | } |
| 0 | 414 | | string ifNoneMatch = default(string); |
| 0 | 415 | | if (jobScheduleDeleteOptions != null) |
| | 416 | | { |
| 0 | 417 | | ifNoneMatch = jobScheduleDeleteOptions.IfNoneMatch; |
| | 418 | | } |
| 0 | 419 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 420 | | if (jobScheduleDeleteOptions != null) |
| | 421 | | { |
| 0 | 422 | | ifModifiedSince = jobScheduleDeleteOptions.IfModifiedSince; |
| | 423 | | } |
| 0 | 424 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 425 | | if (jobScheduleDeleteOptions != null) |
| | 426 | | { |
| 0 | 427 | | ifUnmodifiedSince = jobScheduleDeleteOptions.IfUnmodifiedSince; |
| | 428 | | } |
| | 429 | | // Tracing |
| 0 | 430 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 431 | | string _invocationId = null; |
| 0 | 432 | | if (_shouldTrace) |
| | 433 | | { |
| 0 | 434 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 435 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 436 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 437 | | tracingParameters.Add("timeout", timeout); |
| 0 | 438 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 439 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 440 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 441 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 442 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 443 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 444 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 445 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 446 | | ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); |
| | 447 | | } |
| | 448 | | // Construct URL |
| 0 | 449 | | var _baseUrl = Client.BaseUri; |
| 0 | 450 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}"; |
| 0 | 451 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 452 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 453 | | List<string> _queryParameters = new List<string>(); |
| 0 | 454 | | if (Client.ApiVersion != null) |
| | 455 | | { |
| 0 | 456 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 457 | | } |
| 0 | 458 | | if (timeout != null) |
| | 459 | | { |
| 0 | 460 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 461 | | } |
| 0 | 462 | | if (_queryParameters.Count > 0) |
| | 463 | | { |
| 0 | 464 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 465 | | } |
| | 466 | | // Create HTTP transport objects |
| 0 | 467 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 468 | | HttpResponseMessage _httpResponse = null; |
| 0 | 469 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 470 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 471 | | // Set Headers |
| 0 | 472 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 473 | | { |
| 0 | 474 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 475 | | } |
| 0 | 476 | | if (Client.AcceptLanguage != null) |
| | 477 | | { |
| 0 | 478 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 479 | | { |
| 0 | 480 | | _httpRequest.Headers.Remove("accept-language"); |
| | 481 | | } |
| 0 | 482 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 483 | | } |
| 0 | 484 | | if (clientRequestId != null) |
| | 485 | | { |
| 0 | 486 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 487 | | { |
| 0 | 488 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 489 | | } |
| 0 | 490 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 491 | | } |
| 0 | 492 | | if (returnClientRequestId != null) |
| | 493 | | { |
| 0 | 494 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 495 | | { |
| 0 | 496 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 497 | | } |
| 0 | 498 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 499 | | } |
| 0 | 500 | | if (ocpDate != null) |
| | 501 | | { |
| 0 | 502 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 503 | | { |
| 0 | 504 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 505 | | } |
| 0 | 506 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 507 | | } |
| 0 | 508 | | if (ifMatch != null) |
| | 509 | | { |
| 0 | 510 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 511 | | { |
| 0 | 512 | | _httpRequest.Headers.Remove("If-Match"); |
| | 513 | | } |
| 0 | 514 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 515 | | } |
| 0 | 516 | | if (ifNoneMatch != null) |
| | 517 | | { |
| 0 | 518 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 519 | | { |
| 0 | 520 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 521 | | } |
| 0 | 522 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 523 | | } |
| 0 | 524 | | if (ifModifiedSince != null) |
| | 525 | | { |
| 0 | 526 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 527 | | { |
| 0 | 528 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 529 | | } |
| 0 | 530 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 531 | | } |
| 0 | 532 | | if (ifUnmodifiedSince != null) |
| | 533 | | { |
| 0 | 534 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 535 | | { |
| 0 | 536 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 537 | | } |
| 0 | 538 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 539 | | } |
| | 540 | |
|
| | 541 | |
|
| 0 | 542 | | if (customHeaders != null) |
| | 543 | | { |
| 0 | 544 | | foreach(var _header in customHeaders) |
| | 545 | | { |
| 0 | 546 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 547 | | { |
| 0 | 548 | | _httpRequest.Headers.Remove(_header.Key); |
| | 549 | | } |
| 0 | 550 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 551 | | } |
| | 552 | | } |
| | 553 | |
|
| | 554 | | // Serialize Request |
| 0 | 555 | | string _requestContent = null; |
| | 556 | | // Set Credentials |
| 0 | 557 | | if (Client.Credentials != null) |
| | 558 | | { |
| 0 | 559 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 560 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 561 | | } |
| | 562 | | // Send Request |
| 0 | 563 | | if (_shouldTrace) |
| | 564 | | { |
| 0 | 565 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 566 | | } |
| 0 | 567 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 568 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 569 | | if (_shouldTrace) |
| | 570 | | { |
| 0 | 571 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 572 | | } |
| 0 | 573 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 574 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 575 | | string _responseContent = null; |
| 0 | 576 | | if ((int)_statusCode != 202) |
| | 577 | | { |
| 0 | 578 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 579 | | try |
| | 580 | | { |
| 0 | 581 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 582 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 583 | | if (_errorBody != null) |
| | 584 | | { |
| 0 | 585 | | ex.Body = _errorBody; |
| | 586 | | } |
| 0 | 587 | | } |
| 0 | 588 | | catch (JsonException) |
| | 589 | | { |
| | 590 | | // Ignore the exception |
| 0 | 591 | | } |
| 0 | 592 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 593 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 594 | | if (_shouldTrace) |
| | 595 | | { |
| 0 | 596 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 597 | | } |
| 0 | 598 | | _httpRequest.Dispose(); |
| 0 | 599 | | if (_httpResponse != null) |
| | 600 | | { |
| 0 | 601 | | _httpResponse.Dispose(); |
| | 602 | | } |
| 0 | 603 | | throw ex; |
| | 604 | | } |
| | 605 | | // Create Result |
| 0 | 606 | | var _result = new AzureOperationHeaderResponse<JobScheduleDeleteHeaders>(); |
| 0 | 607 | | _result.Request = _httpRequest; |
| 0 | 608 | | _result.Response = _httpResponse; |
| 0 | 609 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 610 | | { |
| 0 | 611 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 612 | | } |
| | 613 | | try |
| | 614 | | { |
| 0 | 615 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleDeleteHeaders>(JsonSerializer.Cre |
| 0 | 616 | | } |
| 0 | 617 | | catch (JsonException ex) |
| | 618 | | { |
| 0 | 619 | | _httpRequest.Dispose(); |
| 0 | 620 | | if (_httpResponse != null) |
| | 621 | | { |
| 0 | 622 | | _httpResponse.Dispose(); |
| | 623 | | } |
| 0 | 624 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 625 | | } |
| 0 | 626 | | if (_shouldTrace) |
| | 627 | | { |
| 0 | 628 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 629 | | } |
| 0 | 630 | | return _result; |
| 0 | 631 | | } |
| | 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 | | { |
| 1 | 665 | | if (Client.BatchUrl == null) |
| | 666 | | { |
| 0 | 667 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 668 | | } |
| 1 | 669 | | if (jobScheduleId == null) |
| | 670 | | { |
| 1 | 671 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 672 | | } |
| 0 | 673 | | if (Client.ApiVersion == null) |
| | 674 | | { |
| 0 | 675 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 676 | | } |
| 0 | 677 | | string select = default(string); |
| 0 | 678 | | if (jobScheduleGetOptions != null) |
| | 679 | | { |
| 0 | 680 | | select = jobScheduleGetOptions.Select; |
| | 681 | | } |
| 0 | 682 | | string expand = default(string); |
| 0 | 683 | | if (jobScheduleGetOptions != null) |
| | 684 | | { |
| 0 | 685 | | expand = jobScheduleGetOptions.Expand; |
| | 686 | | } |
| 0 | 687 | | int? timeout = default(int?); |
| 0 | 688 | | if (jobScheduleGetOptions != null) |
| | 689 | | { |
| 0 | 690 | | timeout = jobScheduleGetOptions.Timeout; |
| | 691 | | } |
| 0 | 692 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 693 | | if (jobScheduleGetOptions != null) |
| | 694 | | { |
| 0 | 695 | | clientRequestId = jobScheduleGetOptions.ClientRequestId; |
| | 696 | | } |
| 0 | 697 | | bool? returnClientRequestId = default(bool?); |
| 0 | 698 | | if (jobScheduleGetOptions != null) |
| | 699 | | { |
| 0 | 700 | | returnClientRequestId = jobScheduleGetOptions.ReturnClientRequestId; |
| | 701 | | } |
| 0 | 702 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 703 | | if (jobScheduleGetOptions != null) |
| | 704 | | { |
| 0 | 705 | | ocpDate = jobScheduleGetOptions.OcpDate; |
| | 706 | | } |
| 0 | 707 | | string ifMatch = default(string); |
| 0 | 708 | | if (jobScheduleGetOptions != null) |
| | 709 | | { |
| 0 | 710 | | ifMatch = jobScheduleGetOptions.IfMatch; |
| | 711 | | } |
| 0 | 712 | | string ifNoneMatch = default(string); |
| 0 | 713 | | if (jobScheduleGetOptions != null) |
| | 714 | | { |
| 0 | 715 | | ifNoneMatch = jobScheduleGetOptions.IfNoneMatch; |
| | 716 | | } |
| 0 | 717 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 718 | | if (jobScheduleGetOptions != null) |
| | 719 | | { |
| 0 | 720 | | ifModifiedSince = jobScheduleGetOptions.IfModifiedSince; |
| | 721 | | } |
| 0 | 722 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 723 | | if (jobScheduleGetOptions != null) |
| | 724 | | { |
| 0 | 725 | | ifUnmodifiedSince = jobScheduleGetOptions.IfUnmodifiedSince; |
| | 726 | | } |
| | 727 | | // Tracing |
| 0 | 728 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 729 | | string _invocationId = null; |
| 0 | 730 | | if (_shouldTrace) |
| | 731 | | { |
| 0 | 732 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 733 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 734 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 735 | | tracingParameters.Add("select", select); |
| 0 | 736 | | tracingParameters.Add("expand", expand); |
| 0 | 737 | | tracingParameters.Add("timeout", timeout); |
| 0 | 738 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 739 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 740 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 741 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 742 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 743 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 744 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 745 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 746 | | ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); |
| | 747 | | } |
| | 748 | | // Construct URL |
| 0 | 749 | | var _baseUrl = Client.BaseUri; |
| 0 | 750 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}"; |
| 0 | 751 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 752 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 753 | | List<string> _queryParameters = new List<string>(); |
| 0 | 754 | | if (Client.ApiVersion != null) |
| | 755 | | { |
| 0 | 756 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 757 | | } |
| 0 | 758 | | if (select != null) |
| | 759 | | { |
| 0 | 760 | | _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); |
| | 761 | | } |
| 0 | 762 | | if (expand != null) |
| | 763 | | { |
| 0 | 764 | | _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); |
| | 765 | | } |
| 0 | 766 | | if (timeout != null) |
| | 767 | | { |
| 0 | 768 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 769 | | } |
| 0 | 770 | | if (_queryParameters.Count > 0) |
| | 771 | | { |
| 0 | 772 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 773 | | } |
| | 774 | | // Create HTTP transport objects |
| 0 | 775 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 776 | | HttpResponseMessage _httpResponse = null; |
| 0 | 777 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 778 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 779 | | // Set Headers |
| 0 | 780 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 781 | | { |
| 0 | 782 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 783 | | } |
| 0 | 784 | | if (Client.AcceptLanguage != null) |
| | 785 | | { |
| 0 | 786 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 787 | | { |
| 0 | 788 | | _httpRequest.Headers.Remove("accept-language"); |
| | 789 | | } |
| 0 | 790 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 791 | | } |
| 0 | 792 | | if (clientRequestId != null) |
| | 793 | | { |
| 0 | 794 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 795 | | { |
| 0 | 796 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 797 | | } |
| 0 | 798 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 799 | | } |
| 0 | 800 | | if (returnClientRequestId != null) |
| | 801 | | { |
| 0 | 802 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 803 | | { |
| 0 | 804 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 805 | | } |
| 0 | 806 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 807 | | } |
| 0 | 808 | | if (ocpDate != null) |
| | 809 | | { |
| 0 | 810 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 811 | | { |
| 0 | 812 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 813 | | } |
| 0 | 814 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 815 | | } |
| 0 | 816 | | if (ifMatch != null) |
| | 817 | | { |
| 0 | 818 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 819 | | { |
| 0 | 820 | | _httpRequest.Headers.Remove("If-Match"); |
| | 821 | | } |
| 0 | 822 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 823 | | } |
| 0 | 824 | | if (ifNoneMatch != null) |
| | 825 | | { |
| 0 | 826 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 827 | | { |
| 0 | 828 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 829 | | } |
| 0 | 830 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 831 | | } |
| 0 | 832 | | if (ifModifiedSince != null) |
| | 833 | | { |
| 0 | 834 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 835 | | { |
| 0 | 836 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 837 | | } |
| 0 | 838 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 839 | | } |
| 0 | 840 | | if (ifUnmodifiedSince != null) |
| | 841 | | { |
| 0 | 842 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 843 | | { |
| 0 | 844 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 845 | | } |
| 0 | 846 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 847 | | } |
| | 848 | |
|
| | 849 | |
|
| 0 | 850 | | if (customHeaders != null) |
| | 851 | | { |
| 0 | 852 | | foreach(var _header in customHeaders) |
| | 853 | | { |
| 0 | 854 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 855 | | { |
| 0 | 856 | | _httpRequest.Headers.Remove(_header.Key); |
| | 857 | | } |
| 0 | 858 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 859 | | } |
| | 860 | | } |
| | 861 | |
|
| | 862 | | // Serialize Request |
| 0 | 863 | | string _requestContent = null; |
| | 864 | | // Set Credentials |
| 0 | 865 | | if (Client.Credentials != null) |
| | 866 | | { |
| 0 | 867 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 868 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 869 | | } |
| | 870 | | // Send Request |
| 0 | 871 | | if (_shouldTrace) |
| | 872 | | { |
| 0 | 873 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 874 | | } |
| 0 | 875 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 876 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 877 | | if (_shouldTrace) |
| | 878 | | { |
| 0 | 879 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 880 | | } |
| 0 | 881 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 882 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 883 | | string _responseContent = null; |
| 0 | 884 | | if ((int)_statusCode != 200) |
| | 885 | | { |
| 0 | 886 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 887 | | try |
| | 888 | | { |
| 0 | 889 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 890 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 891 | | if (_errorBody != null) |
| | 892 | | { |
| 0 | 893 | | ex.Body = _errorBody; |
| | 894 | | } |
| 0 | 895 | | } |
| 0 | 896 | | catch (JsonException) |
| | 897 | | { |
| | 898 | | // Ignore the exception |
| 0 | 899 | | } |
| 0 | 900 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 901 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 902 | | if (_shouldTrace) |
| | 903 | | { |
| 0 | 904 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 905 | | } |
| 0 | 906 | | _httpRequest.Dispose(); |
| 0 | 907 | | if (_httpResponse != null) |
| | 908 | | { |
| 0 | 909 | | _httpResponse.Dispose(); |
| | 910 | | } |
| 0 | 911 | | throw ex; |
| | 912 | | } |
| | 913 | | // Create Result |
| 0 | 914 | | var _result = new AzureOperationResponse<CloudJobSchedule,JobScheduleGetHeaders>(); |
| 0 | 915 | | _result.Request = _httpRequest; |
| 0 | 916 | | _result.Response = _httpResponse; |
| 0 | 917 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 918 | | { |
| 0 | 919 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 920 | | } |
| | 921 | | // Deserialize Response |
| 0 | 922 | | if ((int)_statusCode == 200) |
| | 923 | | { |
| 0 | 924 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 925 | | try |
| | 926 | | { |
| 0 | 927 | | _result.Body = SafeJsonConvert.DeserializeObject<CloudJobSchedule>(_responseContent, Client.Deserial |
| 0 | 928 | | } |
| 0 | 929 | | catch (JsonException ex) |
| | 930 | | { |
| 0 | 931 | | _httpRequest.Dispose(); |
| 0 | 932 | | if (_httpResponse != null) |
| | 933 | | { |
| 0 | 934 | | _httpResponse.Dispose(); |
| | 935 | | } |
| 0 | 936 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 937 | | } |
| | 938 | | } |
| | 939 | | try |
| | 940 | | { |
| 0 | 941 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleGetHeaders>(JsonSerializer.Create |
| 0 | 942 | | } |
| 0 | 943 | | catch (JsonException ex) |
| | 944 | | { |
| 0 | 945 | | _httpRequest.Dispose(); |
| 0 | 946 | | if (_httpResponse != null) |
| | 947 | | { |
| 0 | 948 | | _httpResponse.Dispose(); |
| | 949 | | } |
| 0 | 950 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 951 | | } |
| 0 | 952 | | if (_shouldTrace) |
| | 953 | | { |
| 0 | 954 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 955 | | } |
| 0 | 956 | | return _result; |
| 0 | 957 | | } |
| | 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 | | { |
| 0 | 998 | | if (Client.BatchUrl == null) |
| | 999 | | { |
| 0 | 1000 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1001 | | } |
| 0 | 1002 | | if (jobScheduleId == null) |
| | 1003 | | { |
| 0 | 1004 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 1005 | | } |
| 0 | 1006 | | if (jobSchedulePatchParameter == null) |
| | 1007 | | { |
| 0 | 1008 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobSchedulePatchParameter"); |
| | 1009 | | } |
| 0 | 1010 | | if (Client.ApiVersion == null) |
| | 1011 | | { |
| 0 | 1012 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1013 | | } |
| 0 | 1014 | | int? timeout = default(int?); |
| 0 | 1015 | | if (jobSchedulePatchOptions != null) |
| | 1016 | | { |
| 0 | 1017 | | timeout = jobSchedulePatchOptions.Timeout; |
| | 1018 | | } |
| 0 | 1019 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1020 | | if (jobSchedulePatchOptions != null) |
| | 1021 | | { |
| 0 | 1022 | | clientRequestId = jobSchedulePatchOptions.ClientRequestId; |
| | 1023 | | } |
| 0 | 1024 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1025 | | if (jobSchedulePatchOptions != null) |
| | 1026 | | { |
| 0 | 1027 | | returnClientRequestId = jobSchedulePatchOptions.ReturnClientRequestId; |
| | 1028 | | } |
| 0 | 1029 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1030 | | if (jobSchedulePatchOptions != null) |
| | 1031 | | { |
| 0 | 1032 | | ocpDate = jobSchedulePatchOptions.OcpDate; |
| | 1033 | | } |
| 0 | 1034 | | string ifMatch = default(string); |
| 0 | 1035 | | if (jobSchedulePatchOptions != null) |
| | 1036 | | { |
| 0 | 1037 | | ifMatch = jobSchedulePatchOptions.IfMatch; |
| | 1038 | | } |
| 0 | 1039 | | string ifNoneMatch = default(string); |
| 0 | 1040 | | if (jobSchedulePatchOptions != null) |
| | 1041 | | { |
| 0 | 1042 | | ifNoneMatch = jobSchedulePatchOptions.IfNoneMatch; |
| | 1043 | | } |
| 0 | 1044 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1045 | | if (jobSchedulePatchOptions != null) |
| | 1046 | | { |
| 0 | 1047 | | ifModifiedSince = jobSchedulePatchOptions.IfModifiedSince; |
| | 1048 | | } |
| 0 | 1049 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1050 | | if (jobSchedulePatchOptions != null) |
| | 1051 | | { |
| 0 | 1052 | | ifUnmodifiedSince = jobSchedulePatchOptions.IfUnmodifiedSince; |
| | 1053 | | } |
| | 1054 | | // Tracing |
| 0 | 1055 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1056 | | string _invocationId = null; |
| 0 | 1057 | | if (_shouldTrace) |
| | 1058 | | { |
| 0 | 1059 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1060 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1061 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 1062 | | tracingParameters.Add("jobSchedulePatchParameter", jobSchedulePatchParameter); |
| 0 | 1063 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1064 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1065 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1066 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1067 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1068 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1069 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1070 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1071 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1072 | | ServiceClientTracing.Enter(_invocationId, this, "Patch", tracingParameters); |
| | 1073 | | } |
| | 1074 | | // Construct URL |
| 0 | 1075 | | var _baseUrl = Client.BaseUri; |
| 0 | 1076 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}"; |
| 0 | 1077 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1078 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 1079 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1080 | | if (Client.ApiVersion != null) |
| | 1081 | | { |
| 0 | 1082 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1083 | | } |
| 0 | 1084 | | if (timeout != null) |
| | 1085 | | { |
| 0 | 1086 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1087 | | } |
| 0 | 1088 | | if (_queryParameters.Count > 0) |
| | 1089 | | { |
| 0 | 1090 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1091 | | } |
| | 1092 | | // Create HTTP transport objects |
| 0 | 1093 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1094 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1095 | | _httpRequest.Method = new HttpMethod("PATCH"); |
| 0 | 1096 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1097 | | // Set Headers |
| 0 | 1098 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1099 | | { |
| 0 | 1100 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1101 | | } |
| 0 | 1102 | | if (Client.AcceptLanguage != null) |
| | 1103 | | { |
| 0 | 1104 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1105 | | { |
| 0 | 1106 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1107 | | } |
| 0 | 1108 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1109 | | } |
| 0 | 1110 | | if (clientRequestId != null) |
| | 1111 | | { |
| 0 | 1112 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1113 | | { |
| 0 | 1114 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1115 | | } |
| 0 | 1116 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1117 | | } |
| 0 | 1118 | | if (returnClientRequestId != null) |
| | 1119 | | { |
| 0 | 1120 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1121 | | { |
| 0 | 1122 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1123 | | } |
| 0 | 1124 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1125 | | } |
| 0 | 1126 | | if (ocpDate != null) |
| | 1127 | | { |
| 0 | 1128 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1129 | | { |
| 0 | 1130 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1131 | | } |
| 0 | 1132 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1133 | | } |
| 0 | 1134 | | if (ifMatch != null) |
| | 1135 | | { |
| 0 | 1136 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1137 | | { |
| 0 | 1138 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1139 | | } |
| 0 | 1140 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1141 | | } |
| 0 | 1142 | | if (ifNoneMatch != null) |
| | 1143 | | { |
| 0 | 1144 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1145 | | { |
| 0 | 1146 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1147 | | } |
| 0 | 1148 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1149 | | } |
| 0 | 1150 | | if (ifModifiedSince != null) |
| | 1151 | | { |
| 0 | 1152 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1153 | | { |
| 0 | 1154 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1155 | | } |
| 0 | 1156 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1157 | | } |
| 0 | 1158 | | if (ifUnmodifiedSince != null) |
| | 1159 | | { |
| 0 | 1160 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1161 | | { |
| 0 | 1162 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1163 | | } |
| 0 | 1164 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1165 | | } |
| | 1166 | |
|
| | 1167 | |
|
| 0 | 1168 | | if (customHeaders != null) |
| | 1169 | | { |
| 0 | 1170 | | foreach(var _header in customHeaders) |
| | 1171 | | { |
| 0 | 1172 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1173 | | { |
| 0 | 1174 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1175 | | } |
| 0 | 1176 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1177 | | } |
| | 1178 | | } |
| | 1179 | |
|
| | 1180 | | // Serialize Request |
| 0 | 1181 | | string _requestContent = null; |
| 0 | 1182 | | if(jobSchedulePatchParameter != null) |
| | 1183 | | { |
| 0 | 1184 | | _requestContent = SafeJsonConvert.SerializeObject(jobSchedulePatchParameter, Client.SerializationSetting |
| 0 | 1185 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 1186 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 1187 | | } |
| | 1188 | | // Set Credentials |
| 0 | 1189 | | if (Client.Credentials != null) |
| | 1190 | | { |
| 0 | 1191 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1192 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1193 | | } |
| | 1194 | | // Send Request |
| 0 | 1195 | | if (_shouldTrace) |
| | 1196 | | { |
| 0 | 1197 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1198 | | } |
| 0 | 1199 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1200 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1201 | | if (_shouldTrace) |
| | 1202 | | { |
| 0 | 1203 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1204 | | } |
| 0 | 1205 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1206 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1207 | | string _responseContent = null; |
| 0 | 1208 | | if ((int)_statusCode != 200) |
| | 1209 | | { |
| 0 | 1210 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1211 | | try |
| | 1212 | | { |
| 0 | 1213 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1214 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1215 | | if (_errorBody != null) |
| | 1216 | | { |
| 0 | 1217 | | ex.Body = _errorBody; |
| | 1218 | | } |
| 0 | 1219 | | } |
| 0 | 1220 | | catch (JsonException) |
| | 1221 | | { |
| | 1222 | | // Ignore the exception |
| 0 | 1223 | | } |
| 0 | 1224 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1225 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1226 | | if (_shouldTrace) |
| | 1227 | | { |
| 0 | 1228 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1229 | | } |
| 0 | 1230 | | _httpRequest.Dispose(); |
| 0 | 1231 | | if (_httpResponse != null) |
| | 1232 | | { |
| 0 | 1233 | | _httpResponse.Dispose(); |
| | 1234 | | } |
| 0 | 1235 | | throw ex; |
| | 1236 | | } |
| | 1237 | | // Create Result |
| 0 | 1238 | | var _result = new AzureOperationHeaderResponse<JobSchedulePatchHeaders>(); |
| 0 | 1239 | | _result.Request = _httpRequest; |
| 0 | 1240 | | _result.Response = _httpResponse; |
| 0 | 1241 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1242 | | { |
| 0 | 1243 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1244 | | } |
| | 1245 | | try |
| | 1246 | | { |
| 0 | 1247 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobSchedulePatchHeaders>(JsonSerializer.Crea |
| 0 | 1248 | | } |
| 0 | 1249 | | catch (JsonException ex) |
| | 1250 | | { |
| 0 | 1251 | | _httpRequest.Dispose(); |
| 0 | 1252 | | if (_httpResponse != null) |
| | 1253 | | { |
| 0 | 1254 | | _httpResponse.Dispose(); |
| | 1255 | | } |
| 0 | 1256 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1257 | | } |
| 0 | 1258 | | if (_shouldTrace) |
| | 1259 | | { |
| 0 | 1260 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1261 | | } |
| 0 | 1262 | | return _result; |
| 0 | 1263 | | } |
| | 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 | | { |
| 0 | 1304 | | if (Client.BatchUrl == null) |
| | 1305 | | { |
| 0 | 1306 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1307 | | } |
| 0 | 1308 | | if (jobScheduleId == null) |
| | 1309 | | { |
| 0 | 1310 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 1311 | | } |
| 0 | 1312 | | if (jobScheduleUpdateParameter == null) |
| | 1313 | | { |
| 0 | 1314 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleUpdateParameter"); |
| | 1315 | | } |
| 0 | 1316 | | if (Client.ApiVersion == null) |
| | 1317 | | { |
| 0 | 1318 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1319 | | } |
| 0 | 1320 | | int? timeout = default(int?); |
| 0 | 1321 | | if (jobScheduleUpdateOptions != null) |
| | 1322 | | { |
| 0 | 1323 | | timeout = jobScheduleUpdateOptions.Timeout; |
| | 1324 | | } |
| 0 | 1325 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1326 | | if (jobScheduleUpdateOptions != null) |
| | 1327 | | { |
| 0 | 1328 | | clientRequestId = jobScheduleUpdateOptions.ClientRequestId; |
| | 1329 | | } |
| 0 | 1330 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1331 | | if (jobScheduleUpdateOptions != null) |
| | 1332 | | { |
| 0 | 1333 | | returnClientRequestId = jobScheduleUpdateOptions.ReturnClientRequestId; |
| | 1334 | | } |
| 0 | 1335 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1336 | | if (jobScheduleUpdateOptions != null) |
| | 1337 | | { |
| 0 | 1338 | | ocpDate = jobScheduleUpdateOptions.OcpDate; |
| | 1339 | | } |
| 0 | 1340 | | string ifMatch = default(string); |
| 0 | 1341 | | if (jobScheduleUpdateOptions != null) |
| | 1342 | | { |
| 0 | 1343 | | ifMatch = jobScheduleUpdateOptions.IfMatch; |
| | 1344 | | } |
| 0 | 1345 | | string ifNoneMatch = default(string); |
| 0 | 1346 | | if (jobScheduleUpdateOptions != null) |
| | 1347 | | { |
| 0 | 1348 | | ifNoneMatch = jobScheduleUpdateOptions.IfNoneMatch; |
| | 1349 | | } |
| 0 | 1350 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1351 | | if (jobScheduleUpdateOptions != null) |
| | 1352 | | { |
| 0 | 1353 | | ifModifiedSince = jobScheduleUpdateOptions.IfModifiedSince; |
| | 1354 | | } |
| 0 | 1355 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1356 | | if (jobScheduleUpdateOptions != null) |
| | 1357 | | { |
| 0 | 1358 | | ifUnmodifiedSince = jobScheduleUpdateOptions.IfUnmodifiedSince; |
| | 1359 | | } |
| | 1360 | | // Tracing |
| 0 | 1361 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1362 | | string _invocationId = null; |
| 0 | 1363 | | if (_shouldTrace) |
| | 1364 | | { |
| 0 | 1365 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1366 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1367 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 1368 | | tracingParameters.Add("jobScheduleUpdateParameter", jobScheduleUpdateParameter); |
| 0 | 1369 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1370 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1371 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1372 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1373 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1374 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1375 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1376 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1377 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1378 | | ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); |
| | 1379 | | } |
| | 1380 | | // Construct URL |
| 0 | 1381 | | var _baseUrl = Client.BaseUri; |
| 0 | 1382 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}"; |
| 0 | 1383 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1384 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 1385 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1386 | | if (Client.ApiVersion != null) |
| | 1387 | | { |
| 0 | 1388 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1389 | | } |
| 0 | 1390 | | if (timeout != null) |
| | 1391 | | { |
| 0 | 1392 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1393 | | } |
| 0 | 1394 | | if (_queryParameters.Count > 0) |
| | 1395 | | { |
| 0 | 1396 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1397 | | } |
| | 1398 | | // Create HTTP transport objects |
| 0 | 1399 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1400 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1401 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 1402 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1403 | | // Set Headers |
| 0 | 1404 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1405 | | { |
| 0 | 1406 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1407 | | } |
| 0 | 1408 | | if (Client.AcceptLanguage != null) |
| | 1409 | | { |
| 0 | 1410 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1411 | | { |
| 0 | 1412 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1413 | | } |
| 0 | 1414 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1415 | | } |
| 0 | 1416 | | if (clientRequestId != null) |
| | 1417 | | { |
| 0 | 1418 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1419 | | { |
| 0 | 1420 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1421 | | } |
| 0 | 1422 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1423 | | } |
| 0 | 1424 | | if (returnClientRequestId != null) |
| | 1425 | | { |
| 0 | 1426 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1427 | | { |
| 0 | 1428 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1429 | | } |
| 0 | 1430 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1431 | | } |
| 0 | 1432 | | if (ocpDate != null) |
| | 1433 | | { |
| 0 | 1434 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1435 | | { |
| 0 | 1436 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1437 | | } |
| 0 | 1438 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1439 | | } |
| 0 | 1440 | | if (ifMatch != null) |
| | 1441 | | { |
| 0 | 1442 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1443 | | { |
| 0 | 1444 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1445 | | } |
| 0 | 1446 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1447 | | } |
| 0 | 1448 | | if (ifNoneMatch != null) |
| | 1449 | | { |
| 0 | 1450 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1451 | | { |
| 0 | 1452 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1453 | | } |
| 0 | 1454 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1455 | | } |
| 0 | 1456 | | if (ifModifiedSince != null) |
| | 1457 | | { |
| 0 | 1458 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1459 | | { |
| 0 | 1460 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1461 | | } |
| 0 | 1462 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1463 | | } |
| 0 | 1464 | | if (ifUnmodifiedSince != null) |
| | 1465 | | { |
| 0 | 1466 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1467 | | { |
| 0 | 1468 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1469 | | } |
| 0 | 1470 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1471 | | } |
| | 1472 | |
|
| | 1473 | |
|
| 0 | 1474 | | if (customHeaders != null) |
| | 1475 | | { |
| 0 | 1476 | | foreach(var _header in customHeaders) |
| | 1477 | | { |
| 0 | 1478 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1479 | | { |
| 0 | 1480 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1481 | | } |
| 0 | 1482 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1483 | | } |
| | 1484 | | } |
| | 1485 | |
|
| | 1486 | | // Serialize Request |
| 0 | 1487 | | string _requestContent = null; |
| 0 | 1488 | | if(jobScheduleUpdateParameter != null) |
| | 1489 | | { |
| 0 | 1490 | | _requestContent = SafeJsonConvert.SerializeObject(jobScheduleUpdateParameter, Client.SerializationSettin |
| 0 | 1491 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 1492 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 1493 | | } |
| | 1494 | | // Set Credentials |
| 0 | 1495 | | if (Client.Credentials != null) |
| | 1496 | | { |
| 0 | 1497 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1498 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1499 | | } |
| | 1500 | | // Send Request |
| 0 | 1501 | | if (_shouldTrace) |
| | 1502 | | { |
| 0 | 1503 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1504 | | } |
| 0 | 1505 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1506 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1507 | | if (_shouldTrace) |
| | 1508 | | { |
| 0 | 1509 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1510 | | } |
| 0 | 1511 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1512 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1513 | | string _responseContent = null; |
| 0 | 1514 | | if ((int)_statusCode != 200) |
| | 1515 | | { |
| 0 | 1516 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1517 | | try |
| | 1518 | | { |
| 0 | 1519 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1520 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1521 | | if (_errorBody != null) |
| | 1522 | | { |
| 0 | 1523 | | ex.Body = _errorBody; |
| | 1524 | | } |
| 0 | 1525 | | } |
| 0 | 1526 | | catch (JsonException) |
| | 1527 | | { |
| | 1528 | | // Ignore the exception |
| 0 | 1529 | | } |
| 0 | 1530 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1531 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1532 | | if (_shouldTrace) |
| | 1533 | | { |
| 0 | 1534 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1535 | | } |
| 0 | 1536 | | _httpRequest.Dispose(); |
| 0 | 1537 | | if (_httpResponse != null) |
| | 1538 | | { |
| 0 | 1539 | | _httpResponse.Dispose(); |
| | 1540 | | } |
| 0 | 1541 | | throw ex; |
| | 1542 | | } |
| | 1543 | | // Create Result |
| 0 | 1544 | | var _result = new AzureOperationHeaderResponse<JobScheduleUpdateHeaders>(); |
| 0 | 1545 | | _result.Request = _httpRequest; |
| 0 | 1546 | | _result.Response = _httpResponse; |
| 0 | 1547 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1548 | | { |
| 0 | 1549 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1550 | | } |
| | 1551 | | try |
| | 1552 | | { |
| 0 | 1553 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleUpdateHeaders>(JsonSerializer.Cre |
| 0 | 1554 | | } |
| 0 | 1555 | | catch (JsonException ex) |
| | 1556 | | { |
| 0 | 1557 | | _httpRequest.Dispose(); |
| 0 | 1558 | | if (_httpResponse != null) |
| | 1559 | | { |
| 0 | 1560 | | _httpResponse.Dispose(); |
| | 1561 | | } |
| 0 | 1562 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1563 | | } |
| 0 | 1564 | | if (_shouldTrace) |
| | 1565 | | { |
| 0 | 1566 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1567 | | } |
| 0 | 1568 | | return _result; |
| 0 | 1569 | | } |
| | 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 | | { |
| 0 | 1603 | | if (Client.BatchUrl == null) |
| | 1604 | | { |
| 0 | 1605 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1606 | | } |
| 0 | 1607 | | if (jobScheduleId == null) |
| | 1608 | | { |
| 0 | 1609 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 1610 | | } |
| 0 | 1611 | | if (Client.ApiVersion == null) |
| | 1612 | | { |
| 0 | 1613 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1614 | | } |
| 0 | 1615 | | int? timeout = default(int?); |
| 0 | 1616 | | if (jobScheduleDisableOptions != null) |
| | 1617 | | { |
| 0 | 1618 | | timeout = jobScheduleDisableOptions.Timeout; |
| | 1619 | | } |
| 0 | 1620 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1621 | | if (jobScheduleDisableOptions != null) |
| | 1622 | | { |
| 0 | 1623 | | clientRequestId = jobScheduleDisableOptions.ClientRequestId; |
| | 1624 | | } |
| 0 | 1625 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1626 | | if (jobScheduleDisableOptions != null) |
| | 1627 | | { |
| 0 | 1628 | | returnClientRequestId = jobScheduleDisableOptions.ReturnClientRequestId; |
| | 1629 | | } |
| 0 | 1630 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1631 | | if (jobScheduleDisableOptions != null) |
| | 1632 | | { |
| 0 | 1633 | | ocpDate = jobScheduleDisableOptions.OcpDate; |
| | 1634 | | } |
| 0 | 1635 | | string ifMatch = default(string); |
| 0 | 1636 | | if (jobScheduleDisableOptions != null) |
| | 1637 | | { |
| 0 | 1638 | | ifMatch = jobScheduleDisableOptions.IfMatch; |
| | 1639 | | } |
| 0 | 1640 | | string ifNoneMatch = default(string); |
| 0 | 1641 | | if (jobScheduleDisableOptions != null) |
| | 1642 | | { |
| 0 | 1643 | | ifNoneMatch = jobScheduleDisableOptions.IfNoneMatch; |
| | 1644 | | } |
| 0 | 1645 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1646 | | if (jobScheduleDisableOptions != null) |
| | 1647 | | { |
| 0 | 1648 | | ifModifiedSince = jobScheduleDisableOptions.IfModifiedSince; |
| | 1649 | | } |
| 0 | 1650 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1651 | | if (jobScheduleDisableOptions != null) |
| | 1652 | | { |
| 0 | 1653 | | ifUnmodifiedSince = jobScheduleDisableOptions.IfUnmodifiedSince; |
| | 1654 | | } |
| | 1655 | | // Tracing |
| 0 | 1656 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1657 | | string _invocationId = null; |
| 0 | 1658 | | if (_shouldTrace) |
| | 1659 | | { |
| 0 | 1660 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1661 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1662 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 1663 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1664 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1665 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1666 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1667 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1668 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1669 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1670 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1671 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1672 | | ServiceClientTracing.Enter(_invocationId, this, "Disable", tracingParameters); |
| | 1673 | | } |
| | 1674 | | // Construct URL |
| 0 | 1675 | | var _baseUrl = Client.BaseUri; |
| 0 | 1676 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/disable"; |
| 0 | 1677 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1678 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 1679 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1680 | | if (Client.ApiVersion != null) |
| | 1681 | | { |
| 0 | 1682 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1683 | | } |
| 0 | 1684 | | if (timeout != null) |
| | 1685 | | { |
| 0 | 1686 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1687 | | } |
| 0 | 1688 | | if (_queryParameters.Count > 0) |
| | 1689 | | { |
| 0 | 1690 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1691 | | } |
| | 1692 | | // Create HTTP transport objects |
| 0 | 1693 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1694 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1695 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 1696 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1697 | | // Set Headers |
| 0 | 1698 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1699 | | { |
| 0 | 1700 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1701 | | } |
| 0 | 1702 | | if (Client.AcceptLanguage != null) |
| | 1703 | | { |
| 0 | 1704 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1705 | | { |
| 0 | 1706 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1707 | | } |
| 0 | 1708 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1709 | | } |
| 0 | 1710 | | if (clientRequestId != null) |
| | 1711 | | { |
| 0 | 1712 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1713 | | { |
| 0 | 1714 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1715 | | } |
| 0 | 1716 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1717 | | } |
| 0 | 1718 | | if (returnClientRequestId != null) |
| | 1719 | | { |
| 0 | 1720 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1721 | | { |
| 0 | 1722 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1723 | | } |
| 0 | 1724 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1725 | | } |
| 0 | 1726 | | if (ocpDate != null) |
| | 1727 | | { |
| 0 | 1728 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1729 | | { |
| 0 | 1730 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1731 | | } |
| 0 | 1732 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1733 | | } |
| 0 | 1734 | | if (ifMatch != null) |
| | 1735 | | { |
| 0 | 1736 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1737 | | { |
| 0 | 1738 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1739 | | } |
| 0 | 1740 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1741 | | } |
| 0 | 1742 | | if (ifNoneMatch != null) |
| | 1743 | | { |
| 0 | 1744 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1745 | | { |
| 0 | 1746 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1747 | | } |
| 0 | 1748 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1749 | | } |
| 0 | 1750 | | if (ifModifiedSince != null) |
| | 1751 | | { |
| 0 | 1752 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1753 | | { |
| 0 | 1754 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1755 | | } |
| 0 | 1756 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1757 | | } |
| 0 | 1758 | | if (ifUnmodifiedSince != null) |
| | 1759 | | { |
| 0 | 1760 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1761 | | { |
| 0 | 1762 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1763 | | } |
| 0 | 1764 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1765 | | } |
| | 1766 | |
|
| | 1767 | |
|
| 0 | 1768 | | if (customHeaders != null) |
| | 1769 | | { |
| 0 | 1770 | | foreach(var _header in customHeaders) |
| | 1771 | | { |
| 0 | 1772 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1773 | | { |
| 0 | 1774 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1775 | | } |
| 0 | 1776 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1777 | | } |
| | 1778 | | } |
| | 1779 | |
|
| | 1780 | | // Serialize Request |
| 0 | 1781 | | string _requestContent = null; |
| | 1782 | | // Set Credentials |
| 0 | 1783 | | if (Client.Credentials != null) |
| | 1784 | | { |
| 0 | 1785 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1786 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1787 | | } |
| | 1788 | | // Send Request |
| 0 | 1789 | | if (_shouldTrace) |
| | 1790 | | { |
| 0 | 1791 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1792 | | } |
| 0 | 1793 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1794 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1795 | | if (_shouldTrace) |
| | 1796 | | { |
| 0 | 1797 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1798 | | } |
| 0 | 1799 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1800 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1801 | | string _responseContent = null; |
| 0 | 1802 | | if ((int)_statusCode != 204) |
| | 1803 | | { |
| 0 | 1804 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1805 | | try |
| | 1806 | | { |
| 0 | 1807 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1808 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1809 | | if (_errorBody != null) |
| | 1810 | | { |
| 0 | 1811 | | ex.Body = _errorBody; |
| | 1812 | | } |
| 0 | 1813 | | } |
| 0 | 1814 | | catch (JsonException) |
| | 1815 | | { |
| | 1816 | | // Ignore the exception |
| 0 | 1817 | | } |
| 0 | 1818 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1819 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1820 | | if (_shouldTrace) |
| | 1821 | | { |
| 0 | 1822 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1823 | | } |
| 0 | 1824 | | _httpRequest.Dispose(); |
| 0 | 1825 | | if (_httpResponse != null) |
| | 1826 | | { |
| 0 | 1827 | | _httpResponse.Dispose(); |
| | 1828 | | } |
| 0 | 1829 | | throw ex; |
| | 1830 | | } |
| | 1831 | | // Create Result |
| 0 | 1832 | | var _result = new AzureOperationHeaderResponse<JobScheduleDisableHeaders>(); |
| 0 | 1833 | | _result.Request = _httpRequest; |
| 0 | 1834 | | _result.Response = _httpResponse; |
| 0 | 1835 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1836 | | { |
| 0 | 1837 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1838 | | } |
| | 1839 | | try |
| | 1840 | | { |
| 0 | 1841 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleDisableHeaders>(JsonSerializer.Cr |
| 0 | 1842 | | } |
| 0 | 1843 | | catch (JsonException ex) |
| | 1844 | | { |
| 0 | 1845 | | _httpRequest.Dispose(); |
| 0 | 1846 | | if (_httpResponse != null) |
| | 1847 | | { |
| 0 | 1848 | | _httpResponse.Dispose(); |
| | 1849 | | } |
| 0 | 1850 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1851 | | } |
| 0 | 1852 | | if (_shouldTrace) |
| | 1853 | | { |
| 0 | 1854 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1855 | | } |
| 0 | 1856 | | return _result; |
| 0 | 1857 | | } |
| | 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 | | { |
| 0 | 1888 | | if (Client.BatchUrl == null) |
| | 1889 | | { |
| 0 | 1890 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1891 | | } |
| 0 | 1892 | | if (jobScheduleId == null) |
| | 1893 | | { |
| 0 | 1894 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 1895 | | } |
| 0 | 1896 | | if (Client.ApiVersion == null) |
| | 1897 | | { |
| 0 | 1898 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1899 | | } |
| 0 | 1900 | | int? timeout = default(int?); |
| 0 | 1901 | | if (jobScheduleEnableOptions != null) |
| | 1902 | | { |
| 0 | 1903 | | timeout = jobScheduleEnableOptions.Timeout; |
| | 1904 | | } |
| 0 | 1905 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1906 | | if (jobScheduleEnableOptions != null) |
| | 1907 | | { |
| 0 | 1908 | | clientRequestId = jobScheduleEnableOptions.ClientRequestId; |
| | 1909 | | } |
| 0 | 1910 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1911 | | if (jobScheduleEnableOptions != null) |
| | 1912 | | { |
| 0 | 1913 | | returnClientRequestId = jobScheduleEnableOptions.ReturnClientRequestId; |
| | 1914 | | } |
| 0 | 1915 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1916 | | if (jobScheduleEnableOptions != null) |
| | 1917 | | { |
| 0 | 1918 | | ocpDate = jobScheduleEnableOptions.OcpDate; |
| | 1919 | | } |
| 0 | 1920 | | string ifMatch = default(string); |
| 0 | 1921 | | if (jobScheduleEnableOptions != null) |
| | 1922 | | { |
| 0 | 1923 | | ifMatch = jobScheduleEnableOptions.IfMatch; |
| | 1924 | | } |
| 0 | 1925 | | string ifNoneMatch = default(string); |
| 0 | 1926 | | if (jobScheduleEnableOptions != null) |
| | 1927 | | { |
| 0 | 1928 | | ifNoneMatch = jobScheduleEnableOptions.IfNoneMatch; |
| | 1929 | | } |
| 0 | 1930 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1931 | | if (jobScheduleEnableOptions != null) |
| | 1932 | | { |
| 0 | 1933 | | ifModifiedSince = jobScheduleEnableOptions.IfModifiedSince; |
| | 1934 | | } |
| 0 | 1935 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1936 | | if (jobScheduleEnableOptions != null) |
| | 1937 | | { |
| 0 | 1938 | | ifUnmodifiedSince = jobScheduleEnableOptions.IfUnmodifiedSince; |
| | 1939 | | } |
| | 1940 | | // Tracing |
| 0 | 1941 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1942 | | string _invocationId = null; |
| 0 | 1943 | | if (_shouldTrace) |
| | 1944 | | { |
| 0 | 1945 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1946 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1947 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 1948 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1949 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1950 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1951 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1952 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1953 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1954 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1955 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1956 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1957 | | ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters); |
| | 1958 | | } |
| | 1959 | | // Construct URL |
| 0 | 1960 | | var _baseUrl = Client.BaseUri; |
| 0 | 1961 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/enable"; |
| 0 | 1962 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1963 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 1964 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1965 | | if (Client.ApiVersion != null) |
| | 1966 | | { |
| 0 | 1967 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1968 | | } |
| 0 | 1969 | | if (timeout != null) |
| | 1970 | | { |
| 0 | 1971 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1972 | | } |
| 0 | 1973 | | if (_queryParameters.Count > 0) |
| | 1974 | | { |
| 0 | 1975 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1976 | | } |
| | 1977 | | // Create HTTP transport objects |
| 0 | 1978 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1979 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1980 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 1981 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1982 | | // Set Headers |
| 0 | 1983 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1984 | | { |
| 0 | 1985 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1986 | | } |
| 0 | 1987 | | if (Client.AcceptLanguage != null) |
| | 1988 | | { |
| 0 | 1989 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1990 | | { |
| 0 | 1991 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1992 | | } |
| 0 | 1993 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1994 | | } |
| 0 | 1995 | | if (clientRequestId != null) |
| | 1996 | | { |
| 0 | 1997 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1998 | | { |
| 0 | 1999 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2000 | | } |
| 0 | 2001 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2002 | | } |
| 0 | 2003 | | if (returnClientRequestId != null) |
| | 2004 | | { |
| 0 | 2005 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2006 | | { |
| 0 | 2007 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2008 | | } |
| 0 | 2009 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2010 | | } |
| 0 | 2011 | | if (ocpDate != null) |
| | 2012 | | { |
| 0 | 2013 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2014 | | { |
| 0 | 2015 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2016 | | } |
| 0 | 2017 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2018 | | } |
| 0 | 2019 | | if (ifMatch != null) |
| | 2020 | | { |
| 0 | 2021 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 2022 | | { |
| 0 | 2023 | | _httpRequest.Headers.Remove("If-Match"); |
| | 2024 | | } |
| 0 | 2025 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 2026 | | } |
| 0 | 2027 | | if (ifNoneMatch != null) |
| | 2028 | | { |
| 0 | 2029 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 2030 | | { |
| 0 | 2031 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 2032 | | } |
| 0 | 2033 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 2034 | | } |
| 0 | 2035 | | if (ifModifiedSince != null) |
| | 2036 | | { |
| 0 | 2037 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 2038 | | { |
| 0 | 2039 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 2040 | | } |
| 0 | 2041 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 2042 | | } |
| 0 | 2043 | | if (ifUnmodifiedSince != null) |
| | 2044 | | { |
| 0 | 2045 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 2046 | | { |
| 0 | 2047 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 2048 | | } |
| 0 | 2049 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 2050 | | } |
| | 2051 | |
|
| | 2052 | |
|
| 0 | 2053 | | if (customHeaders != null) |
| | 2054 | | { |
| 0 | 2055 | | foreach(var _header in customHeaders) |
| | 2056 | | { |
| 0 | 2057 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2058 | | { |
| 0 | 2059 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2060 | | } |
| 0 | 2061 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2062 | | } |
| | 2063 | | } |
| | 2064 | |
|
| | 2065 | | // Serialize Request |
| 0 | 2066 | | string _requestContent = null; |
| | 2067 | | // Set Credentials |
| 0 | 2068 | | if (Client.Credentials != null) |
| | 2069 | | { |
| 0 | 2070 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2071 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2072 | | } |
| | 2073 | | // Send Request |
| 0 | 2074 | | if (_shouldTrace) |
| | 2075 | | { |
| 0 | 2076 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2077 | | } |
| 0 | 2078 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2079 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2080 | | if (_shouldTrace) |
| | 2081 | | { |
| 0 | 2082 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2083 | | } |
| 0 | 2084 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2085 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2086 | | string _responseContent = null; |
| 0 | 2087 | | if ((int)_statusCode != 204) |
| | 2088 | | { |
| 0 | 2089 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2090 | | try |
| | 2091 | | { |
| 0 | 2092 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2093 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2094 | | if (_errorBody != null) |
| | 2095 | | { |
| 0 | 2096 | | ex.Body = _errorBody; |
| | 2097 | | } |
| 0 | 2098 | | } |
| 0 | 2099 | | catch (JsonException) |
| | 2100 | | { |
| | 2101 | | // Ignore the exception |
| 0 | 2102 | | } |
| 0 | 2103 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2104 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2105 | | if (_shouldTrace) |
| | 2106 | | { |
| 0 | 2107 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2108 | | } |
| 0 | 2109 | | _httpRequest.Dispose(); |
| 0 | 2110 | | if (_httpResponse != null) |
| | 2111 | | { |
| 0 | 2112 | | _httpResponse.Dispose(); |
| | 2113 | | } |
| 0 | 2114 | | throw ex; |
| | 2115 | | } |
| | 2116 | | // Create Result |
| 0 | 2117 | | var _result = new AzureOperationHeaderResponse<JobScheduleEnableHeaders>(); |
| 0 | 2118 | | _result.Request = _httpRequest; |
| 0 | 2119 | | _result.Response = _httpResponse; |
| 0 | 2120 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2121 | | { |
| 0 | 2122 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2123 | | } |
| | 2124 | | try |
| | 2125 | | { |
| 0 | 2126 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleEnableHeaders>(JsonSerializer.Cre |
| 0 | 2127 | | } |
| 0 | 2128 | | catch (JsonException ex) |
| | 2129 | | { |
| 0 | 2130 | | _httpRequest.Dispose(); |
| 0 | 2131 | | if (_httpResponse != null) |
| | 2132 | | { |
| 0 | 2133 | | _httpResponse.Dispose(); |
| | 2134 | | } |
| 0 | 2135 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2136 | | } |
| 0 | 2137 | | if (_shouldTrace) |
| | 2138 | | { |
| 0 | 2139 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2140 | | } |
| 0 | 2141 | | return _result; |
| 0 | 2142 | | } |
| | 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 | | { |
| 0 | 2173 | | if (Client.BatchUrl == null) |
| | 2174 | | { |
| 0 | 2175 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 2176 | | } |
| 0 | 2177 | | if (jobScheduleId == null) |
| | 2178 | | { |
| 0 | 2179 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobScheduleId"); |
| | 2180 | | } |
| 0 | 2181 | | if (Client.ApiVersion == null) |
| | 2182 | | { |
| 0 | 2183 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 2184 | | } |
| 0 | 2185 | | int? timeout = default(int?); |
| 0 | 2186 | | if (jobScheduleTerminateOptions != null) |
| | 2187 | | { |
| 0 | 2188 | | timeout = jobScheduleTerminateOptions.Timeout; |
| | 2189 | | } |
| 0 | 2190 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2191 | | if (jobScheduleTerminateOptions != null) |
| | 2192 | | { |
| 0 | 2193 | | clientRequestId = jobScheduleTerminateOptions.ClientRequestId; |
| | 2194 | | } |
| 0 | 2195 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2196 | | if (jobScheduleTerminateOptions != null) |
| | 2197 | | { |
| 0 | 2198 | | returnClientRequestId = jobScheduleTerminateOptions.ReturnClientRequestId; |
| | 2199 | | } |
| 0 | 2200 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2201 | | if (jobScheduleTerminateOptions != null) |
| | 2202 | | { |
| 0 | 2203 | | ocpDate = jobScheduleTerminateOptions.OcpDate; |
| | 2204 | | } |
| 0 | 2205 | | string ifMatch = default(string); |
| 0 | 2206 | | if (jobScheduleTerminateOptions != null) |
| | 2207 | | { |
| 0 | 2208 | | ifMatch = jobScheduleTerminateOptions.IfMatch; |
| | 2209 | | } |
| 0 | 2210 | | string ifNoneMatch = default(string); |
| 0 | 2211 | | if (jobScheduleTerminateOptions != null) |
| | 2212 | | { |
| 0 | 2213 | | ifNoneMatch = jobScheduleTerminateOptions.IfNoneMatch; |
| | 2214 | | } |
| 0 | 2215 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 2216 | | if (jobScheduleTerminateOptions != null) |
| | 2217 | | { |
| 0 | 2218 | | ifModifiedSince = jobScheduleTerminateOptions.IfModifiedSince; |
| | 2219 | | } |
| 0 | 2220 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 2221 | | if (jobScheduleTerminateOptions != null) |
| | 2222 | | { |
| 0 | 2223 | | ifUnmodifiedSince = jobScheduleTerminateOptions.IfUnmodifiedSince; |
| | 2224 | | } |
| | 2225 | | // Tracing |
| 0 | 2226 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2227 | | string _invocationId = null; |
| 0 | 2228 | | if (_shouldTrace) |
| | 2229 | | { |
| 0 | 2230 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2231 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2232 | | tracingParameters.Add("jobScheduleId", jobScheduleId); |
| 0 | 2233 | | tracingParameters.Add("timeout", timeout); |
| 0 | 2234 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2235 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2236 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2237 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 2238 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 2239 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 2240 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 2241 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2242 | | ServiceClientTracing.Enter(_invocationId, this, "Terminate", tracingParameters); |
| | 2243 | | } |
| | 2244 | | // Construct URL |
| 0 | 2245 | | var _baseUrl = Client.BaseUri; |
| 0 | 2246 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules/{jobScheduleId}/terminate"; |
| 0 | 2247 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 2248 | | _url = _url.Replace("{jobScheduleId}", System.Uri.EscapeDataString(jobScheduleId)); |
| 0 | 2249 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2250 | | if (Client.ApiVersion != null) |
| | 2251 | | { |
| 0 | 2252 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 2253 | | } |
| 0 | 2254 | | if (timeout != null) |
| | 2255 | | { |
| 0 | 2256 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 2257 | | } |
| 0 | 2258 | | if (_queryParameters.Count > 0) |
| | 2259 | | { |
| 0 | 2260 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2261 | | } |
| | 2262 | | // Create HTTP transport objects |
| 0 | 2263 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2264 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2265 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 2266 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2267 | | // Set Headers |
| 0 | 2268 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2269 | | { |
| 0 | 2270 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2271 | | } |
| 0 | 2272 | | if (Client.AcceptLanguage != null) |
| | 2273 | | { |
| 0 | 2274 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2275 | | { |
| 0 | 2276 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2277 | | } |
| 0 | 2278 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2279 | | } |
| 0 | 2280 | | if (clientRequestId != null) |
| | 2281 | | { |
| 0 | 2282 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2283 | | { |
| 0 | 2284 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2285 | | } |
| 0 | 2286 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2287 | | } |
| 0 | 2288 | | if (returnClientRequestId != null) |
| | 2289 | | { |
| 0 | 2290 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2291 | | { |
| 0 | 2292 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2293 | | } |
| 0 | 2294 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2295 | | } |
| 0 | 2296 | | if (ocpDate != null) |
| | 2297 | | { |
| 0 | 2298 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2299 | | { |
| 0 | 2300 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2301 | | } |
| 0 | 2302 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2303 | | } |
| 0 | 2304 | | if (ifMatch != null) |
| | 2305 | | { |
| 0 | 2306 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 2307 | | { |
| 0 | 2308 | | _httpRequest.Headers.Remove("If-Match"); |
| | 2309 | | } |
| 0 | 2310 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 2311 | | } |
| 0 | 2312 | | if (ifNoneMatch != null) |
| | 2313 | | { |
| 0 | 2314 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 2315 | | { |
| 0 | 2316 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 2317 | | } |
| 0 | 2318 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 2319 | | } |
| 0 | 2320 | | if (ifModifiedSince != null) |
| | 2321 | | { |
| 0 | 2322 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 2323 | | { |
| 0 | 2324 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 2325 | | } |
| 0 | 2326 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 2327 | | } |
| 0 | 2328 | | if (ifUnmodifiedSince != null) |
| | 2329 | | { |
| 0 | 2330 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 2331 | | { |
| 0 | 2332 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 2333 | | } |
| 0 | 2334 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 2335 | | } |
| | 2336 | |
|
| | 2337 | |
|
| 0 | 2338 | | if (customHeaders != null) |
| | 2339 | | { |
| 0 | 2340 | | foreach(var _header in customHeaders) |
| | 2341 | | { |
| 0 | 2342 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2343 | | { |
| 0 | 2344 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2345 | | } |
| 0 | 2346 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2347 | | } |
| | 2348 | | } |
| | 2349 | |
|
| | 2350 | | // Serialize Request |
| 0 | 2351 | | string _requestContent = null; |
| | 2352 | | // Set Credentials |
| 0 | 2353 | | if (Client.Credentials != null) |
| | 2354 | | { |
| 0 | 2355 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2356 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2357 | | } |
| | 2358 | | // Send Request |
| 0 | 2359 | | if (_shouldTrace) |
| | 2360 | | { |
| 0 | 2361 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2362 | | } |
| 0 | 2363 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2364 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2365 | | if (_shouldTrace) |
| | 2366 | | { |
| 0 | 2367 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2368 | | } |
| 0 | 2369 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2370 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2371 | | string _responseContent = null; |
| 0 | 2372 | | if ((int)_statusCode != 202) |
| | 2373 | | { |
| 0 | 2374 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2375 | | try |
| | 2376 | | { |
| 0 | 2377 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2378 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2379 | | if (_errorBody != null) |
| | 2380 | | { |
| 0 | 2381 | | ex.Body = _errorBody; |
| | 2382 | | } |
| 0 | 2383 | | } |
| 0 | 2384 | | catch (JsonException) |
| | 2385 | | { |
| | 2386 | | // Ignore the exception |
| 0 | 2387 | | } |
| 0 | 2388 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2389 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2390 | | if (_shouldTrace) |
| | 2391 | | { |
| 0 | 2392 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2393 | | } |
| 0 | 2394 | | _httpRequest.Dispose(); |
| 0 | 2395 | | if (_httpResponse != null) |
| | 2396 | | { |
| 0 | 2397 | | _httpResponse.Dispose(); |
| | 2398 | | } |
| 0 | 2399 | | throw ex; |
| | 2400 | | } |
| | 2401 | | // Create Result |
| 0 | 2402 | | var _result = new AzureOperationHeaderResponse<JobScheduleTerminateHeaders>(); |
| 0 | 2403 | | _result.Request = _httpRequest; |
| 0 | 2404 | | _result.Response = _httpResponse; |
| 0 | 2405 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2406 | | { |
| 0 | 2407 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2408 | | } |
| | 2409 | | try |
| | 2410 | | { |
| 0 | 2411 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleTerminateHeaders>(JsonSerializer. |
| 0 | 2412 | | } |
| 0 | 2413 | | catch (JsonException ex) |
| | 2414 | | { |
| 0 | 2415 | | _httpRequest.Dispose(); |
| 0 | 2416 | | if (_httpResponse != null) |
| | 2417 | | { |
| 0 | 2418 | | _httpResponse.Dispose(); |
| | 2419 | | } |
| 0 | 2420 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2421 | | } |
| 0 | 2422 | | if (_shouldTrace) |
| | 2423 | | { |
| 0 | 2424 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2425 | | } |
| 0 | 2426 | | return _result; |
| 0 | 2427 | | } |
| | 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 | | { |
| 0 | 2458 | | if (Client.BatchUrl == null) |
| | 2459 | | { |
| 0 | 2460 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 2461 | | } |
| 0 | 2462 | | if (cloudJobSchedule == null) |
| | 2463 | | { |
| 0 | 2464 | | throw new ValidationException(ValidationRules.CannotBeNull, "cloudJobSchedule"); |
| | 2465 | | } |
| 0 | 2466 | | if (Client.ApiVersion == null) |
| | 2467 | | { |
| 0 | 2468 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 2469 | | } |
| 0 | 2470 | | int? timeout = default(int?); |
| 0 | 2471 | | if (jobScheduleAddOptions != null) |
| | 2472 | | { |
| 0 | 2473 | | timeout = jobScheduleAddOptions.Timeout; |
| | 2474 | | } |
| 0 | 2475 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2476 | | if (jobScheduleAddOptions != null) |
| | 2477 | | { |
| 0 | 2478 | | clientRequestId = jobScheduleAddOptions.ClientRequestId; |
| | 2479 | | } |
| 0 | 2480 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2481 | | if (jobScheduleAddOptions != null) |
| | 2482 | | { |
| 0 | 2483 | | returnClientRequestId = jobScheduleAddOptions.ReturnClientRequestId; |
| | 2484 | | } |
| 0 | 2485 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2486 | | if (jobScheduleAddOptions != null) |
| | 2487 | | { |
| 0 | 2488 | | ocpDate = jobScheduleAddOptions.OcpDate; |
| | 2489 | | } |
| | 2490 | | // Tracing |
| 0 | 2491 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2492 | | string _invocationId = null; |
| 0 | 2493 | | if (_shouldTrace) |
| | 2494 | | { |
| 0 | 2495 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2496 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2497 | | tracingParameters.Add("cloudJobSchedule", cloudJobSchedule); |
| 0 | 2498 | | tracingParameters.Add("timeout", timeout); |
| 0 | 2499 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2500 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2501 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2502 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2503 | | ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); |
| | 2504 | | } |
| | 2505 | | // Construct URL |
| 0 | 2506 | | var _baseUrl = Client.BaseUri; |
| 0 | 2507 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules"; |
| 0 | 2508 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 2509 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2510 | | if (Client.ApiVersion != null) |
| | 2511 | | { |
| 0 | 2512 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 2513 | | } |
| 0 | 2514 | | if (timeout != null) |
| | 2515 | | { |
| 0 | 2516 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 2517 | | } |
| 0 | 2518 | | if (_queryParameters.Count > 0) |
| | 2519 | | { |
| 0 | 2520 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2521 | | } |
| | 2522 | | // Create HTTP transport objects |
| 0 | 2523 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2524 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2525 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 2526 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2527 | | // Set Headers |
| 0 | 2528 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2529 | | { |
| 0 | 2530 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2531 | | } |
| 0 | 2532 | | if (Client.AcceptLanguage != null) |
| | 2533 | | { |
| 0 | 2534 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2535 | | { |
| 0 | 2536 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2537 | | } |
| 0 | 2538 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2539 | | } |
| 0 | 2540 | | if (clientRequestId != null) |
| | 2541 | | { |
| 0 | 2542 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2543 | | { |
| 0 | 2544 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2545 | | } |
| 0 | 2546 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2547 | | } |
| 0 | 2548 | | if (returnClientRequestId != null) |
| | 2549 | | { |
| 0 | 2550 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2551 | | { |
| 0 | 2552 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2553 | | } |
| 0 | 2554 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2555 | | } |
| 0 | 2556 | | if (ocpDate != null) |
| | 2557 | | { |
| 0 | 2558 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2559 | | { |
| 0 | 2560 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2561 | | } |
| 0 | 2562 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2563 | | } |
| | 2564 | |
|
| | 2565 | |
|
| 0 | 2566 | | if (customHeaders != null) |
| | 2567 | | { |
| 0 | 2568 | | foreach(var _header in customHeaders) |
| | 2569 | | { |
| 0 | 2570 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2571 | | { |
| 0 | 2572 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2573 | | } |
| 0 | 2574 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2575 | | } |
| | 2576 | | } |
| | 2577 | |
|
| | 2578 | | // Serialize Request |
| 0 | 2579 | | string _requestContent = null; |
| 0 | 2580 | | if(cloudJobSchedule != null) |
| | 2581 | | { |
| 0 | 2582 | | _requestContent = SafeJsonConvert.SerializeObject(cloudJobSchedule, Client.SerializationSettings); |
| 0 | 2583 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 2584 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 2585 | | } |
| | 2586 | | // Set Credentials |
| 0 | 2587 | | if (Client.Credentials != null) |
| | 2588 | | { |
| 0 | 2589 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2590 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2591 | | } |
| | 2592 | | // Send Request |
| 0 | 2593 | | if (_shouldTrace) |
| | 2594 | | { |
| 0 | 2595 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2596 | | } |
| 0 | 2597 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2598 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2599 | | if (_shouldTrace) |
| | 2600 | | { |
| 0 | 2601 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2602 | | } |
| 0 | 2603 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2604 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2605 | | string _responseContent = null; |
| 0 | 2606 | | if ((int)_statusCode != 201) |
| | 2607 | | { |
| 0 | 2608 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2609 | | try |
| | 2610 | | { |
| 0 | 2611 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2612 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2613 | | if (_errorBody != null) |
| | 2614 | | { |
| 0 | 2615 | | ex.Body = _errorBody; |
| | 2616 | | } |
| 0 | 2617 | | } |
| 0 | 2618 | | catch (JsonException) |
| | 2619 | | { |
| | 2620 | | // Ignore the exception |
| 0 | 2621 | | } |
| 0 | 2622 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2623 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2624 | | if (_shouldTrace) |
| | 2625 | | { |
| 0 | 2626 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2627 | | } |
| 0 | 2628 | | _httpRequest.Dispose(); |
| 0 | 2629 | | if (_httpResponse != null) |
| | 2630 | | { |
| 0 | 2631 | | _httpResponse.Dispose(); |
| | 2632 | | } |
| 0 | 2633 | | throw ex; |
| | 2634 | | } |
| | 2635 | | // Create Result |
| 0 | 2636 | | var _result = new AzureOperationHeaderResponse<JobScheduleAddHeaders>(); |
| 0 | 2637 | | _result.Request = _httpRequest; |
| 0 | 2638 | | _result.Response = _httpResponse; |
| 0 | 2639 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2640 | | { |
| 0 | 2641 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2642 | | } |
| | 2643 | | try |
| | 2644 | | { |
| 0 | 2645 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleAddHeaders>(JsonSerializer.Create |
| 0 | 2646 | | } |
| 0 | 2647 | | catch (JsonException ex) |
| | 2648 | | { |
| 0 | 2649 | | _httpRequest.Dispose(); |
| 0 | 2650 | | if (_httpResponse != null) |
| | 2651 | | { |
| 0 | 2652 | | _httpResponse.Dispose(); |
| | 2653 | | } |
| 0 | 2654 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2655 | | } |
| 0 | 2656 | | if (_shouldTrace) |
| | 2657 | | { |
| 0 | 2658 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2659 | | } |
| 0 | 2660 | | return _result; |
| 0 | 2661 | | } |
| | 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 | | { |
| 0 | 2692 | | if (Client.BatchUrl == null) |
| | 2693 | | { |
| 0 | 2694 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 2695 | | } |
| 0 | 2696 | | if (Client.ApiVersion == null) |
| | 2697 | | { |
| 0 | 2698 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 2699 | | } |
| 0 | 2700 | | string filter = default(string); |
| 0 | 2701 | | if (jobScheduleListOptions != null) |
| | 2702 | | { |
| 0 | 2703 | | filter = jobScheduleListOptions.Filter; |
| | 2704 | | } |
| 0 | 2705 | | string select = default(string); |
| 0 | 2706 | | if (jobScheduleListOptions != null) |
| | 2707 | | { |
| 0 | 2708 | | select = jobScheduleListOptions.Select; |
| | 2709 | | } |
| 0 | 2710 | | string expand = default(string); |
| 0 | 2711 | | if (jobScheduleListOptions != null) |
| | 2712 | | { |
| 0 | 2713 | | expand = jobScheduleListOptions.Expand; |
| | 2714 | | } |
| 0 | 2715 | | int? maxResults = default(int?); |
| 0 | 2716 | | if (jobScheduleListOptions != null) |
| | 2717 | | { |
| 0 | 2718 | | maxResults = jobScheduleListOptions.MaxResults; |
| | 2719 | | } |
| 0 | 2720 | | int? timeout = default(int?); |
| 0 | 2721 | | if (jobScheduleListOptions != null) |
| | 2722 | | { |
| 0 | 2723 | | timeout = jobScheduleListOptions.Timeout; |
| | 2724 | | } |
| 0 | 2725 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2726 | | if (jobScheduleListOptions != null) |
| | 2727 | | { |
| 0 | 2728 | | clientRequestId = jobScheduleListOptions.ClientRequestId; |
| | 2729 | | } |
| 0 | 2730 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2731 | | if (jobScheduleListOptions != null) |
| | 2732 | | { |
| 0 | 2733 | | returnClientRequestId = jobScheduleListOptions.ReturnClientRequestId; |
| | 2734 | | } |
| 0 | 2735 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2736 | | if (jobScheduleListOptions != null) |
| | 2737 | | { |
| 0 | 2738 | | ocpDate = jobScheduleListOptions.OcpDate; |
| | 2739 | | } |
| | 2740 | | // Tracing |
| 0 | 2741 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2742 | | string _invocationId = null; |
| 0 | 2743 | | if (_shouldTrace) |
| | 2744 | | { |
| 0 | 2745 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2746 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2747 | | tracingParameters.Add("filter", filter); |
| 0 | 2748 | | tracingParameters.Add("select", select); |
| 0 | 2749 | | tracingParameters.Add("expand", expand); |
| 0 | 2750 | | tracingParameters.Add("maxResults", maxResults); |
| 0 | 2751 | | tracingParameters.Add("timeout", timeout); |
| 0 | 2752 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2753 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2754 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2755 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2756 | | ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); |
| | 2757 | | } |
| | 2758 | | // Construct URL |
| 0 | 2759 | | var _baseUrl = Client.BaseUri; |
| 0 | 2760 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobschedules"; |
| 0 | 2761 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 2762 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2763 | | if (Client.ApiVersion != null) |
| | 2764 | | { |
| 0 | 2765 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 2766 | | } |
| 0 | 2767 | | if (filter != null) |
| | 2768 | | { |
| 0 | 2769 | | _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); |
| | 2770 | | } |
| 0 | 2771 | | if (select != null) |
| | 2772 | | { |
| 0 | 2773 | | _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); |
| | 2774 | | } |
| 0 | 2775 | | if (expand != null) |
| | 2776 | | { |
| 0 | 2777 | | _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); |
| | 2778 | | } |
| 0 | 2779 | | if (maxResults != null) |
| | 2780 | | { |
| 0 | 2781 | | _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali |
| | 2782 | | } |
| 0 | 2783 | | if (timeout != null) |
| | 2784 | | { |
| 0 | 2785 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 2786 | | } |
| 0 | 2787 | | if (_queryParameters.Count > 0) |
| | 2788 | | { |
| 0 | 2789 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2790 | | } |
| | 2791 | | // Create HTTP transport objects |
| 0 | 2792 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2793 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2794 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 2795 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2796 | | // Set Headers |
| 0 | 2797 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2798 | | { |
| 0 | 2799 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2800 | | } |
| 0 | 2801 | | if (Client.AcceptLanguage != null) |
| | 2802 | | { |
| 0 | 2803 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2804 | | { |
| 0 | 2805 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2806 | | } |
| 0 | 2807 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2808 | | } |
| 0 | 2809 | | if (clientRequestId != null) |
| | 2810 | | { |
| 0 | 2811 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2812 | | { |
| 0 | 2813 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2814 | | } |
| 0 | 2815 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2816 | | } |
| 0 | 2817 | | if (returnClientRequestId != null) |
| | 2818 | | { |
| 0 | 2819 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2820 | | { |
| 0 | 2821 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2822 | | } |
| 0 | 2823 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2824 | | } |
| 0 | 2825 | | if (ocpDate != null) |
| | 2826 | | { |
| 0 | 2827 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2828 | | { |
| 0 | 2829 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2830 | | } |
| 0 | 2831 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2832 | | } |
| | 2833 | |
|
| | 2834 | |
|
| 0 | 2835 | | if (customHeaders != null) |
| | 2836 | | { |
| 0 | 2837 | | foreach(var _header in customHeaders) |
| | 2838 | | { |
| 0 | 2839 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2840 | | { |
| 0 | 2841 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2842 | | } |
| 0 | 2843 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2844 | | } |
| | 2845 | | } |
| | 2846 | |
|
| | 2847 | | // Serialize Request |
| 0 | 2848 | | string _requestContent = null; |
| | 2849 | | // Set Credentials |
| 0 | 2850 | | if (Client.Credentials != null) |
| | 2851 | | { |
| 0 | 2852 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2853 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2854 | | } |
| | 2855 | | // Send Request |
| 0 | 2856 | | if (_shouldTrace) |
| | 2857 | | { |
| 0 | 2858 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2859 | | } |
| 0 | 2860 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2861 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2862 | | if (_shouldTrace) |
| | 2863 | | { |
| 0 | 2864 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2865 | | } |
| 0 | 2866 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2867 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2868 | | string _responseContent = null; |
| 0 | 2869 | | if ((int)_statusCode != 200) |
| | 2870 | | { |
| 0 | 2871 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2872 | | try |
| | 2873 | | { |
| 0 | 2874 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2875 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2876 | | if (_errorBody != null) |
| | 2877 | | { |
| 0 | 2878 | | ex.Body = _errorBody; |
| | 2879 | | } |
| 0 | 2880 | | } |
| 0 | 2881 | | catch (JsonException) |
| | 2882 | | { |
| | 2883 | | // Ignore the exception |
| 0 | 2884 | | } |
| 0 | 2885 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2886 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2887 | | if (_shouldTrace) |
| | 2888 | | { |
| 0 | 2889 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2890 | | } |
| 0 | 2891 | | _httpRequest.Dispose(); |
| 0 | 2892 | | if (_httpResponse != null) |
| | 2893 | | { |
| 0 | 2894 | | _httpResponse.Dispose(); |
| | 2895 | | } |
| 0 | 2896 | | throw ex; |
| | 2897 | | } |
| | 2898 | | // Create Result |
| 0 | 2899 | | var _result = new AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>(); |
| 0 | 2900 | | _result.Request = _httpRequest; |
| 0 | 2901 | | _result.Response = _httpResponse; |
| 0 | 2902 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2903 | | { |
| 0 | 2904 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2905 | | } |
| | 2906 | | // Deserialize Response |
| 0 | 2907 | | if ((int)_statusCode == 200) |
| | 2908 | | { |
| 0 | 2909 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2910 | | try |
| | 2911 | | { |
| 0 | 2912 | | _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJobSchedule>>(_responseContent, Client.De |
| 0 | 2913 | | } |
| 0 | 2914 | | catch (JsonException ex) |
| | 2915 | | { |
| 0 | 2916 | | _httpRequest.Dispose(); |
| 0 | 2917 | | if (_httpResponse != null) |
| | 2918 | | { |
| 0 | 2919 | | _httpResponse.Dispose(); |
| | 2920 | | } |
| 0 | 2921 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2922 | | } |
| | 2923 | | } |
| | 2924 | | try |
| | 2925 | | { |
| 0 | 2926 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleListHeaders>(JsonSerializer.Creat |
| 0 | 2927 | | } |
| 0 | 2928 | | catch (JsonException ex) |
| | 2929 | | { |
| 0 | 2930 | | _httpRequest.Dispose(); |
| 0 | 2931 | | if (_httpResponse != null) |
| | 2932 | | { |
| 0 | 2933 | | _httpResponse.Dispose(); |
| | 2934 | | } |
| 0 | 2935 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2936 | | } |
| 0 | 2937 | | if (_shouldTrace) |
| | 2938 | | { |
| 0 | 2939 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2940 | | } |
| 0 | 2941 | | return _result; |
| 0 | 2942 | | } |
| | 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 | | { |
| 0 | 2976 | | if (nextPageLink == null) |
| | 2977 | | { |
| 0 | 2978 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); |
| | 2979 | | } |
| 0 | 2980 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2981 | | if (jobScheduleListNextOptions != null) |
| | 2982 | | { |
| 0 | 2983 | | clientRequestId = jobScheduleListNextOptions.ClientRequestId; |
| | 2984 | | } |
| 0 | 2985 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2986 | | if (jobScheduleListNextOptions != null) |
| | 2987 | | { |
| 0 | 2988 | | returnClientRequestId = jobScheduleListNextOptions.ReturnClientRequestId; |
| | 2989 | | } |
| 0 | 2990 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2991 | | if (jobScheduleListNextOptions != null) |
| | 2992 | | { |
| 0 | 2993 | | ocpDate = jobScheduleListNextOptions.OcpDate; |
| | 2994 | | } |
| | 2995 | | // Tracing |
| 0 | 2996 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2997 | | string _invocationId = null; |
| 0 | 2998 | | if (_shouldTrace) |
| | 2999 | | { |
| 0 | 3000 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3001 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3002 | | tracingParameters.Add("nextPageLink", nextPageLink); |
| 0 | 3003 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 3004 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 3005 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 3006 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3007 | | ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); |
| | 3008 | | } |
| | 3009 | | // Construct URL |
| 0 | 3010 | | string _url = "{nextLink}"; |
| 0 | 3011 | | _url = _url.Replace("{nextLink}", nextPageLink); |
| 0 | 3012 | | List<string> _queryParameters = new List<string>(); |
| 0 | 3013 | | if (_queryParameters.Count > 0) |
| | 3014 | | { |
| 0 | 3015 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 3016 | | } |
| | 3017 | | // Create HTTP transport objects |
| 0 | 3018 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 3019 | | HttpResponseMessage _httpResponse = null; |
| 0 | 3020 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 3021 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3022 | | // Set Headers |
| 0 | 3023 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 3024 | | { |
| 0 | 3025 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 3026 | | } |
| 0 | 3027 | | if (Client.AcceptLanguage != null) |
| | 3028 | | { |
| 0 | 3029 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 3030 | | { |
| 0 | 3031 | | _httpRequest.Headers.Remove("accept-language"); |
| | 3032 | | } |
| 0 | 3033 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 3034 | | } |
| 0 | 3035 | | if (clientRequestId != null) |
| | 3036 | | { |
| 0 | 3037 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 3038 | | { |
| 0 | 3039 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 3040 | | } |
| 0 | 3041 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 3042 | | } |
| 0 | 3043 | | if (returnClientRequestId != null) |
| | 3044 | | { |
| 0 | 3045 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 3046 | | { |
| 0 | 3047 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 3048 | | } |
| 0 | 3049 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 3050 | | } |
| 0 | 3051 | | if (ocpDate != null) |
| | 3052 | | { |
| 0 | 3053 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 3054 | | { |
| 0 | 3055 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 3056 | | } |
| 0 | 3057 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 3058 | | } |
| | 3059 | |
|
| | 3060 | |
|
| 0 | 3061 | | if (customHeaders != null) |
| | 3062 | | { |
| 0 | 3063 | | foreach(var _header in customHeaders) |
| | 3064 | | { |
| 0 | 3065 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3066 | | { |
| 0 | 3067 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3068 | | } |
| 0 | 3069 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3070 | | } |
| | 3071 | | } |
| | 3072 | |
|
| | 3073 | | // Serialize Request |
| 0 | 3074 | | string _requestContent = null; |
| | 3075 | | // Set Credentials |
| 0 | 3076 | | if (Client.Credentials != null) |
| | 3077 | | { |
| 0 | 3078 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3079 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3080 | | } |
| | 3081 | | // Send Request |
| 0 | 3082 | | if (_shouldTrace) |
| | 3083 | | { |
| 0 | 3084 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3085 | | } |
| 0 | 3086 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3087 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 3088 | | if (_shouldTrace) |
| | 3089 | | { |
| 0 | 3090 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3091 | | } |
| 0 | 3092 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 3093 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3094 | | string _responseContent = null; |
| 0 | 3095 | | if ((int)_statusCode != 200) |
| | 3096 | | { |
| 0 | 3097 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 3098 | | try |
| | 3099 | | { |
| 0 | 3100 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3101 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 3102 | | if (_errorBody != null) |
| | 3103 | | { |
| 0 | 3104 | | ex.Body = _errorBody; |
| | 3105 | | } |
| 0 | 3106 | | } |
| 0 | 3107 | | catch (JsonException) |
| | 3108 | | { |
| | 3109 | | // Ignore the exception |
| 0 | 3110 | | } |
| 0 | 3111 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3112 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3113 | | if (_shouldTrace) |
| | 3114 | | { |
| 0 | 3115 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3116 | | } |
| 0 | 3117 | | _httpRequest.Dispose(); |
| 0 | 3118 | | if (_httpResponse != null) |
| | 3119 | | { |
| 0 | 3120 | | _httpResponse.Dispose(); |
| | 3121 | | } |
| 0 | 3122 | | throw ex; |
| | 3123 | | } |
| | 3124 | | // Create Result |
| 0 | 3125 | | var _result = new AzureOperationResponse<IPage<CloudJobSchedule>,JobScheduleListHeaders>(); |
| 0 | 3126 | | _result.Request = _httpRequest; |
| 0 | 3127 | | _result.Response = _httpResponse; |
| 0 | 3128 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 3129 | | { |
| 0 | 3130 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 3131 | | } |
| | 3132 | | // Deserialize Response |
| 0 | 3133 | | if ((int)_statusCode == 200) |
| | 3134 | | { |
| 0 | 3135 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3136 | | try |
| | 3137 | | { |
| 0 | 3138 | | _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudJobSchedule>>(_responseContent, Client.De |
| 0 | 3139 | | } |
| 0 | 3140 | | catch (JsonException ex) |
| | 3141 | | { |
| 0 | 3142 | | _httpRequest.Dispose(); |
| 0 | 3143 | | if (_httpResponse != null) |
| | 3144 | | { |
| 0 | 3145 | | _httpResponse.Dispose(); |
| | 3146 | | } |
| 0 | 3147 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3148 | | } |
| | 3149 | | } |
| | 3150 | | try |
| | 3151 | | { |
| 0 | 3152 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<JobScheduleListHeaders>(JsonSerializer.Creat |
| 0 | 3153 | | } |
| 0 | 3154 | | catch (JsonException ex) |
| | 3155 | | { |
| 0 | 3156 | | _httpRequest.Dispose(); |
| 0 | 3157 | | if (_httpResponse != null) |
| | 3158 | | { |
| 0 | 3159 | | _httpResponse.Dispose(); |
| | 3160 | | } |
| 0 | 3161 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 3162 | | } |
| 0 | 3163 | | if (_shouldTrace) |
| | 3164 | | { |
| 0 | 3165 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3166 | | } |
| 0 | 3167 | | return _result; |
| 0 | 3168 | | } |
| | 3169 | |
|
| | 3170 | | } |
| | 3171 | | } |