| | 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 | | /// TaskOperations operations. |
| | 28 | | /// </summary> |
| | 29 | | internal partial class TaskOperations : IServiceOperations<BatchServiceClient>, ITaskOperations |
| | 30 | | { |
| | 31 | | /// <summary> |
| | 32 | | /// Initializes a new instance of the TaskOperations 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 TaskOperations(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> |
| 0 | 52 | | public BatchServiceClient Client { get; private set; } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Adds a Task to the specified Job. |
| | 56 | | /// </summary> |
| | 57 | | /// <remarks> |
| | 58 | | /// The maximum lifetime of a Task from addition to completion is 180 days. If |
| | 59 | | /// a Task has not completed within 180 days of being added it will be |
| | 60 | | /// terminated by the Batch service and left in whatever state it was in at |
| | 61 | | /// that time. |
| | 62 | | /// </remarks> |
| | 63 | | /// <param name='jobId'> |
| | 64 | | /// The ID of the Job to which the Task is to be added. |
| | 65 | | /// </param> |
| | 66 | | /// <param name='task'> |
| | 67 | | /// The Task to be added. |
| | 68 | | /// </param> |
| | 69 | | /// <param name='taskAddOptions'> |
| | 70 | | /// Additional parameters for the operation |
| | 71 | | /// </param> |
| | 72 | | /// <param name='customHeaders'> |
| | 73 | | /// Headers that will be added to request. |
| | 74 | | /// </param> |
| | 75 | | /// <param name='cancellationToken'> |
| | 76 | | /// The cancellation token. |
| | 77 | | /// </param> |
| | 78 | | /// <exception cref="BatchErrorException"> |
| | 79 | | /// Thrown when the operation returned an invalid status code |
| | 80 | | /// </exception> |
| | 81 | | /// <exception cref="ValidationException"> |
| | 82 | | /// Thrown when a required parameter is null |
| | 83 | | /// </exception> |
| | 84 | | /// <exception cref="System.ArgumentNullException"> |
| | 85 | | /// Thrown when a required parameter is null |
| | 86 | | /// </exception> |
| | 87 | | /// <return> |
| | 88 | | /// A response object containing the response body and response headers. |
| | 89 | | /// </return> |
| | 90 | | public async Task<AzureOperationHeaderResponse<TaskAddHeaders>> AddWithHttpMessagesAsync(string jobId, TaskAddPa |
| | 91 | | { |
| 0 | 92 | | if (Client.BatchUrl == null) |
| | 93 | | { |
| 0 | 94 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 95 | | } |
| 0 | 96 | | if (jobId == null) |
| | 97 | | { |
| 0 | 98 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 99 | | } |
| 0 | 100 | | if (task == null) |
| | 101 | | { |
| 0 | 102 | | throw new ValidationException(ValidationRules.CannotBeNull, "task"); |
| | 103 | | } |
| 0 | 104 | | if (Client.ApiVersion == null) |
| | 105 | | { |
| 0 | 106 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 107 | | } |
| 0 | 108 | | int? timeout = default(int?); |
| 0 | 109 | | if (taskAddOptions != null) |
| | 110 | | { |
| 0 | 111 | | timeout = taskAddOptions.Timeout; |
| | 112 | | } |
| 0 | 113 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 114 | | if (taskAddOptions != null) |
| | 115 | | { |
| 0 | 116 | | clientRequestId = taskAddOptions.ClientRequestId; |
| | 117 | | } |
| 0 | 118 | | bool? returnClientRequestId = default(bool?); |
| 0 | 119 | | if (taskAddOptions != null) |
| | 120 | | { |
| 0 | 121 | | returnClientRequestId = taskAddOptions.ReturnClientRequestId; |
| | 122 | | } |
| 0 | 123 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 124 | | if (taskAddOptions != null) |
| | 125 | | { |
| 0 | 126 | | ocpDate = taskAddOptions.OcpDate; |
| | 127 | | } |
| | 128 | | // Tracing |
| 0 | 129 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 130 | | string _invocationId = null; |
| 0 | 131 | | if (_shouldTrace) |
| | 132 | | { |
| 0 | 133 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 134 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 135 | | tracingParameters.Add("jobId", jobId); |
| 0 | 136 | | tracingParameters.Add("task", task); |
| 0 | 137 | | tracingParameters.Add("timeout", timeout); |
| 0 | 138 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 139 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 140 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 141 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 142 | | ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters); |
| | 143 | | } |
| | 144 | | // Construct URL |
| 0 | 145 | | var _baseUrl = Client.BaseUri; |
| 0 | 146 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks"; |
| 0 | 147 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 148 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 149 | | List<string> _queryParameters = new List<string>(); |
| 0 | 150 | | if (Client.ApiVersion != null) |
| | 151 | | { |
| 0 | 152 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 153 | | } |
| 0 | 154 | | if (timeout != null) |
| | 155 | | { |
| 0 | 156 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 157 | | } |
| 0 | 158 | | if (_queryParameters.Count > 0) |
| | 159 | | { |
| 0 | 160 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 161 | | } |
| | 162 | | // Create HTTP transport objects |
| 0 | 163 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 164 | | HttpResponseMessage _httpResponse = null; |
| 0 | 165 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 166 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 167 | | // Set Headers |
| 0 | 168 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 169 | | { |
| 0 | 170 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 171 | | } |
| 0 | 172 | | if (Client.AcceptLanguage != null) |
| | 173 | | { |
| 0 | 174 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 175 | | { |
| 0 | 176 | | _httpRequest.Headers.Remove("accept-language"); |
| | 177 | | } |
| 0 | 178 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 179 | | } |
| 0 | 180 | | if (clientRequestId != null) |
| | 181 | | { |
| 0 | 182 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 183 | | { |
| 0 | 184 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 185 | | } |
| 0 | 186 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 187 | | } |
| 0 | 188 | | if (returnClientRequestId != null) |
| | 189 | | { |
| 0 | 190 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 191 | | { |
| 0 | 192 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 193 | | } |
| 0 | 194 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 195 | | } |
| 0 | 196 | | if (ocpDate != null) |
| | 197 | | { |
| 0 | 198 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 199 | | { |
| 0 | 200 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 201 | | } |
| 0 | 202 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 203 | | } |
| | 204 | |
|
| | 205 | |
|
| 0 | 206 | | if (customHeaders != null) |
| | 207 | | { |
| 0 | 208 | | foreach(var _header in customHeaders) |
| | 209 | | { |
| 0 | 210 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 211 | | { |
| 0 | 212 | | _httpRequest.Headers.Remove(_header.Key); |
| | 213 | | } |
| 0 | 214 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 215 | | } |
| | 216 | | } |
| | 217 | |
|
| | 218 | | // Serialize Request |
| 0 | 219 | | string _requestContent = null; |
| 0 | 220 | | if(task != null) |
| | 221 | | { |
| 0 | 222 | | _requestContent = SafeJsonConvert.SerializeObject(task, Client.SerializationSettings); |
| 0 | 223 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 224 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 225 | | } |
| | 226 | | // Set Credentials |
| 0 | 227 | | if (Client.Credentials != null) |
| | 228 | | { |
| 0 | 229 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 230 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 231 | | } |
| | 232 | | // Send Request |
| 0 | 233 | | if (_shouldTrace) |
| | 234 | | { |
| 0 | 235 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 236 | | } |
| 0 | 237 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 238 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 239 | | if (_shouldTrace) |
| | 240 | | { |
| 0 | 241 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 242 | | } |
| 0 | 243 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 244 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 245 | | string _responseContent = null; |
| 0 | 246 | | if ((int)_statusCode != 201) |
| | 247 | | { |
| 0 | 248 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 249 | | try |
| | 250 | | { |
| 0 | 251 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 252 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 253 | | if (_errorBody != null) |
| | 254 | | { |
| 0 | 255 | | ex.Body = _errorBody; |
| | 256 | | } |
| 0 | 257 | | } |
| 0 | 258 | | catch (JsonException) |
| | 259 | | { |
| | 260 | | // Ignore the exception |
| 0 | 261 | | } |
| 0 | 262 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 263 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 264 | | if (_shouldTrace) |
| | 265 | | { |
| 0 | 266 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 267 | | } |
| 0 | 268 | | _httpRequest.Dispose(); |
| 0 | 269 | | if (_httpResponse != null) |
| | 270 | | { |
| 0 | 271 | | _httpResponse.Dispose(); |
| | 272 | | } |
| 0 | 273 | | throw ex; |
| | 274 | | } |
| | 275 | | // Create Result |
| 0 | 276 | | var _result = new AzureOperationHeaderResponse<TaskAddHeaders>(); |
| 0 | 277 | | _result.Request = _httpRequest; |
| 0 | 278 | | _result.Response = _httpResponse; |
| 0 | 279 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 280 | | { |
| 0 | 281 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 282 | | } |
| | 283 | | try |
| | 284 | | { |
| 0 | 285 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskAddHeaders>(JsonSerializer.Create(Client |
| 0 | 286 | | } |
| 0 | 287 | | catch (JsonException ex) |
| | 288 | | { |
| 0 | 289 | | _httpRequest.Dispose(); |
| 0 | 290 | | if (_httpResponse != null) |
| | 291 | | { |
| 0 | 292 | | _httpResponse.Dispose(); |
| | 293 | | } |
| 0 | 294 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 295 | | } |
| 0 | 296 | | if (_shouldTrace) |
| | 297 | | { |
| 0 | 298 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 299 | | } |
| 0 | 300 | | return _result; |
| 0 | 301 | | } |
| | 302 | |
|
| | 303 | | /// <summary> |
| | 304 | | /// Lists all of the Tasks that are associated with the specified Job. |
| | 305 | | /// </summary> |
| | 306 | | /// <remarks> |
| | 307 | | /// For multi-instance Tasks, information such as affinityId, executionInfo and |
| | 308 | | /// nodeInfo refer to the primary Task. Use the list subtasks API to retrieve |
| | 309 | | /// information about subtasks. |
| | 310 | | /// </remarks> |
| | 311 | | /// <param name='jobId'> |
| | 312 | | /// The ID of the Job. |
| | 313 | | /// </param> |
| | 314 | | /// <param name='taskListOptions'> |
| | 315 | | /// Additional parameters for the operation |
| | 316 | | /// </param> |
| | 317 | | /// <param name='customHeaders'> |
| | 318 | | /// Headers that will be added to request. |
| | 319 | | /// </param> |
| | 320 | | /// <param name='cancellationToken'> |
| | 321 | | /// The cancellation token. |
| | 322 | | /// </param> |
| | 323 | | /// <exception cref="BatchErrorException"> |
| | 324 | | /// Thrown when the operation returned an invalid status code |
| | 325 | | /// </exception> |
| | 326 | | /// <exception cref="SerializationException"> |
| | 327 | | /// Thrown when unable to deserialize the response |
| | 328 | | /// </exception> |
| | 329 | | /// <exception cref="ValidationException"> |
| | 330 | | /// Thrown when a required parameter is null |
| | 331 | | /// </exception> |
| | 332 | | /// <exception cref="System.ArgumentNullException"> |
| | 333 | | /// Thrown when a required parameter is null |
| | 334 | | /// </exception> |
| | 335 | | /// <return> |
| | 336 | | /// A response object containing the response body and response headers. |
| | 337 | | /// </return> |
| | 338 | | public async Task<AzureOperationResponse<IPage<CloudTask>,TaskListHeaders>> ListWithHttpMessagesAsync(string job |
| | 339 | | { |
| 0 | 340 | | if (Client.BatchUrl == null) |
| | 341 | | { |
| 0 | 342 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 343 | | } |
| 0 | 344 | | if (jobId == null) |
| | 345 | | { |
| 0 | 346 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 347 | | } |
| 0 | 348 | | if (Client.ApiVersion == null) |
| | 349 | | { |
| 0 | 350 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 351 | | } |
| 0 | 352 | | string filter = default(string); |
| 0 | 353 | | if (taskListOptions != null) |
| | 354 | | { |
| 0 | 355 | | filter = taskListOptions.Filter; |
| | 356 | | } |
| 0 | 357 | | string select = default(string); |
| 0 | 358 | | if (taskListOptions != null) |
| | 359 | | { |
| 0 | 360 | | select = taskListOptions.Select; |
| | 361 | | } |
| 0 | 362 | | string expand = default(string); |
| 0 | 363 | | if (taskListOptions != null) |
| | 364 | | { |
| 0 | 365 | | expand = taskListOptions.Expand; |
| | 366 | | } |
| 0 | 367 | | int? maxResults = default(int?); |
| 0 | 368 | | if (taskListOptions != null) |
| | 369 | | { |
| 0 | 370 | | maxResults = taskListOptions.MaxResults; |
| | 371 | | } |
| 0 | 372 | | int? timeout = default(int?); |
| 0 | 373 | | if (taskListOptions != null) |
| | 374 | | { |
| 0 | 375 | | timeout = taskListOptions.Timeout; |
| | 376 | | } |
| 0 | 377 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 378 | | if (taskListOptions != null) |
| | 379 | | { |
| 0 | 380 | | clientRequestId = taskListOptions.ClientRequestId; |
| | 381 | | } |
| 0 | 382 | | bool? returnClientRequestId = default(bool?); |
| 0 | 383 | | if (taskListOptions != null) |
| | 384 | | { |
| 0 | 385 | | returnClientRequestId = taskListOptions.ReturnClientRequestId; |
| | 386 | | } |
| 0 | 387 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 388 | | if (taskListOptions != null) |
| | 389 | | { |
| 0 | 390 | | ocpDate = taskListOptions.OcpDate; |
| | 391 | | } |
| | 392 | | // Tracing |
| 0 | 393 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 394 | | string _invocationId = null; |
| 0 | 395 | | if (_shouldTrace) |
| | 396 | | { |
| 0 | 397 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 398 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 399 | | tracingParameters.Add("jobId", jobId); |
| 0 | 400 | | tracingParameters.Add("filter", filter); |
| 0 | 401 | | tracingParameters.Add("select", select); |
| 0 | 402 | | tracingParameters.Add("expand", expand); |
| 0 | 403 | | tracingParameters.Add("maxResults", maxResults); |
| 0 | 404 | | tracingParameters.Add("timeout", timeout); |
| 0 | 405 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 406 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 407 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 408 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 409 | | ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); |
| | 410 | | } |
| | 411 | | // Construct URL |
| 0 | 412 | | var _baseUrl = Client.BaseUri; |
| 0 | 413 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks"; |
| 0 | 414 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 415 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 416 | | List<string> _queryParameters = new List<string>(); |
| 0 | 417 | | if (Client.ApiVersion != null) |
| | 418 | | { |
| 0 | 419 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 420 | | } |
| 0 | 421 | | if (filter != null) |
| | 422 | | { |
| 0 | 423 | | _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); |
| | 424 | | } |
| 0 | 425 | | if (select != null) |
| | 426 | | { |
| 0 | 427 | | _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); |
| | 428 | | } |
| 0 | 429 | | if (expand != null) |
| | 430 | | { |
| 0 | 431 | | _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); |
| | 432 | | } |
| 0 | 433 | | if (maxResults != null) |
| | 434 | | { |
| 0 | 435 | | _queryParameters.Add(string.Format("maxresults={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali |
| | 436 | | } |
| 0 | 437 | | if (timeout != null) |
| | 438 | | { |
| 0 | 439 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 440 | | } |
| 0 | 441 | | if (_queryParameters.Count > 0) |
| | 442 | | { |
| 0 | 443 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 444 | | } |
| | 445 | | // Create HTTP transport objects |
| 0 | 446 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 447 | | HttpResponseMessage _httpResponse = null; |
| 0 | 448 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 449 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 450 | | // Set Headers |
| 0 | 451 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 452 | | { |
| 0 | 453 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 454 | | } |
| 0 | 455 | | if (Client.AcceptLanguage != null) |
| | 456 | | { |
| 0 | 457 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 458 | | { |
| 0 | 459 | | _httpRequest.Headers.Remove("accept-language"); |
| | 460 | | } |
| 0 | 461 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 462 | | } |
| 0 | 463 | | if (clientRequestId != null) |
| | 464 | | { |
| 0 | 465 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 466 | | { |
| 0 | 467 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 468 | | } |
| 0 | 469 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 470 | | } |
| 0 | 471 | | if (returnClientRequestId != null) |
| | 472 | | { |
| 0 | 473 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 474 | | { |
| 0 | 475 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 476 | | } |
| 0 | 477 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 478 | | } |
| 0 | 479 | | if (ocpDate != null) |
| | 480 | | { |
| 0 | 481 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 482 | | { |
| 0 | 483 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 484 | | } |
| 0 | 485 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 486 | | } |
| | 487 | |
|
| | 488 | |
|
| 0 | 489 | | if (customHeaders != null) |
| | 490 | | { |
| 0 | 491 | | foreach(var _header in customHeaders) |
| | 492 | | { |
| 0 | 493 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 494 | | { |
| 0 | 495 | | _httpRequest.Headers.Remove(_header.Key); |
| | 496 | | } |
| 0 | 497 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 498 | | } |
| | 499 | | } |
| | 500 | |
|
| | 501 | | // Serialize Request |
| 0 | 502 | | string _requestContent = null; |
| | 503 | | // Set Credentials |
| 0 | 504 | | if (Client.Credentials != null) |
| | 505 | | { |
| 0 | 506 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 507 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 508 | | } |
| | 509 | | // Send Request |
| 0 | 510 | | if (_shouldTrace) |
| | 511 | | { |
| 0 | 512 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 513 | | } |
| 0 | 514 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 515 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 516 | | if (_shouldTrace) |
| | 517 | | { |
| 0 | 518 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 519 | | } |
| 0 | 520 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 521 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 522 | | string _responseContent = null; |
| 0 | 523 | | if ((int)_statusCode != 200) |
| | 524 | | { |
| 0 | 525 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 526 | | try |
| | 527 | | { |
| 0 | 528 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 529 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 530 | | if (_errorBody != null) |
| | 531 | | { |
| 0 | 532 | | ex.Body = _errorBody; |
| | 533 | | } |
| 0 | 534 | | } |
| 0 | 535 | | catch (JsonException) |
| | 536 | | { |
| | 537 | | // Ignore the exception |
| 0 | 538 | | } |
| 0 | 539 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 540 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 541 | | if (_shouldTrace) |
| | 542 | | { |
| 0 | 543 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 544 | | } |
| 0 | 545 | | _httpRequest.Dispose(); |
| 0 | 546 | | if (_httpResponse != null) |
| | 547 | | { |
| 0 | 548 | | _httpResponse.Dispose(); |
| | 549 | | } |
| 0 | 550 | | throw ex; |
| | 551 | | } |
| | 552 | | // Create Result |
| 0 | 553 | | var _result = new AzureOperationResponse<IPage<CloudTask>,TaskListHeaders>(); |
| 0 | 554 | | _result.Request = _httpRequest; |
| 0 | 555 | | _result.Response = _httpResponse; |
| 0 | 556 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 557 | | { |
| 0 | 558 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 559 | | } |
| | 560 | | // Deserialize Response |
| 0 | 561 | | if ((int)_statusCode == 200) |
| | 562 | | { |
| 0 | 563 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 564 | | try |
| | 565 | | { |
| 0 | 566 | | _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudTask>>(_responseContent, Client.Deseriali |
| 0 | 567 | | } |
| 0 | 568 | | catch (JsonException ex) |
| | 569 | | { |
| 0 | 570 | | _httpRequest.Dispose(); |
| 0 | 571 | | if (_httpResponse != null) |
| | 572 | | { |
| 0 | 573 | | _httpResponse.Dispose(); |
| | 574 | | } |
| 0 | 575 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 576 | | } |
| | 577 | | } |
| | 578 | | try |
| | 579 | | { |
| 0 | 580 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskListHeaders>(JsonSerializer.Create(Clien |
| 0 | 581 | | } |
| 0 | 582 | | catch (JsonException ex) |
| | 583 | | { |
| 0 | 584 | | _httpRequest.Dispose(); |
| 0 | 585 | | if (_httpResponse != null) |
| | 586 | | { |
| 0 | 587 | | _httpResponse.Dispose(); |
| | 588 | | } |
| 0 | 589 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 590 | | } |
| 0 | 591 | | if (_shouldTrace) |
| | 592 | | { |
| 0 | 593 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 594 | | } |
| 0 | 595 | | return _result; |
| 0 | 596 | | } |
| | 597 | |
|
| | 598 | | /// <summary> |
| | 599 | | /// Adds a collection of Tasks to the specified Job. |
| | 600 | | /// </summary> |
| | 601 | | /// <remarks> |
| | 602 | | /// Note that each Task must have a unique ID. The Batch service may not return |
| | 603 | | /// the results for each Task in the same order the Tasks were submitted in |
| | 604 | | /// this request. If the server times out or the connection is closed during |
| | 605 | | /// the request, the request may have been partially or fully processed, or not |
| | 606 | | /// at all. In such cases, the user should re-issue the request. Note that it |
| | 607 | | /// is up to the user to correctly handle failures when re-issuing a request. |
| | 608 | | /// For example, you should use the same Task IDs during a retry so that if the |
| | 609 | | /// prior operation succeeded, the retry will not create extra Tasks |
| | 610 | | /// unexpectedly. If the response contains any Tasks which failed to add, a |
| | 611 | | /// client can retry the request. In a retry, it is most efficient to resubmit |
| | 612 | | /// only Tasks that failed to add, and to omit Tasks that were successfully |
| | 613 | | /// added on the first attempt. The maximum lifetime of a Task from addition to |
| | 614 | | /// completion is 180 days. If a Task has not completed within 180 days of |
| | 615 | | /// being added it will be terminated by the Batch service and left in whatever |
| | 616 | | /// state it was in at that time. |
| | 617 | | /// </remarks> |
| | 618 | | /// <param name='jobId'> |
| | 619 | | /// The ID of the Job to which the Task collection is to be added. |
| | 620 | | /// </param> |
| | 621 | | /// <param name='value'> |
| | 622 | | /// The collection of Tasks to add. The maximum count of Tasks is 100. The |
| | 623 | | /// total serialized size of this collection must be less than 1MB. If it is |
| | 624 | | /// greater than 1MB (for example if each Task has 100's of resource files or |
| | 625 | | /// environment variables), the request will fail with code |
| | 626 | | /// 'RequestBodyTooLarge' and should be retried again with fewer Tasks. |
| | 627 | | /// </param> |
| | 628 | | /// <param name='taskAddCollectionOptions'> |
| | 629 | | /// Additional parameters for the operation |
| | 630 | | /// </param> |
| | 631 | | /// <param name='customHeaders'> |
| | 632 | | /// Headers that will be added to request. |
| | 633 | | /// </param> |
| | 634 | | /// <param name='cancellationToken'> |
| | 635 | | /// The cancellation token. |
| | 636 | | /// </param> |
| | 637 | | /// <exception cref="BatchErrorException"> |
| | 638 | | /// Thrown when the operation returned an invalid status code |
| | 639 | | /// </exception> |
| | 640 | | /// <exception cref="SerializationException"> |
| | 641 | | /// Thrown when unable to deserialize the response |
| | 642 | | /// </exception> |
| | 643 | | /// <exception cref="ValidationException"> |
| | 644 | | /// Thrown when a required parameter is null |
| | 645 | | /// </exception> |
| | 646 | | /// <exception cref="System.ArgumentNullException"> |
| | 647 | | /// Thrown when a required parameter is null |
| | 648 | | /// </exception> |
| | 649 | | /// <return> |
| | 650 | | /// A response object containing the response body and response headers. |
| | 651 | | /// </return> |
| | 652 | | public async Task<AzureOperationResponse<TaskAddCollectionResult,TaskAddCollectionHeaders>> AddCollectionWithHtt |
| | 653 | | { |
| 0 | 654 | | if (Client.BatchUrl == null) |
| | 655 | | { |
| 0 | 656 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 657 | | } |
| 0 | 658 | | if (jobId == null) |
| | 659 | | { |
| 0 | 660 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 661 | | } |
| 0 | 662 | | if (Client.ApiVersion == null) |
| | 663 | | { |
| 0 | 664 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 665 | | } |
| 0 | 666 | | if (value == null) |
| | 667 | | { |
| 0 | 668 | | throw new ValidationException(ValidationRules.CannotBeNull, "value"); |
| | 669 | | } |
| 0 | 670 | | int? timeout = default(int?); |
| 0 | 671 | | if (taskAddCollectionOptions != null) |
| | 672 | | { |
| 0 | 673 | | timeout = taskAddCollectionOptions.Timeout; |
| | 674 | | } |
| 0 | 675 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 676 | | if (taskAddCollectionOptions != null) |
| | 677 | | { |
| 0 | 678 | | clientRequestId = taskAddCollectionOptions.ClientRequestId; |
| | 679 | | } |
| 0 | 680 | | bool? returnClientRequestId = default(bool?); |
| 0 | 681 | | if (taskAddCollectionOptions != null) |
| | 682 | | { |
| 0 | 683 | | returnClientRequestId = taskAddCollectionOptions.ReturnClientRequestId; |
| | 684 | | } |
| 0 | 685 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 686 | | if (taskAddCollectionOptions != null) |
| | 687 | | { |
| 0 | 688 | | ocpDate = taskAddCollectionOptions.OcpDate; |
| | 689 | | } |
| 0 | 690 | | TaskAddCollectionParameter taskCollection = new TaskAddCollectionParameter(); |
| 0 | 691 | | if (value != null) |
| | 692 | | { |
| 0 | 693 | | taskCollection.Value = value; |
| | 694 | | } |
| | 695 | | // Tracing |
| 0 | 696 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 697 | | string _invocationId = null; |
| 0 | 698 | | if (_shouldTrace) |
| | 699 | | { |
| 0 | 700 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 701 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 702 | | tracingParameters.Add("jobId", jobId); |
| 0 | 703 | | tracingParameters.Add("timeout", timeout); |
| 0 | 704 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 705 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 706 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 707 | | tracingParameters.Add("taskCollection", taskCollection); |
| 0 | 708 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 709 | | ServiceClientTracing.Enter(_invocationId, this, "AddCollection", tracingParameters); |
| | 710 | | } |
| | 711 | | // Construct URL |
| 0 | 712 | | var _baseUrl = Client.BaseUri; |
| 0 | 713 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/addtaskcollection"; |
| 0 | 714 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 715 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 716 | | List<string> _queryParameters = new List<string>(); |
| 0 | 717 | | if (Client.ApiVersion != null) |
| | 718 | | { |
| 0 | 719 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 720 | | } |
| 0 | 721 | | if (timeout != null) |
| | 722 | | { |
| 0 | 723 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 724 | | } |
| 0 | 725 | | if (_queryParameters.Count > 0) |
| | 726 | | { |
| 0 | 727 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 728 | | } |
| | 729 | | // Create HTTP transport objects |
| 0 | 730 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 731 | | HttpResponseMessage _httpResponse = null; |
| 0 | 732 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 733 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 734 | | // Set Headers |
| 0 | 735 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 736 | | { |
| 0 | 737 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 738 | | } |
| 0 | 739 | | if (Client.AcceptLanguage != null) |
| | 740 | | { |
| 0 | 741 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 742 | | { |
| 0 | 743 | | _httpRequest.Headers.Remove("accept-language"); |
| | 744 | | } |
| 0 | 745 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 746 | | } |
| 0 | 747 | | if (clientRequestId != null) |
| | 748 | | { |
| 0 | 749 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 750 | | { |
| 0 | 751 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 752 | | } |
| 0 | 753 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 754 | | } |
| 0 | 755 | | if (returnClientRequestId != null) |
| | 756 | | { |
| 0 | 757 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 758 | | { |
| 0 | 759 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 760 | | } |
| 0 | 761 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 762 | | } |
| 0 | 763 | | if (ocpDate != null) |
| | 764 | | { |
| 0 | 765 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 766 | | { |
| 0 | 767 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 768 | | } |
| 0 | 769 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 770 | | } |
| | 771 | |
|
| | 772 | |
|
| 0 | 773 | | if (customHeaders != null) |
| | 774 | | { |
| 0 | 775 | | foreach(var _header in customHeaders) |
| | 776 | | { |
| 0 | 777 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 778 | | { |
| 0 | 779 | | _httpRequest.Headers.Remove(_header.Key); |
| | 780 | | } |
| 0 | 781 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 782 | | } |
| | 783 | | } |
| | 784 | |
|
| | 785 | | // Serialize Request |
| 0 | 786 | | string _requestContent = null; |
| 0 | 787 | | if(taskCollection != null) |
| | 788 | | { |
| 0 | 789 | | _requestContent = SafeJsonConvert.SerializeObject(taskCollection, Client.SerializationSettings); |
| 0 | 790 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 791 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 792 | | } |
| | 793 | | // Set Credentials |
| 0 | 794 | | if (Client.Credentials != null) |
| | 795 | | { |
| 0 | 796 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 797 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 798 | | } |
| | 799 | | // Send Request |
| 0 | 800 | | if (_shouldTrace) |
| | 801 | | { |
| 0 | 802 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 803 | | } |
| 0 | 804 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 805 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 806 | | if (_shouldTrace) |
| | 807 | | { |
| 0 | 808 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 809 | | } |
| 0 | 810 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 811 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 812 | | string _responseContent = null; |
| 0 | 813 | | if ((int)_statusCode != 200) |
| | 814 | | { |
| 0 | 815 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 816 | | try |
| | 817 | | { |
| 0 | 818 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 819 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 820 | | if (_errorBody != null) |
| | 821 | | { |
| 0 | 822 | | ex.Body = _errorBody; |
| | 823 | | } |
| 0 | 824 | | } |
| 0 | 825 | | catch (JsonException) |
| | 826 | | { |
| | 827 | | // Ignore the exception |
| 0 | 828 | | } |
| 0 | 829 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 830 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 831 | | if (_shouldTrace) |
| | 832 | | { |
| 0 | 833 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 834 | | } |
| 0 | 835 | | _httpRequest.Dispose(); |
| 0 | 836 | | if (_httpResponse != null) |
| | 837 | | { |
| 0 | 838 | | _httpResponse.Dispose(); |
| | 839 | | } |
| 0 | 840 | | throw ex; |
| | 841 | | } |
| | 842 | | // Create Result |
| 0 | 843 | | var _result = new AzureOperationResponse<TaskAddCollectionResult,TaskAddCollectionHeaders>(); |
| 0 | 844 | | _result.Request = _httpRequest; |
| 0 | 845 | | _result.Response = _httpResponse; |
| 0 | 846 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 847 | | { |
| 0 | 848 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 849 | | } |
| | 850 | | // Deserialize Response |
| 0 | 851 | | if ((int)_statusCode == 200) |
| | 852 | | { |
| 0 | 853 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 854 | | try |
| | 855 | | { |
| 0 | 856 | | _result.Body = SafeJsonConvert.DeserializeObject<TaskAddCollectionResult>(_responseContent, Client.D |
| 0 | 857 | | } |
| 0 | 858 | | catch (JsonException ex) |
| | 859 | | { |
| 0 | 860 | | _httpRequest.Dispose(); |
| 0 | 861 | | if (_httpResponse != null) |
| | 862 | | { |
| 0 | 863 | | _httpResponse.Dispose(); |
| | 864 | | } |
| 0 | 865 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 866 | | } |
| | 867 | | } |
| | 868 | | try |
| | 869 | | { |
| 0 | 870 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskAddCollectionHeaders>(JsonSerializer.Cre |
| 0 | 871 | | } |
| 0 | 872 | | catch (JsonException ex) |
| | 873 | | { |
| 0 | 874 | | _httpRequest.Dispose(); |
| 0 | 875 | | if (_httpResponse != null) |
| | 876 | | { |
| 0 | 877 | | _httpResponse.Dispose(); |
| | 878 | | } |
| 0 | 879 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 880 | | } |
| 0 | 881 | | if (_shouldTrace) |
| | 882 | | { |
| 0 | 883 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 884 | | } |
| 0 | 885 | | return _result; |
| 0 | 886 | | } |
| | 887 | |
|
| | 888 | | /// <summary> |
| | 889 | | /// Deletes a Task from the specified Job. |
| | 890 | | /// </summary> |
| | 891 | | /// <remarks> |
| | 892 | | /// When a Task is deleted, all of the files in its directory on the Compute |
| | 893 | | /// Node where it ran are also deleted (regardless of the retention time). For |
| | 894 | | /// multi-instance Tasks, the delete Task operation applies synchronously to |
| | 895 | | /// the primary task; subtasks and their files are then deleted asynchronously |
| | 896 | | /// in the background. |
| | 897 | | /// </remarks> |
| | 898 | | /// <param name='jobId'> |
| | 899 | | /// The ID of the Job from which to delete the Task. |
| | 900 | | /// </param> |
| | 901 | | /// <param name='taskId'> |
| | 902 | | /// The ID of the Task to delete. |
| | 903 | | /// </param> |
| | 904 | | /// <param name='taskDeleteOptions'> |
| | 905 | | /// Additional parameters for the operation |
| | 906 | | /// </param> |
| | 907 | | /// <param name='customHeaders'> |
| | 908 | | /// Headers that will be added to request. |
| | 909 | | /// </param> |
| | 910 | | /// <param name='cancellationToken'> |
| | 911 | | /// The cancellation token. |
| | 912 | | /// </param> |
| | 913 | | /// <exception cref="BatchErrorException"> |
| | 914 | | /// Thrown when the operation returned an invalid status code |
| | 915 | | /// </exception> |
| | 916 | | /// <exception cref="ValidationException"> |
| | 917 | | /// Thrown when a required parameter is null |
| | 918 | | /// </exception> |
| | 919 | | /// <exception cref="System.ArgumentNullException"> |
| | 920 | | /// Thrown when a required parameter is null |
| | 921 | | /// </exception> |
| | 922 | | /// <return> |
| | 923 | | /// A response object containing the response body and response headers. |
| | 924 | | /// </return> |
| | 925 | | public async Task<AzureOperationHeaderResponse<TaskDeleteHeaders>> DeleteWithHttpMessagesAsync(string jobId, str |
| | 926 | | { |
| 0 | 927 | | if (Client.BatchUrl == null) |
| | 928 | | { |
| 0 | 929 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 930 | | } |
| 0 | 931 | | if (jobId == null) |
| | 932 | | { |
| 0 | 933 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 934 | | } |
| 0 | 935 | | if (taskId == null) |
| | 936 | | { |
| 0 | 937 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 938 | | } |
| 0 | 939 | | if (Client.ApiVersion == null) |
| | 940 | | { |
| 0 | 941 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 942 | | } |
| 0 | 943 | | int? timeout = default(int?); |
| 0 | 944 | | if (taskDeleteOptions != null) |
| | 945 | | { |
| 0 | 946 | | timeout = taskDeleteOptions.Timeout; |
| | 947 | | } |
| 0 | 948 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 949 | | if (taskDeleteOptions != null) |
| | 950 | | { |
| 0 | 951 | | clientRequestId = taskDeleteOptions.ClientRequestId; |
| | 952 | | } |
| 0 | 953 | | bool? returnClientRequestId = default(bool?); |
| 0 | 954 | | if (taskDeleteOptions != null) |
| | 955 | | { |
| 0 | 956 | | returnClientRequestId = taskDeleteOptions.ReturnClientRequestId; |
| | 957 | | } |
| 0 | 958 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 959 | | if (taskDeleteOptions != null) |
| | 960 | | { |
| 0 | 961 | | ocpDate = taskDeleteOptions.OcpDate; |
| | 962 | | } |
| 0 | 963 | | string ifMatch = default(string); |
| 0 | 964 | | if (taskDeleteOptions != null) |
| | 965 | | { |
| 0 | 966 | | ifMatch = taskDeleteOptions.IfMatch; |
| | 967 | | } |
| 0 | 968 | | string ifNoneMatch = default(string); |
| 0 | 969 | | if (taskDeleteOptions != null) |
| | 970 | | { |
| 0 | 971 | | ifNoneMatch = taskDeleteOptions.IfNoneMatch; |
| | 972 | | } |
| 0 | 973 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 974 | | if (taskDeleteOptions != null) |
| | 975 | | { |
| 0 | 976 | | ifModifiedSince = taskDeleteOptions.IfModifiedSince; |
| | 977 | | } |
| 0 | 978 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 979 | | if (taskDeleteOptions != null) |
| | 980 | | { |
| 0 | 981 | | ifUnmodifiedSince = taskDeleteOptions.IfUnmodifiedSince; |
| | 982 | | } |
| | 983 | | // Tracing |
| 0 | 984 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 985 | | string _invocationId = null; |
| 0 | 986 | | if (_shouldTrace) |
| | 987 | | { |
| 0 | 988 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 989 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 990 | | tracingParameters.Add("jobId", jobId); |
| 0 | 991 | | tracingParameters.Add("taskId", taskId); |
| 0 | 992 | | tracingParameters.Add("timeout", timeout); |
| 0 | 993 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 994 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 995 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 996 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 997 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 998 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 999 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1000 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1001 | | ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); |
| | 1002 | | } |
| | 1003 | | // Construct URL |
| 0 | 1004 | | var _baseUrl = Client.BaseUri; |
| 0 | 1005 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}"; |
| 0 | 1006 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1007 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 1008 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 1009 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1010 | | if (Client.ApiVersion != null) |
| | 1011 | | { |
| 0 | 1012 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1013 | | } |
| 0 | 1014 | | if (timeout != null) |
| | 1015 | | { |
| 0 | 1016 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1017 | | } |
| 0 | 1018 | | if (_queryParameters.Count > 0) |
| | 1019 | | { |
| 0 | 1020 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1021 | | } |
| | 1022 | | // Create HTTP transport objects |
| 0 | 1023 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1024 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1025 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 1026 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1027 | | // Set Headers |
| 0 | 1028 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1029 | | { |
| 0 | 1030 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1031 | | } |
| 0 | 1032 | | if (Client.AcceptLanguage != null) |
| | 1033 | | { |
| 0 | 1034 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1035 | | { |
| 0 | 1036 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1037 | | } |
| 0 | 1038 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1039 | | } |
| 0 | 1040 | | if (clientRequestId != null) |
| | 1041 | | { |
| 0 | 1042 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1043 | | { |
| 0 | 1044 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1045 | | } |
| 0 | 1046 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1047 | | } |
| 0 | 1048 | | if (returnClientRequestId != null) |
| | 1049 | | { |
| 0 | 1050 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1051 | | { |
| 0 | 1052 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1053 | | } |
| 0 | 1054 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1055 | | } |
| 0 | 1056 | | if (ocpDate != null) |
| | 1057 | | { |
| 0 | 1058 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1059 | | { |
| 0 | 1060 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1061 | | } |
| 0 | 1062 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1063 | | } |
| 0 | 1064 | | if (ifMatch != null) |
| | 1065 | | { |
| 0 | 1066 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1067 | | { |
| 0 | 1068 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1069 | | } |
| 0 | 1070 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1071 | | } |
| 0 | 1072 | | if (ifNoneMatch != null) |
| | 1073 | | { |
| 0 | 1074 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1075 | | { |
| 0 | 1076 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1077 | | } |
| 0 | 1078 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1079 | | } |
| 0 | 1080 | | if (ifModifiedSince != null) |
| | 1081 | | { |
| 0 | 1082 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1083 | | { |
| 0 | 1084 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1085 | | } |
| 0 | 1086 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1087 | | } |
| 0 | 1088 | | if (ifUnmodifiedSince != null) |
| | 1089 | | { |
| 0 | 1090 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1091 | | { |
| 0 | 1092 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1093 | | } |
| 0 | 1094 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1095 | | } |
| | 1096 | |
|
| | 1097 | |
|
| 0 | 1098 | | if (customHeaders != null) |
| | 1099 | | { |
| 0 | 1100 | | foreach(var _header in customHeaders) |
| | 1101 | | { |
| 0 | 1102 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1103 | | { |
| 0 | 1104 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1105 | | } |
| 0 | 1106 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1107 | | } |
| | 1108 | | } |
| | 1109 | |
|
| | 1110 | | // Serialize Request |
| 0 | 1111 | | string _requestContent = null; |
| | 1112 | | // Set Credentials |
| 0 | 1113 | | if (Client.Credentials != null) |
| | 1114 | | { |
| 0 | 1115 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1116 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1117 | | } |
| | 1118 | | // Send Request |
| 0 | 1119 | | if (_shouldTrace) |
| | 1120 | | { |
| 0 | 1121 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1122 | | } |
| 0 | 1123 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1124 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1125 | | if (_shouldTrace) |
| | 1126 | | { |
| 0 | 1127 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1128 | | } |
| 0 | 1129 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1130 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1131 | | string _responseContent = null; |
| 0 | 1132 | | if ((int)_statusCode != 200) |
| | 1133 | | { |
| 0 | 1134 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1135 | | try |
| | 1136 | | { |
| 0 | 1137 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1138 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1139 | | if (_errorBody != null) |
| | 1140 | | { |
| 0 | 1141 | | ex.Body = _errorBody; |
| | 1142 | | } |
| 0 | 1143 | | } |
| 0 | 1144 | | catch (JsonException) |
| | 1145 | | { |
| | 1146 | | // Ignore the exception |
| 0 | 1147 | | } |
| 0 | 1148 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1149 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1150 | | if (_shouldTrace) |
| | 1151 | | { |
| 0 | 1152 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1153 | | } |
| 0 | 1154 | | _httpRequest.Dispose(); |
| 0 | 1155 | | if (_httpResponse != null) |
| | 1156 | | { |
| 0 | 1157 | | _httpResponse.Dispose(); |
| | 1158 | | } |
| 0 | 1159 | | throw ex; |
| | 1160 | | } |
| | 1161 | | // Create Result |
| 0 | 1162 | | var _result = new AzureOperationHeaderResponse<TaskDeleteHeaders>(); |
| 0 | 1163 | | _result.Request = _httpRequest; |
| 0 | 1164 | | _result.Response = _httpResponse; |
| 0 | 1165 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1166 | | { |
| 0 | 1167 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1168 | | } |
| | 1169 | | try |
| | 1170 | | { |
| 0 | 1171 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskDeleteHeaders>(JsonSerializer.Create(Cli |
| 0 | 1172 | | } |
| 0 | 1173 | | catch (JsonException ex) |
| | 1174 | | { |
| 0 | 1175 | | _httpRequest.Dispose(); |
| 0 | 1176 | | if (_httpResponse != null) |
| | 1177 | | { |
| 0 | 1178 | | _httpResponse.Dispose(); |
| | 1179 | | } |
| 0 | 1180 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1181 | | } |
| 0 | 1182 | | if (_shouldTrace) |
| | 1183 | | { |
| 0 | 1184 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1185 | | } |
| 0 | 1186 | | return _result; |
| 0 | 1187 | | } |
| | 1188 | |
|
| | 1189 | | /// <summary> |
| | 1190 | | /// Gets information about the specified Task. |
| | 1191 | | /// </summary> |
| | 1192 | | /// <remarks> |
| | 1193 | | /// For multi-instance Tasks, information such as affinityId, executionInfo and |
| | 1194 | | /// nodeInfo refer to the primary Task. Use the list subtasks API to retrieve |
| | 1195 | | /// information about subtasks. |
| | 1196 | | /// </remarks> |
| | 1197 | | /// <param name='jobId'> |
| | 1198 | | /// The ID of the Job that contains the Task. |
| | 1199 | | /// </param> |
| | 1200 | | /// <param name='taskId'> |
| | 1201 | | /// The ID of the Task to get information about. |
| | 1202 | | /// </param> |
| | 1203 | | /// <param name='taskGetOptions'> |
| | 1204 | | /// Additional parameters for the operation |
| | 1205 | | /// </param> |
| | 1206 | | /// <param name='customHeaders'> |
| | 1207 | | /// Headers that will be added to request. |
| | 1208 | | /// </param> |
| | 1209 | | /// <param name='cancellationToken'> |
| | 1210 | | /// The cancellation token. |
| | 1211 | | /// </param> |
| | 1212 | | /// <exception cref="BatchErrorException"> |
| | 1213 | | /// Thrown when the operation returned an invalid status code |
| | 1214 | | /// </exception> |
| | 1215 | | /// <exception cref="SerializationException"> |
| | 1216 | | /// Thrown when unable to deserialize the response |
| | 1217 | | /// </exception> |
| | 1218 | | /// <exception cref="ValidationException"> |
| | 1219 | | /// Thrown when a required parameter is null |
| | 1220 | | /// </exception> |
| | 1221 | | /// <exception cref="System.ArgumentNullException"> |
| | 1222 | | /// Thrown when a required parameter is null |
| | 1223 | | /// </exception> |
| | 1224 | | /// <return> |
| | 1225 | | /// A response object containing the response body and response headers. |
| | 1226 | | /// </return> |
| | 1227 | | public async Task<AzureOperationResponse<CloudTask,TaskGetHeaders>> GetWithHttpMessagesAsync(string jobId, strin |
| | 1228 | | { |
| 0 | 1229 | | if (Client.BatchUrl == null) |
| | 1230 | | { |
| 0 | 1231 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1232 | | } |
| 0 | 1233 | | if (jobId == null) |
| | 1234 | | { |
| 0 | 1235 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 1236 | | } |
| 0 | 1237 | | if (taskId == null) |
| | 1238 | | { |
| 0 | 1239 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 1240 | | } |
| 0 | 1241 | | if (Client.ApiVersion == null) |
| | 1242 | | { |
| 0 | 1243 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1244 | | } |
| 0 | 1245 | | string select = default(string); |
| 0 | 1246 | | if (taskGetOptions != null) |
| | 1247 | | { |
| 0 | 1248 | | select = taskGetOptions.Select; |
| | 1249 | | } |
| 0 | 1250 | | string expand = default(string); |
| 0 | 1251 | | if (taskGetOptions != null) |
| | 1252 | | { |
| 0 | 1253 | | expand = taskGetOptions.Expand; |
| | 1254 | | } |
| 0 | 1255 | | int? timeout = default(int?); |
| 0 | 1256 | | if (taskGetOptions != null) |
| | 1257 | | { |
| 0 | 1258 | | timeout = taskGetOptions.Timeout; |
| | 1259 | | } |
| 0 | 1260 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1261 | | if (taskGetOptions != null) |
| | 1262 | | { |
| 0 | 1263 | | clientRequestId = taskGetOptions.ClientRequestId; |
| | 1264 | | } |
| 0 | 1265 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1266 | | if (taskGetOptions != null) |
| | 1267 | | { |
| 0 | 1268 | | returnClientRequestId = taskGetOptions.ReturnClientRequestId; |
| | 1269 | | } |
| 0 | 1270 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1271 | | if (taskGetOptions != null) |
| | 1272 | | { |
| 0 | 1273 | | ocpDate = taskGetOptions.OcpDate; |
| | 1274 | | } |
| 0 | 1275 | | string ifMatch = default(string); |
| 0 | 1276 | | if (taskGetOptions != null) |
| | 1277 | | { |
| 0 | 1278 | | ifMatch = taskGetOptions.IfMatch; |
| | 1279 | | } |
| 0 | 1280 | | string ifNoneMatch = default(string); |
| 0 | 1281 | | if (taskGetOptions != null) |
| | 1282 | | { |
| 0 | 1283 | | ifNoneMatch = taskGetOptions.IfNoneMatch; |
| | 1284 | | } |
| 0 | 1285 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1286 | | if (taskGetOptions != null) |
| | 1287 | | { |
| 0 | 1288 | | ifModifiedSince = taskGetOptions.IfModifiedSince; |
| | 1289 | | } |
| 0 | 1290 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1291 | | if (taskGetOptions != null) |
| | 1292 | | { |
| 0 | 1293 | | ifUnmodifiedSince = taskGetOptions.IfUnmodifiedSince; |
| | 1294 | | } |
| | 1295 | | // Tracing |
| 0 | 1296 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1297 | | string _invocationId = null; |
| 0 | 1298 | | if (_shouldTrace) |
| | 1299 | | { |
| 0 | 1300 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1301 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1302 | | tracingParameters.Add("jobId", jobId); |
| 0 | 1303 | | tracingParameters.Add("taskId", taskId); |
| 0 | 1304 | | tracingParameters.Add("select", select); |
| 0 | 1305 | | tracingParameters.Add("expand", expand); |
| 0 | 1306 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1307 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1308 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1309 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1310 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1311 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1312 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1313 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1314 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1315 | | ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); |
| | 1316 | | } |
| | 1317 | | // Construct URL |
| 0 | 1318 | | var _baseUrl = Client.BaseUri; |
| 0 | 1319 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}"; |
| 0 | 1320 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1321 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 1322 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 1323 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1324 | | if (Client.ApiVersion != null) |
| | 1325 | | { |
| 0 | 1326 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1327 | | } |
| 0 | 1328 | | if (select != null) |
| | 1329 | | { |
| 0 | 1330 | | _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); |
| | 1331 | | } |
| 0 | 1332 | | if (expand != null) |
| | 1333 | | { |
| 0 | 1334 | | _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); |
| | 1335 | | } |
| 0 | 1336 | | if (timeout != null) |
| | 1337 | | { |
| 0 | 1338 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1339 | | } |
| 0 | 1340 | | if (_queryParameters.Count > 0) |
| | 1341 | | { |
| 0 | 1342 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1343 | | } |
| | 1344 | | // Create HTTP transport objects |
| 0 | 1345 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1346 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1347 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 1348 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1349 | | // Set Headers |
| 0 | 1350 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1351 | | { |
| 0 | 1352 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1353 | | } |
| 0 | 1354 | | if (Client.AcceptLanguage != null) |
| | 1355 | | { |
| 0 | 1356 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1357 | | { |
| 0 | 1358 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1359 | | } |
| 0 | 1360 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1361 | | } |
| 0 | 1362 | | if (clientRequestId != null) |
| | 1363 | | { |
| 0 | 1364 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1365 | | { |
| 0 | 1366 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1367 | | } |
| 0 | 1368 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1369 | | } |
| 0 | 1370 | | if (returnClientRequestId != null) |
| | 1371 | | { |
| 0 | 1372 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1373 | | { |
| 0 | 1374 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1375 | | } |
| 0 | 1376 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1377 | | } |
| 0 | 1378 | | if (ocpDate != null) |
| | 1379 | | { |
| 0 | 1380 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1381 | | { |
| 0 | 1382 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1383 | | } |
| 0 | 1384 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1385 | | } |
| 0 | 1386 | | if (ifMatch != null) |
| | 1387 | | { |
| 0 | 1388 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1389 | | { |
| 0 | 1390 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1391 | | } |
| 0 | 1392 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1393 | | } |
| 0 | 1394 | | if (ifNoneMatch != null) |
| | 1395 | | { |
| 0 | 1396 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1397 | | { |
| 0 | 1398 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1399 | | } |
| 0 | 1400 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1401 | | } |
| 0 | 1402 | | if (ifModifiedSince != null) |
| | 1403 | | { |
| 0 | 1404 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1405 | | { |
| 0 | 1406 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1407 | | } |
| 0 | 1408 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1409 | | } |
| 0 | 1410 | | if (ifUnmodifiedSince != null) |
| | 1411 | | { |
| 0 | 1412 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1413 | | { |
| 0 | 1414 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1415 | | } |
| 0 | 1416 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1417 | | } |
| | 1418 | |
|
| | 1419 | |
|
| 0 | 1420 | | if (customHeaders != null) |
| | 1421 | | { |
| 0 | 1422 | | foreach(var _header in customHeaders) |
| | 1423 | | { |
| 0 | 1424 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1425 | | { |
| 0 | 1426 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1427 | | } |
| 0 | 1428 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1429 | | } |
| | 1430 | | } |
| | 1431 | |
|
| | 1432 | | // Serialize Request |
| 0 | 1433 | | string _requestContent = null; |
| | 1434 | | // Set Credentials |
| 0 | 1435 | | if (Client.Credentials != null) |
| | 1436 | | { |
| 0 | 1437 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1438 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1439 | | } |
| | 1440 | | // Send Request |
| 0 | 1441 | | if (_shouldTrace) |
| | 1442 | | { |
| 0 | 1443 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1444 | | } |
| 0 | 1445 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1446 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1447 | | if (_shouldTrace) |
| | 1448 | | { |
| 0 | 1449 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1450 | | } |
| 0 | 1451 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1452 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1453 | | string _responseContent = null; |
| 0 | 1454 | | if ((int)_statusCode != 200) |
| | 1455 | | { |
| 0 | 1456 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1457 | | try |
| | 1458 | | { |
| 0 | 1459 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1460 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1461 | | if (_errorBody != null) |
| | 1462 | | { |
| 0 | 1463 | | ex.Body = _errorBody; |
| | 1464 | | } |
| 0 | 1465 | | } |
| 0 | 1466 | | catch (JsonException) |
| | 1467 | | { |
| | 1468 | | // Ignore the exception |
| 0 | 1469 | | } |
| 0 | 1470 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1471 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1472 | | if (_shouldTrace) |
| | 1473 | | { |
| 0 | 1474 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1475 | | } |
| 0 | 1476 | | _httpRequest.Dispose(); |
| 0 | 1477 | | if (_httpResponse != null) |
| | 1478 | | { |
| 0 | 1479 | | _httpResponse.Dispose(); |
| | 1480 | | } |
| 0 | 1481 | | throw ex; |
| | 1482 | | } |
| | 1483 | | // Create Result |
| 0 | 1484 | | var _result = new AzureOperationResponse<CloudTask,TaskGetHeaders>(); |
| 0 | 1485 | | _result.Request = _httpRequest; |
| 0 | 1486 | | _result.Response = _httpResponse; |
| 0 | 1487 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1488 | | { |
| 0 | 1489 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1490 | | } |
| | 1491 | | // Deserialize Response |
| 0 | 1492 | | if ((int)_statusCode == 200) |
| | 1493 | | { |
| 0 | 1494 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1495 | | try |
| | 1496 | | { |
| 0 | 1497 | | _result.Body = SafeJsonConvert.DeserializeObject<CloudTask>(_responseContent, Client.Deserialization |
| 0 | 1498 | | } |
| 0 | 1499 | | catch (JsonException ex) |
| | 1500 | | { |
| 0 | 1501 | | _httpRequest.Dispose(); |
| 0 | 1502 | | if (_httpResponse != null) |
| | 1503 | | { |
| 0 | 1504 | | _httpResponse.Dispose(); |
| | 1505 | | } |
| 0 | 1506 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1507 | | } |
| | 1508 | | } |
| | 1509 | | try |
| | 1510 | | { |
| 0 | 1511 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskGetHeaders>(JsonSerializer.Create(Client |
| 0 | 1512 | | } |
| 0 | 1513 | | catch (JsonException ex) |
| | 1514 | | { |
| 0 | 1515 | | _httpRequest.Dispose(); |
| 0 | 1516 | | if (_httpResponse != null) |
| | 1517 | | { |
| 0 | 1518 | | _httpResponse.Dispose(); |
| | 1519 | | } |
| 0 | 1520 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1521 | | } |
| 0 | 1522 | | if (_shouldTrace) |
| | 1523 | | { |
| 0 | 1524 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1525 | | } |
| 0 | 1526 | | return _result; |
| 0 | 1527 | | } |
| | 1528 | |
|
| | 1529 | | /// <summary> |
| | 1530 | | /// Updates the properties of the specified Task. |
| | 1531 | | /// </summary> |
| | 1532 | | /// <param name='jobId'> |
| | 1533 | | /// The ID of the Job containing the Task. |
| | 1534 | | /// </param> |
| | 1535 | | /// <param name='taskId'> |
| | 1536 | | /// The ID of the Task to update. |
| | 1537 | | /// </param> |
| | 1538 | | /// <param name='constraints'> |
| | 1539 | | /// Constraints that apply to this Task. If omitted, the Task is given the |
| | 1540 | | /// default constraints. For multi-instance Tasks, updating the retention time |
| | 1541 | | /// applies only to the primary Task and not subtasks. |
| | 1542 | | /// </param> |
| | 1543 | | /// <param name='taskUpdateOptions'> |
| | 1544 | | /// Additional parameters for the operation |
| | 1545 | | /// </param> |
| | 1546 | | /// <param name='customHeaders'> |
| | 1547 | | /// Headers that will be added to request. |
| | 1548 | | /// </param> |
| | 1549 | | /// <param name='cancellationToken'> |
| | 1550 | | /// The cancellation token. |
| | 1551 | | /// </param> |
| | 1552 | | /// <exception cref="BatchErrorException"> |
| | 1553 | | /// Thrown when the operation returned an invalid status code |
| | 1554 | | /// </exception> |
| | 1555 | | /// <exception cref="ValidationException"> |
| | 1556 | | /// Thrown when a required parameter is null |
| | 1557 | | /// </exception> |
| | 1558 | | /// <exception cref="System.ArgumentNullException"> |
| | 1559 | | /// Thrown when a required parameter is null |
| | 1560 | | /// </exception> |
| | 1561 | | /// <return> |
| | 1562 | | /// A response object containing the response body and response headers. |
| | 1563 | | /// </return> |
| | 1564 | | public async Task<AzureOperationHeaderResponse<TaskUpdateHeaders>> UpdateWithHttpMessagesAsync(string jobId, str |
| | 1565 | | { |
| 0 | 1566 | | if (Client.BatchUrl == null) |
| | 1567 | | { |
| 0 | 1568 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1569 | | } |
| 0 | 1570 | | if (jobId == null) |
| | 1571 | | { |
| 0 | 1572 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 1573 | | } |
| 0 | 1574 | | if (taskId == null) |
| | 1575 | | { |
| 0 | 1576 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 1577 | | } |
| 0 | 1578 | | if (Client.ApiVersion == null) |
| | 1579 | | { |
| 0 | 1580 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1581 | | } |
| 0 | 1582 | | int? timeout = default(int?); |
| 0 | 1583 | | if (taskUpdateOptions != null) |
| | 1584 | | { |
| 0 | 1585 | | timeout = taskUpdateOptions.Timeout; |
| | 1586 | | } |
| 0 | 1587 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1588 | | if (taskUpdateOptions != null) |
| | 1589 | | { |
| 0 | 1590 | | clientRequestId = taskUpdateOptions.ClientRequestId; |
| | 1591 | | } |
| 0 | 1592 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1593 | | if (taskUpdateOptions != null) |
| | 1594 | | { |
| 0 | 1595 | | returnClientRequestId = taskUpdateOptions.ReturnClientRequestId; |
| | 1596 | | } |
| 0 | 1597 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1598 | | if (taskUpdateOptions != null) |
| | 1599 | | { |
| 0 | 1600 | | ocpDate = taskUpdateOptions.OcpDate; |
| | 1601 | | } |
| 0 | 1602 | | string ifMatch = default(string); |
| 0 | 1603 | | if (taskUpdateOptions != null) |
| | 1604 | | { |
| 0 | 1605 | | ifMatch = taskUpdateOptions.IfMatch; |
| | 1606 | | } |
| 0 | 1607 | | string ifNoneMatch = default(string); |
| 0 | 1608 | | if (taskUpdateOptions != null) |
| | 1609 | | { |
| 0 | 1610 | | ifNoneMatch = taskUpdateOptions.IfNoneMatch; |
| | 1611 | | } |
| 0 | 1612 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 1613 | | if (taskUpdateOptions != null) |
| | 1614 | | { |
| 0 | 1615 | | ifModifiedSince = taskUpdateOptions.IfModifiedSince; |
| | 1616 | | } |
| 0 | 1617 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 1618 | | if (taskUpdateOptions != null) |
| | 1619 | | { |
| 0 | 1620 | | ifUnmodifiedSince = taskUpdateOptions.IfUnmodifiedSince; |
| | 1621 | | } |
| 0 | 1622 | | TaskUpdateParameter taskUpdateParameter = new TaskUpdateParameter(); |
| 0 | 1623 | | if (constraints != null) |
| | 1624 | | { |
| 0 | 1625 | | taskUpdateParameter.Constraints = constraints; |
| | 1626 | | } |
| | 1627 | | // Tracing |
| 0 | 1628 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1629 | | string _invocationId = null; |
| 0 | 1630 | | if (_shouldTrace) |
| | 1631 | | { |
| 0 | 1632 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1633 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1634 | | tracingParameters.Add("jobId", jobId); |
| 0 | 1635 | | tracingParameters.Add("taskId", taskId); |
| 0 | 1636 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1637 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1638 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1639 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1640 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 1641 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 1642 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 1643 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 1644 | | tracingParameters.Add("taskUpdateParameter", taskUpdateParameter); |
| 0 | 1645 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1646 | | ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); |
| | 1647 | | } |
| | 1648 | | // Construct URL |
| 0 | 1649 | | var _baseUrl = Client.BaseUri; |
| 0 | 1650 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}"; |
| 0 | 1651 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1652 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 1653 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 1654 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1655 | | if (Client.ApiVersion != null) |
| | 1656 | | { |
| 0 | 1657 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1658 | | } |
| 0 | 1659 | | if (timeout != null) |
| | 1660 | | { |
| 0 | 1661 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1662 | | } |
| 0 | 1663 | | if (_queryParameters.Count > 0) |
| | 1664 | | { |
| 0 | 1665 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1666 | | } |
| | 1667 | | // Create HTTP transport objects |
| 0 | 1668 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1669 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1670 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 1671 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1672 | | // Set Headers |
| 0 | 1673 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1674 | | { |
| 0 | 1675 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1676 | | } |
| 0 | 1677 | | if (Client.AcceptLanguage != null) |
| | 1678 | | { |
| 0 | 1679 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1680 | | { |
| 0 | 1681 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1682 | | } |
| 0 | 1683 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1684 | | } |
| 0 | 1685 | | if (clientRequestId != null) |
| | 1686 | | { |
| 0 | 1687 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1688 | | { |
| 0 | 1689 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1690 | | } |
| 0 | 1691 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1692 | | } |
| 0 | 1693 | | if (returnClientRequestId != null) |
| | 1694 | | { |
| 0 | 1695 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1696 | | { |
| 0 | 1697 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1698 | | } |
| 0 | 1699 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1700 | | } |
| 0 | 1701 | | if (ocpDate != null) |
| | 1702 | | { |
| 0 | 1703 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1704 | | { |
| 0 | 1705 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 1706 | | } |
| 0 | 1707 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 1708 | | } |
| 0 | 1709 | | if (ifMatch != null) |
| | 1710 | | { |
| 0 | 1711 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 1712 | | { |
| 0 | 1713 | | _httpRequest.Headers.Remove("If-Match"); |
| | 1714 | | } |
| 0 | 1715 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 1716 | | } |
| 0 | 1717 | | if (ifNoneMatch != null) |
| | 1718 | | { |
| 0 | 1719 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 1720 | | { |
| 0 | 1721 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 1722 | | } |
| 0 | 1723 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 1724 | | } |
| 0 | 1725 | | if (ifModifiedSince != null) |
| | 1726 | | { |
| 0 | 1727 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 1728 | | { |
| 0 | 1729 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 1730 | | } |
| 0 | 1731 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 1732 | | } |
| 0 | 1733 | | if (ifUnmodifiedSince != null) |
| | 1734 | | { |
| 0 | 1735 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 1736 | | { |
| 0 | 1737 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 1738 | | } |
| 0 | 1739 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 1740 | | } |
| | 1741 | |
|
| | 1742 | |
|
| 0 | 1743 | | if (customHeaders != null) |
| | 1744 | | { |
| 0 | 1745 | | foreach(var _header in customHeaders) |
| | 1746 | | { |
| 0 | 1747 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1748 | | { |
| 0 | 1749 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1750 | | } |
| 0 | 1751 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1752 | | } |
| | 1753 | | } |
| | 1754 | |
|
| | 1755 | | // Serialize Request |
| 0 | 1756 | | string _requestContent = null; |
| 0 | 1757 | | if(taskUpdateParameter != null) |
| | 1758 | | { |
| 0 | 1759 | | _requestContent = SafeJsonConvert.SerializeObject(taskUpdateParameter, Client.SerializationSettings); |
| 0 | 1760 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 1761 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 1762 | | } |
| | 1763 | | // Set Credentials |
| 0 | 1764 | | if (Client.Credentials != null) |
| | 1765 | | { |
| 0 | 1766 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1767 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1768 | | } |
| | 1769 | | // Send Request |
| 0 | 1770 | | if (_shouldTrace) |
| | 1771 | | { |
| 0 | 1772 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1773 | | } |
| 0 | 1774 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1775 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1776 | | if (_shouldTrace) |
| | 1777 | | { |
| 0 | 1778 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1779 | | } |
| 0 | 1780 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1781 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1782 | | string _responseContent = null; |
| 0 | 1783 | | if ((int)_statusCode != 200) |
| | 1784 | | { |
| 0 | 1785 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 1786 | | try |
| | 1787 | | { |
| 0 | 1788 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1789 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 1790 | | if (_errorBody != null) |
| | 1791 | | { |
| 0 | 1792 | | ex.Body = _errorBody; |
| | 1793 | | } |
| 0 | 1794 | | } |
| 0 | 1795 | | catch (JsonException) |
| | 1796 | | { |
| | 1797 | | // Ignore the exception |
| 0 | 1798 | | } |
| 0 | 1799 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1800 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1801 | | if (_shouldTrace) |
| | 1802 | | { |
| 0 | 1803 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1804 | | } |
| 0 | 1805 | | _httpRequest.Dispose(); |
| 0 | 1806 | | if (_httpResponse != null) |
| | 1807 | | { |
| 0 | 1808 | | _httpResponse.Dispose(); |
| | 1809 | | } |
| 0 | 1810 | | throw ex; |
| | 1811 | | } |
| | 1812 | | // Create Result |
| 0 | 1813 | | var _result = new AzureOperationHeaderResponse<TaskUpdateHeaders>(); |
| 0 | 1814 | | _result.Request = _httpRequest; |
| 0 | 1815 | | _result.Response = _httpResponse; |
| 0 | 1816 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 1817 | | { |
| 0 | 1818 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 1819 | | } |
| | 1820 | | try |
| | 1821 | | { |
| 0 | 1822 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskUpdateHeaders>(JsonSerializer.Create(Cli |
| 0 | 1823 | | } |
| 0 | 1824 | | catch (JsonException ex) |
| | 1825 | | { |
| 0 | 1826 | | _httpRequest.Dispose(); |
| 0 | 1827 | | if (_httpResponse != null) |
| | 1828 | | { |
| 0 | 1829 | | _httpResponse.Dispose(); |
| | 1830 | | } |
| 0 | 1831 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 1832 | | } |
| 0 | 1833 | | if (_shouldTrace) |
| | 1834 | | { |
| 0 | 1835 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1836 | | } |
| 0 | 1837 | | return _result; |
| 0 | 1838 | | } |
| | 1839 | |
|
| | 1840 | | /// <summary> |
| | 1841 | | /// Lists all of the subtasks that are associated with the specified |
| | 1842 | | /// multi-instance Task. |
| | 1843 | | /// </summary> |
| | 1844 | | /// <remarks> |
| | 1845 | | /// If the Task is not a multi-instance Task then this returns an empty |
| | 1846 | | /// collection. |
| | 1847 | | /// </remarks> |
| | 1848 | | /// <param name='jobId'> |
| | 1849 | | /// The ID of the Job. |
| | 1850 | | /// </param> |
| | 1851 | | /// <param name='taskId'> |
| | 1852 | | /// The ID of the Task. |
| | 1853 | | /// </param> |
| | 1854 | | /// <param name='taskListSubtasksOptions'> |
| | 1855 | | /// Additional parameters for the operation |
| | 1856 | | /// </param> |
| | 1857 | | /// <param name='customHeaders'> |
| | 1858 | | /// Headers that will be added to request. |
| | 1859 | | /// </param> |
| | 1860 | | /// <param name='cancellationToken'> |
| | 1861 | | /// The cancellation token. |
| | 1862 | | /// </param> |
| | 1863 | | /// <exception cref="BatchErrorException"> |
| | 1864 | | /// Thrown when the operation returned an invalid status code |
| | 1865 | | /// </exception> |
| | 1866 | | /// <exception cref="SerializationException"> |
| | 1867 | | /// Thrown when unable to deserialize the response |
| | 1868 | | /// </exception> |
| | 1869 | | /// <exception cref="ValidationException"> |
| | 1870 | | /// Thrown when a required parameter is null |
| | 1871 | | /// </exception> |
| | 1872 | | /// <exception cref="System.ArgumentNullException"> |
| | 1873 | | /// Thrown when a required parameter is null |
| | 1874 | | /// </exception> |
| | 1875 | | /// <return> |
| | 1876 | | /// A response object containing the response body and response headers. |
| | 1877 | | /// </return> |
| | 1878 | | public async Task<AzureOperationResponse<CloudTaskListSubtasksResult,TaskListSubtasksHeaders>> ListSubtasksWithH |
| | 1879 | | { |
| 0 | 1880 | | if (Client.BatchUrl == null) |
| | 1881 | | { |
| 0 | 1882 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 1883 | | } |
| 0 | 1884 | | if (jobId == null) |
| | 1885 | | { |
| 0 | 1886 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 1887 | | } |
| 0 | 1888 | | if (taskId == null) |
| | 1889 | | { |
| 0 | 1890 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 1891 | | } |
| 0 | 1892 | | if (Client.ApiVersion == null) |
| | 1893 | | { |
| 0 | 1894 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 1895 | | } |
| 0 | 1896 | | string select = default(string); |
| 0 | 1897 | | if (taskListSubtasksOptions != null) |
| | 1898 | | { |
| 0 | 1899 | | select = taskListSubtasksOptions.Select; |
| | 1900 | | } |
| 0 | 1901 | | int? timeout = default(int?); |
| 0 | 1902 | | if (taskListSubtasksOptions != null) |
| | 1903 | | { |
| 0 | 1904 | | timeout = taskListSubtasksOptions.Timeout; |
| | 1905 | | } |
| 0 | 1906 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1907 | | if (taskListSubtasksOptions != null) |
| | 1908 | | { |
| 0 | 1909 | | clientRequestId = taskListSubtasksOptions.ClientRequestId; |
| | 1910 | | } |
| 0 | 1911 | | bool? returnClientRequestId = default(bool?); |
| 0 | 1912 | | if (taskListSubtasksOptions != null) |
| | 1913 | | { |
| 0 | 1914 | | returnClientRequestId = taskListSubtasksOptions.ReturnClientRequestId; |
| | 1915 | | } |
| 0 | 1916 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 1917 | | if (taskListSubtasksOptions != null) |
| | 1918 | | { |
| 0 | 1919 | | ocpDate = taskListSubtasksOptions.OcpDate; |
| | 1920 | | } |
| | 1921 | | // Tracing |
| 0 | 1922 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1923 | | string _invocationId = null; |
| 0 | 1924 | | if (_shouldTrace) |
| | 1925 | | { |
| 0 | 1926 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1927 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1928 | | tracingParameters.Add("jobId", jobId); |
| 0 | 1929 | | tracingParameters.Add("taskId", taskId); |
| 0 | 1930 | | tracingParameters.Add("select", select); |
| 0 | 1931 | | tracingParameters.Add("timeout", timeout); |
| 0 | 1932 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1933 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 1934 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 1935 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1936 | | ServiceClientTracing.Enter(_invocationId, this, "ListSubtasks", tracingParameters); |
| | 1937 | | } |
| | 1938 | | // Construct URL |
| 0 | 1939 | | var _baseUrl = Client.BaseUri; |
| 0 | 1940 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/subtasksinfo"; |
| 0 | 1941 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 1942 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 1943 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 1944 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1945 | | if (Client.ApiVersion != null) |
| | 1946 | | { |
| 0 | 1947 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 1948 | | } |
| 0 | 1949 | | if (select != null) |
| | 1950 | | { |
| 0 | 1951 | | _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); |
| | 1952 | | } |
| 0 | 1953 | | if (timeout != null) |
| | 1954 | | { |
| 0 | 1955 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 1956 | | } |
| 0 | 1957 | | if (_queryParameters.Count > 0) |
| | 1958 | | { |
| 0 | 1959 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1960 | | } |
| | 1961 | | // Create HTTP transport objects |
| 0 | 1962 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1963 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1964 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 1965 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1966 | | // Set Headers |
| 0 | 1967 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1968 | | { |
| 0 | 1969 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 1970 | | } |
| 0 | 1971 | | if (Client.AcceptLanguage != null) |
| | 1972 | | { |
| 0 | 1973 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1974 | | { |
| 0 | 1975 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1976 | | } |
| 0 | 1977 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1978 | | } |
| 0 | 1979 | | if (clientRequestId != null) |
| | 1980 | | { |
| 0 | 1981 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 1982 | | { |
| 0 | 1983 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 1984 | | } |
| 0 | 1985 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 1986 | | } |
| 0 | 1987 | | if (returnClientRequestId != null) |
| | 1988 | | { |
| 0 | 1989 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 1990 | | { |
| 0 | 1991 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 1992 | | } |
| 0 | 1993 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 1994 | | } |
| 0 | 1995 | | if (ocpDate != null) |
| | 1996 | | { |
| 0 | 1997 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 1998 | | { |
| 0 | 1999 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2000 | | } |
| 0 | 2001 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2002 | | } |
| | 2003 | |
|
| | 2004 | |
|
| 0 | 2005 | | if (customHeaders != null) |
| | 2006 | | { |
| 0 | 2007 | | foreach(var _header in customHeaders) |
| | 2008 | | { |
| 0 | 2009 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2010 | | { |
| 0 | 2011 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2012 | | } |
| 0 | 2013 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2014 | | } |
| | 2015 | | } |
| | 2016 | |
|
| | 2017 | | // Serialize Request |
| 0 | 2018 | | string _requestContent = null; |
| | 2019 | | // Set Credentials |
| 0 | 2020 | | if (Client.Credentials != null) |
| | 2021 | | { |
| 0 | 2022 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2023 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2024 | | } |
| | 2025 | | // Send Request |
| 0 | 2026 | | if (_shouldTrace) |
| | 2027 | | { |
| 0 | 2028 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2029 | | } |
| 0 | 2030 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2031 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2032 | | if (_shouldTrace) |
| | 2033 | | { |
| 0 | 2034 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2035 | | } |
| 0 | 2036 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2037 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2038 | | string _responseContent = null; |
| 0 | 2039 | | if ((int)_statusCode != 200) |
| | 2040 | | { |
| 0 | 2041 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2042 | | try |
| | 2043 | | { |
| 0 | 2044 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2045 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2046 | | if (_errorBody != null) |
| | 2047 | | { |
| 0 | 2048 | | ex.Body = _errorBody; |
| | 2049 | | } |
| 0 | 2050 | | } |
| 0 | 2051 | | catch (JsonException) |
| | 2052 | | { |
| | 2053 | | // Ignore the exception |
| 0 | 2054 | | } |
| 0 | 2055 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2056 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2057 | | if (_shouldTrace) |
| | 2058 | | { |
| 0 | 2059 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2060 | | } |
| 0 | 2061 | | _httpRequest.Dispose(); |
| 0 | 2062 | | if (_httpResponse != null) |
| | 2063 | | { |
| 0 | 2064 | | _httpResponse.Dispose(); |
| | 2065 | | } |
| 0 | 2066 | | throw ex; |
| | 2067 | | } |
| | 2068 | | // Create Result |
| 0 | 2069 | | var _result = new AzureOperationResponse<CloudTaskListSubtasksResult,TaskListSubtasksHeaders>(); |
| 0 | 2070 | | _result.Request = _httpRequest; |
| 0 | 2071 | | _result.Response = _httpResponse; |
| 0 | 2072 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2073 | | { |
| 0 | 2074 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2075 | | } |
| | 2076 | | // Deserialize Response |
| 0 | 2077 | | if ((int)_statusCode == 200) |
| | 2078 | | { |
| 0 | 2079 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2080 | | try |
| | 2081 | | { |
| 0 | 2082 | | _result.Body = SafeJsonConvert.DeserializeObject<CloudTaskListSubtasksResult>(_responseContent, Clie |
| 0 | 2083 | | } |
| 0 | 2084 | | catch (JsonException ex) |
| | 2085 | | { |
| 0 | 2086 | | _httpRequest.Dispose(); |
| 0 | 2087 | | if (_httpResponse != null) |
| | 2088 | | { |
| 0 | 2089 | | _httpResponse.Dispose(); |
| | 2090 | | } |
| 0 | 2091 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2092 | | } |
| | 2093 | | } |
| | 2094 | | try |
| | 2095 | | { |
| 0 | 2096 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskListSubtasksHeaders>(JsonSerializer.Crea |
| 0 | 2097 | | } |
| 0 | 2098 | | catch (JsonException ex) |
| | 2099 | | { |
| 0 | 2100 | | _httpRequest.Dispose(); |
| 0 | 2101 | | if (_httpResponse != null) |
| | 2102 | | { |
| 0 | 2103 | | _httpResponse.Dispose(); |
| | 2104 | | } |
| 0 | 2105 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2106 | | } |
| 0 | 2107 | | if (_shouldTrace) |
| | 2108 | | { |
| 0 | 2109 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2110 | | } |
| 0 | 2111 | | return _result; |
| 0 | 2112 | | } |
| | 2113 | |
|
| | 2114 | | /// <summary> |
| | 2115 | | /// Terminates the specified Task. |
| | 2116 | | /// </summary> |
| | 2117 | | /// <remarks> |
| | 2118 | | /// When the Task has been terminated, it moves to the completed state. For |
| | 2119 | | /// multi-instance Tasks, the terminate Task operation applies synchronously to |
| | 2120 | | /// the primary task; subtasks are then terminated asynchronously in the |
| | 2121 | | /// background. |
| | 2122 | | /// </remarks> |
| | 2123 | | /// <param name='jobId'> |
| | 2124 | | /// The ID of the Job containing the Task. |
| | 2125 | | /// </param> |
| | 2126 | | /// <param name='taskId'> |
| | 2127 | | /// The ID of the Task to terminate. |
| | 2128 | | /// </param> |
| | 2129 | | /// <param name='taskTerminateOptions'> |
| | 2130 | | /// Additional parameters for the operation |
| | 2131 | | /// </param> |
| | 2132 | | /// <param name='customHeaders'> |
| | 2133 | | /// Headers that will be added to request. |
| | 2134 | | /// </param> |
| | 2135 | | /// <param name='cancellationToken'> |
| | 2136 | | /// The cancellation token. |
| | 2137 | | /// </param> |
| | 2138 | | /// <exception cref="BatchErrorException"> |
| | 2139 | | /// Thrown when the operation returned an invalid status code |
| | 2140 | | /// </exception> |
| | 2141 | | /// <exception cref="ValidationException"> |
| | 2142 | | /// Thrown when a required parameter is null |
| | 2143 | | /// </exception> |
| | 2144 | | /// <exception cref="System.ArgumentNullException"> |
| | 2145 | | /// Thrown when a required parameter is null |
| | 2146 | | /// </exception> |
| | 2147 | | /// <return> |
| | 2148 | | /// A response object containing the response body and response headers. |
| | 2149 | | /// </return> |
| | 2150 | | public async Task<AzureOperationHeaderResponse<TaskTerminateHeaders>> TerminateWithHttpMessagesAsync(string jobI |
| | 2151 | | { |
| 0 | 2152 | | if (Client.BatchUrl == null) |
| | 2153 | | { |
| 0 | 2154 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 2155 | | } |
| 0 | 2156 | | if (jobId == null) |
| | 2157 | | { |
| 0 | 2158 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 2159 | | } |
| 0 | 2160 | | if (taskId == null) |
| | 2161 | | { |
| 0 | 2162 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 2163 | | } |
| 0 | 2164 | | if (Client.ApiVersion == null) |
| | 2165 | | { |
| 0 | 2166 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 2167 | | } |
| 0 | 2168 | | int? timeout = default(int?); |
| 0 | 2169 | | if (taskTerminateOptions != null) |
| | 2170 | | { |
| 0 | 2171 | | timeout = taskTerminateOptions.Timeout; |
| | 2172 | | } |
| 0 | 2173 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2174 | | if (taskTerminateOptions != null) |
| | 2175 | | { |
| 0 | 2176 | | clientRequestId = taskTerminateOptions.ClientRequestId; |
| | 2177 | | } |
| 0 | 2178 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2179 | | if (taskTerminateOptions != null) |
| | 2180 | | { |
| 0 | 2181 | | returnClientRequestId = taskTerminateOptions.ReturnClientRequestId; |
| | 2182 | | } |
| 0 | 2183 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2184 | | if (taskTerminateOptions != null) |
| | 2185 | | { |
| 0 | 2186 | | ocpDate = taskTerminateOptions.OcpDate; |
| | 2187 | | } |
| 0 | 2188 | | string ifMatch = default(string); |
| 0 | 2189 | | if (taskTerminateOptions != null) |
| | 2190 | | { |
| 0 | 2191 | | ifMatch = taskTerminateOptions.IfMatch; |
| | 2192 | | } |
| 0 | 2193 | | string ifNoneMatch = default(string); |
| 0 | 2194 | | if (taskTerminateOptions != null) |
| | 2195 | | { |
| 0 | 2196 | | ifNoneMatch = taskTerminateOptions.IfNoneMatch; |
| | 2197 | | } |
| 0 | 2198 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 2199 | | if (taskTerminateOptions != null) |
| | 2200 | | { |
| 0 | 2201 | | ifModifiedSince = taskTerminateOptions.IfModifiedSince; |
| | 2202 | | } |
| 0 | 2203 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 2204 | | if (taskTerminateOptions != null) |
| | 2205 | | { |
| 0 | 2206 | | ifUnmodifiedSince = taskTerminateOptions.IfUnmodifiedSince; |
| | 2207 | | } |
| | 2208 | | // Tracing |
| 0 | 2209 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2210 | | string _invocationId = null; |
| 0 | 2211 | | if (_shouldTrace) |
| | 2212 | | { |
| 0 | 2213 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2214 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2215 | | tracingParameters.Add("jobId", jobId); |
| 0 | 2216 | | tracingParameters.Add("taskId", taskId); |
| 0 | 2217 | | tracingParameters.Add("timeout", timeout); |
| 0 | 2218 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2219 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2220 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2221 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 2222 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 2223 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 2224 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 2225 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2226 | | ServiceClientTracing.Enter(_invocationId, this, "Terminate", tracingParameters); |
| | 2227 | | } |
| | 2228 | | // Construct URL |
| 0 | 2229 | | var _baseUrl = Client.BaseUri; |
| 0 | 2230 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/terminate"; |
| 0 | 2231 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 2232 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 2233 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 2234 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2235 | | if (Client.ApiVersion != null) |
| | 2236 | | { |
| 0 | 2237 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 2238 | | } |
| 0 | 2239 | | if (timeout != null) |
| | 2240 | | { |
| 0 | 2241 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 2242 | | } |
| 0 | 2243 | | if (_queryParameters.Count > 0) |
| | 2244 | | { |
| 0 | 2245 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2246 | | } |
| | 2247 | | // Create HTTP transport objects |
| 0 | 2248 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2249 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2250 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 2251 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2252 | | // Set Headers |
| 0 | 2253 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2254 | | { |
| 0 | 2255 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2256 | | } |
| 0 | 2257 | | if (Client.AcceptLanguage != null) |
| | 2258 | | { |
| 0 | 2259 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2260 | | { |
| 0 | 2261 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2262 | | } |
| 0 | 2263 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2264 | | } |
| 0 | 2265 | | if (clientRequestId != null) |
| | 2266 | | { |
| 0 | 2267 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2268 | | { |
| 0 | 2269 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2270 | | } |
| 0 | 2271 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2272 | | } |
| 0 | 2273 | | if (returnClientRequestId != null) |
| | 2274 | | { |
| 0 | 2275 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2276 | | { |
| 0 | 2277 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2278 | | } |
| 0 | 2279 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2280 | | } |
| 0 | 2281 | | if (ocpDate != null) |
| | 2282 | | { |
| 0 | 2283 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2284 | | { |
| 0 | 2285 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2286 | | } |
| 0 | 2287 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2288 | | } |
| 0 | 2289 | | if (ifMatch != null) |
| | 2290 | | { |
| 0 | 2291 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 2292 | | { |
| 0 | 2293 | | _httpRequest.Headers.Remove("If-Match"); |
| | 2294 | | } |
| 0 | 2295 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 2296 | | } |
| 0 | 2297 | | if (ifNoneMatch != null) |
| | 2298 | | { |
| 0 | 2299 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 2300 | | { |
| 0 | 2301 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 2302 | | } |
| 0 | 2303 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 2304 | | } |
| 0 | 2305 | | if (ifModifiedSince != null) |
| | 2306 | | { |
| 0 | 2307 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 2308 | | { |
| 0 | 2309 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 2310 | | } |
| 0 | 2311 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 2312 | | } |
| 0 | 2313 | | if (ifUnmodifiedSince != null) |
| | 2314 | | { |
| 0 | 2315 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 2316 | | { |
| 0 | 2317 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 2318 | | } |
| 0 | 2319 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 2320 | | } |
| | 2321 | |
|
| | 2322 | |
|
| 0 | 2323 | | if (customHeaders != null) |
| | 2324 | | { |
| 0 | 2325 | | foreach(var _header in customHeaders) |
| | 2326 | | { |
| 0 | 2327 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2328 | | { |
| 0 | 2329 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2330 | | } |
| 0 | 2331 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2332 | | } |
| | 2333 | | } |
| | 2334 | |
|
| | 2335 | | // Serialize Request |
| 0 | 2336 | | string _requestContent = null; |
| | 2337 | | // Set Credentials |
| 0 | 2338 | | if (Client.Credentials != null) |
| | 2339 | | { |
| 0 | 2340 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2341 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2342 | | } |
| | 2343 | | // Send Request |
| 0 | 2344 | | if (_shouldTrace) |
| | 2345 | | { |
| 0 | 2346 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2347 | | } |
| 0 | 2348 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2349 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2350 | | if (_shouldTrace) |
| | 2351 | | { |
| 0 | 2352 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2353 | | } |
| 0 | 2354 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2355 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2356 | | string _responseContent = null; |
| 0 | 2357 | | if ((int)_statusCode != 204) |
| | 2358 | | { |
| 0 | 2359 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2360 | | try |
| | 2361 | | { |
| 0 | 2362 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2363 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2364 | | if (_errorBody != null) |
| | 2365 | | { |
| 0 | 2366 | | ex.Body = _errorBody; |
| | 2367 | | } |
| 0 | 2368 | | } |
| 0 | 2369 | | catch (JsonException) |
| | 2370 | | { |
| | 2371 | | // Ignore the exception |
| 0 | 2372 | | } |
| 0 | 2373 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2374 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2375 | | if (_shouldTrace) |
| | 2376 | | { |
| 0 | 2377 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2378 | | } |
| 0 | 2379 | | _httpRequest.Dispose(); |
| 0 | 2380 | | if (_httpResponse != null) |
| | 2381 | | { |
| 0 | 2382 | | _httpResponse.Dispose(); |
| | 2383 | | } |
| 0 | 2384 | | throw ex; |
| | 2385 | | } |
| | 2386 | | // Create Result |
| 0 | 2387 | | var _result = new AzureOperationHeaderResponse<TaskTerminateHeaders>(); |
| 0 | 2388 | | _result.Request = _httpRequest; |
| 0 | 2389 | | _result.Response = _httpResponse; |
| 0 | 2390 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2391 | | { |
| 0 | 2392 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2393 | | } |
| | 2394 | | try |
| | 2395 | | { |
| 0 | 2396 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskTerminateHeaders>(JsonSerializer.Create( |
| 0 | 2397 | | } |
| 0 | 2398 | | catch (JsonException ex) |
| | 2399 | | { |
| 0 | 2400 | | _httpRequest.Dispose(); |
| 0 | 2401 | | if (_httpResponse != null) |
| | 2402 | | { |
| 0 | 2403 | | _httpResponse.Dispose(); |
| | 2404 | | } |
| 0 | 2405 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2406 | | } |
| 0 | 2407 | | if (_shouldTrace) |
| | 2408 | | { |
| 0 | 2409 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2410 | | } |
| 0 | 2411 | | return _result; |
| 0 | 2412 | | } |
| | 2413 | |
|
| | 2414 | | /// <summary> |
| | 2415 | | /// Reactivates a Task, allowing it to run again even if its retry count has |
| | 2416 | | /// been exhausted. |
| | 2417 | | /// </summary> |
| | 2418 | | /// <remarks> |
| | 2419 | | /// Reactivation makes a Task eligible to be retried again up to its maximum |
| | 2420 | | /// retry count. The Task's state is changed to active. As the Task is no |
| | 2421 | | /// longer in the completed state, any previous exit code or failure |
| | 2422 | | /// information is no longer available after reactivation. Each time a Task is |
| | 2423 | | /// reactivated, its retry count is reset to 0. Reactivation will fail for |
| | 2424 | | /// Tasks that are not completed or that previously completed successfully |
| | 2425 | | /// (with an exit code of 0). Additionally, it will fail if the Job has |
| | 2426 | | /// completed (or is terminating or deleting). |
| | 2427 | | /// </remarks> |
| | 2428 | | /// <param name='jobId'> |
| | 2429 | | /// The ID of the Job containing the Task. |
| | 2430 | | /// </param> |
| | 2431 | | /// <param name='taskId'> |
| | 2432 | | /// The ID of the Task to reactivate. |
| | 2433 | | /// </param> |
| | 2434 | | /// <param name='taskReactivateOptions'> |
| | 2435 | | /// Additional parameters for the operation |
| | 2436 | | /// </param> |
| | 2437 | | /// <param name='customHeaders'> |
| | 2438 | | /// Headers that will be added to request. |
| | 2439 | | /// </param> |
| | 2440 | | /// <param name='cancellationToken'> |
| | 2441 | | /// The cancellation token. |
| | 2442 | | /// </param> |
| | 2443 | | /// <exception cref="BatchErrorException"> |
| | 2444 | | /// Thrown when the operation returned an invalid status code |
| | 2445 | | /// </exception> |
| | 2446 | | /// <exception cref="ValidationException"> |
| | 2447 | | /// Thrown when a required parameter is null |
| | 2448 | | /// </exception> |
| | 2449 | | /// <exception cref="System.ArgumentNullException"> |
| | 2450 | | /// Thrown when a required parameter is null |
| | 2451 | | /// </exception> |
| | 2452 | | /// <return> |
| | 2453 | | /// A response object containing the response body and response headers. |
| | 2454 | | /// </return> |
| | 2455 | | public async Task<AzureOperationHeaderResponse<TaskReactivateHeaders>> ReactivateWithHttpMessagesAsync(string jo |
| | 2456 | | { |
| 0 | 2457 | | if (Client.BatchUrl == null) |
| | 2458 | | { |
| 0 | 2459 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.BatchUrl"); |
| | 2460 | | } |
| 0 | 2461 | | if (jobId == null) |
| | 2462 | | { |
| 0 | 2463 | | throw new ValidationException(ValidationRules.CannotBeNull, "jobId"); |
| | 2464 | | } |
| 0 | 2465 | | if (taskId == null) |
| | 2466 | | { |
| 0 | 2467 | | throw new ValidationException(ValidationRules.CannotBeNull, "taskId"); |
| | 2468 | | } |
| 0 | 2469 | | if (Client.ApiVersion == null) |
| | 2470 | | { |
| 0 | 2471 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 2472 | | } |
| 0 | 2473 | | int? timeout = default(int?); |
| 0 | 2474 | | if (taskReactivateOptions != null) |
| | 2475 | | { |
| 0 | 2476 | | timeout = taskReactivateOptions.Timeout; |
| | 2477 | | } |
| 0 | 2478 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2479 | | if (taskReactivateOptions != null) |
| | 2480 | | { |
| 0 | 2481 | | clientRequestId = taskReactivateOptions.ClientRequestId; |
| | 2482 | | } |
| 0 | 2483 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2484 | | if (taskReactivateOptions != null) |
| | 2485 | | { |
| 0 | 2486 | | returnClientRequestId = taskReactivateOptions.ReturnClientRequestId; |
| | 2487 | | } |
| 0 | 2488 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2489 | | if (taskReactivateOptions != null) |
| | 2490 | | { |
| 0 | 2491 | | ocpDate = taskReactivateOptions.OcpDate; |
| | 2492 | | } |
| 0 | 2493 | | string ifMatch = default(string); |
| 0 | 2494 | | if (taskReactivateOptions != null) |
| | 2495 | | { |
| 0 | 2496 | | ifMatch = taskReactivateOptions.IfMatch; |
| | 2497 | | } |
| 0 | 2498 | | string ifNoneMatch = default(string); |
| 0 | 2499 | | if (taskReactivateOptions != null) |
| | 2500 | | { |
| 0 | 2501 | | ifNoneMatch = taskReactivateOptions.IfNoneMatch; |
| | 2502 | | } |
| 0 | 2503 | | System.DateTime? ifModifiedSince = default(System.DateTime?); |
| 0 | 2504 | | if (taskReactivateOptions != null) |
| | 2505 | | { |
| 0 | 2506 | | ifModifiedSince = taskReactivateOptions.IfModifiedSince; |
| | 2507 | | } |
| 0 | 2508 | | System.DateTime? ifUnmodifiedSince = default(System.DateTime?); |
| 0 | 2509 | | if (taskReactivateOptions != null) |
| | 2510 | | { |
| 0 | 2511 | | ifUnmodifiedSince = taskReactivateOptions.IfUnmodifiedSince; |
| | 2512 | | } |
| | 2513 | | // Tracing |
| 0 | 2514 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2515 | | string _invocationId = null; |
| 0 | 2516 | | if (_shouldTrace) |
| | 2517 | | { |
| 0 | 2518 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2519 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2520 | | tracingParameters.Add("jobId", jobId); |
| 0 | 2521 | | tracingParameters.Add("taskId", taskId); |
| 0 | 2522 | | tracingParameters.Add("timeout", timeout); |
| 0 | 2523 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2524 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2525 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2526 | | tracingParameters.Add("ifMatch", ifMatch); |
| 0 | 2527 | | tracingParameters.Add("ifNoneMatch", ifNoneMatch); |
| 0 | 2528 | | tracingParameters.Add("ifModifiedSince", ifModifiedSince); |
| 0 | 2529 | | tracingParameters.Add("ifUnmodifiedSince", ifUnmodifiedSince); |
| 0 | 2530 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2531 | | ServiceClientTracing.Enter(_invocationId, this, "Reactivate", tracingParameters); |
| | 2532 | | } |
| | 2533 | | // Construct URL |
| 0 | 2534 | | var _baseUrl = Client.BaseUri; |
| 0 | 2535 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "jobs/{jobId}/tasks/{taskId}/reactivate"; |
| 0 | 2536 | | _url = _url.Replace("{batchUrl}", Client.BatchUrl); |
| 0 | 2537 | | _url = _url.Replace("{jobId}", System.Uri.EscapeDataString(jobId)); |
| 0 | 2538 | | _url = _url.Replace("{taskId}", System.Uri.EscapeDataString(taskId)); |
| 0 | 2539 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2540 | | if (Client.ApiVersion != null) |
| | 2541 | | { |
| 0 | 2542 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 2543 | | } |
| 0 | 2544 | | if (timeout != null) |
| | 2545 | | { |
| 0 | 2546 | | _queryParameters.Add(string.Format("timeout={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO |
| | 2547 | | } |
| 0 | 2548 | | if (_queryParameters.Count > 0) |
| | 2549 | | { |
| 0 | 2550 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2551 | | } |
| | 2552 | | // Create HTTP transport objects |
| 0 | 2553 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2554 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2555 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 2556 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2557 | | // Set Headers |
| 0 | 2558 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2559 | | { |
| 0 | 2560 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2561 | | } |
| 0 | 2562 | | if (Client.AcceptLanguage != null) |
| | 2563 | | { |
| 0 | 2564 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2565 | | { |
| 0 | 2566 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2567 | | } |
| 0 | 2568 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2569 | | } |
| 0 | 2570 | | if (clientRequestId != null) |
| | 2571 | | { |
| 0 | 2572 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2573 | | { |
| 0 | 2574 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2575 | | } |
| 0 | 2576 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2577 | | } |
| 0 | 2578 | | if (returnClientRequestId != null) |
| | 2579 | | { |
| 0 | 2580 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2581 | | { |
| 0 | 2582 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2583 | | } |
| 0 | 2584 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2585 | | } |
| 0 | 2586 | | if (ocpDate != null) |
| | 2587 | | { |
| 0 | 2588 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2589 | | { |
| 0 | 2590 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2591 | | } |
| 0 | 2592 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2593 | | } |
| 0 | 2594 | | if (ifMatch != null) |
| | 2595 | | { |
| 0 | 2596 | | if (_httpRequest.Headers.Contains("If-Match")) |
| | 2597 | | { |
| 0 | 2598 | | _httpRequest.Headers.Remove("If-Match"); |
| | 2599 | | } |
| 0 | 2600 | | _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); |
| | 2601 | | } |
| 0 | 2602 | | if (ifNoneMatch != null) |
| | 2603 | | { |
| 0 | 2604 | | if (_httpRequest.Headers.Contains("If-None-Match")) |
| | 2605 | | { |
| 0 | 2606 | | _httpRequest.Headers.Remove("If-None-Match"); |
| | 2607 | | } |
| 0 | 2608 | | _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch); |
| | 2609 | | } |
| 0 | 2610 | | if (ifModifiedSince != null) |
| | 2611 | | { |
| 0 | 2612 | | if (_httpRequest.Headers.Contains("If-Modified-Since")) |
| | 2613 | | { |
| 0 | 2614 | | _httpRequest.Headers.Remove("If-Modified-Since"); |
| | 2615 | | } |
| 0 | 2616 | | _httpRequest.Headers.TryAddWithoutValidation("If-Modified-Since", SafeJsonConvert.SerializeObject(ifModi |
| | 2617 | | } |
| 0 | 2618 | | if (ifUnmodifiedSince != null) |
| | 2619 | | { |
| 0 | 2620 | | if (_httpRequest.Headers.Contains("If-Unmodified-Since")) |
| | 2621 | | { |
| 0 | 2622 | | _httpRequest.Headers.Remove("If-Unmodified-Since"); |
| | 2623 | | } |
| 0 | 2624 | | _httpRequest.Headers.TryAddWithoutValidation("If-Unmodified-Since", SafeJsonConvert.SerializeObject(ifUn |
| | 2625 | | } |
| | 2626 | |
|
| | 2627 | |
|
| 0 | 2628 | | if (customHeaders != null) |
| | 2629 | | { |
| 0 | 2630 | | foreach(var _header in customHeaders) |
| | 2631 | | { |
| 0 | 2632 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2633 | | { |
| 0 | 2634 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2635 | | } |
| 0 | 2636 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2637 | | } |
| | 2638 | | } |
| | 2639 | |
|
| | 2640 | | // Serialize Request |
| 0 | 2641 | | string _requestContent = null; |
| | 2642 | | // Set Credentials |
| 0 | 2643 | | if (Client.Credentials != null) |
| | 2644 | | { |
| 0 | 2645 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2646 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2647 | | } |
| | 2648 | | // Send Request |
| 0 | 2649 | | if (_shouldTrace) |
| | 2650 | | { |
| 0 | 2651 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2652 | | } |
| 0 | 2653 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2654 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2655 | | if (_shouldTrace) |
| | 2656 | | { |
| 0 | 2657 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2658 | | } |
| 0 | 2659 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2660 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2661 | | string _responseContent = null; |
| 0 | 2662 | | if ((int)_statusCode != 204) |
| | 2663 | | { |
| 0 | 2664 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2665 | | try |
| | 2666 | | { |
| 0 | 2667 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2668 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2669 | | if (_errorBody != null) |
| | 2670 | | { |
| 0 | 2671 | | ex.Body = _errorBody; |
| | 2672 | | } |
| 0 | 2673 | | } |
| 0 | 2674 | | catch (JsonException) |
| | 2675 | | { |
| | 2676 | | // Ignore the exception |
| 0 | 2677 | | } |
| 0 | 2678 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2679 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2680 | | if (_shouldTrace) |
| | 2681 | | { |
| 0 | 2682 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2683 | | } |
| 0 | 2684 | | _httpRequest.Dispose(); |
| 0 | 2685 | | if (_httpResponse != null) |
| | 2686 | | { |
| 0 | 2687 | | _httpResponse.Dispose(); |
| | 2688 | | } |
| 0 | 2689 | | throw ex; |
| | 2690 | | } |
| | 2691 | | // Create Result |
| 0 | 2692 | | var _result = new AzureOperationHeaderResponse<TaskReactivateHeaders>(); |
| 0 | 2693 | | _result.Request = _httpRequest; |
| 0 | 2694 | | _result.Response = _httpResponse; |
| 0 | 2695 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2696 | | { |
| 0 | 2697 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2698 | | } |
| | 2699 | | try |
| | 2700 | | { |
| 0 | 2701 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskReactivateHeaders>(JsonSerializer.Create |
| 0 | 2702 | | } |
| 0 | 2703 | | catch (JsonException ex) |
| | 2704 | | { |
| 0 | 2705 | | _httpRequest.Dispose(); |
| 0 | 2706 | | if (_httpResponse != null) |
| | 2707 | | { |
| 0 | 2708 | | _httpResponse.Dispose(); |
| | 2709 | | } |
| 0 | 2710 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2711 | | } |
| 0 | 2712 | | if (_shouldTrace) |
| | 2713 | | { |
| 0 | 2714 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2715 | | } |
| 0 | 2716 | | return _result; |
| 0 | 2717 | | } |
| | 2718 | |
|
| | 2719 | | /// <summary> |
| | 2720 | | /// Lists all of the Tasks that are associated with the specified Job. |
| | 2721 | | /// </summary> |
| | 2722 | | /// <remarks> |
| | 2723 | | /// For multi-instance Tasks, information such as affinityId, executionInfo and |
| | 2724 | | /// nodeInfo refer to the primary Task. Use the list subtasks API to retrieve |
| | 2725 | | /// information about subtasks. |
| | 2726 | | /// </remarks> |
| | 2727 | | /// <param name='nextPageLink'> |
| | 2728 | | /// The NextLink from the previous successful call to List operation. |
| | 2729 | | /// </param> |
| | 2730 | | /// <param name='taskListNextOptions'> |
| | 2731 | | /// Additional parameters for the operation |
| | 2732 | | /// </param> |
| | 2733 | | /// <param name='customHeaders'> |
| | 2734 | | /// Headers that will be added to request. |
| | 2735 | | /// </param> |
| | 2736 | | /// <param name='cancellationToken'> |
| | 2737 | | /// The cancellation token. |
| | 2738 | | /// </param> |
| | 2739 | | /// <exception cref="BatchErrorException"> |
| | 2740 | | /// Thrown when the operation returned an invalid status code |
| | 2741 | | /// </exception> |
| | 2742 | | /// <exception cref="SerializationException"> |
| | 2743 | | /// Thrown when unable to deserialize the response |
| | 2744 | | /// </exception> |
| | 2745 | | /// <exception cref="ValidationException"> |
| | 2746 | | /// Thrown when a required parameter is null |
| | 2747 | | /// </exception> |
| | 2748 | | /// <exception cref="System.ArgumentNullException"> |
| | 2749 | | /// Thrown when a required parameter is null |
| | 2750 | | /// </exception> |
| | 2751 | | /// <return> |
| | 2752 | | /// A response object containing the response body and response headers. |
| | 2753 | | /// </return> |
| | 2754 | | public async Task<AzureOperationResponse<IPage<CloudTask>,TaskListHeaders>> ListNextWithHttpMessagesAsync(string |
| | 2755 | | { |
| 0 | 2756 | | if (nextPageLink == null) |
| | 2757 | | { |
| 0 | 2758 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); |
| | 2759 | | } |
| 0 | 2760 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 2761 | | if (taskListNextOptions != null) |
| | 2762 | | { |
| 0 | 2763 | | clientRequestId = taskListNextOptions.ClientRequestId; |
| | 2764 | | } |
| 0 | 2765 | | bool? returnClientRequestId = default(bool?); |
| 0 | 2766 | | if (taskListNextOptions != null) |
| | 2767 | | { |
| 0 | 2768 | | returnClientRequestId = taskListNextOptions.ReturnClientRequestId; |
| | 2769 | | } |
| 0 | 2770 | | System.DateTime? ocpDate = default(System.DateTime?); |
| 0 | 2771 | | if (taskListNextOptions != null) |
| | 2772 | | { |
| 0 | 2773 | | ocpDate = taskListNextOptions.OcpDate; |
| | 2774 | | } |
| | 2775 | | // Tracing |
| 0 | 2776 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2777 | | string _invocationId = null; |
| 0 | 2778 | | if (_shouldTrace) |
| | 2779 | | { |
| 0 | 2780 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2781 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2782 | | tracingParameters.Add("nextPageLink", nextPageLink); |
| 0 | 2783 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 2784 | | tracingParameters.Add("returnClientRequestId", returnClientRequestId); |
| 0 | 2785 | | tracingParameters.Add("ocpDate", ocpDate); |
| 0 | 2786 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2787 | | ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); |
| | 2788 | | } |
| | 2789 | | // Construct URL |
| 0 | 2790 | | string _url = "{nextLink}"; |
| 0 | 2791 | | _url = _url.Replace("{nextLink}", nextPageLink); |
| 0 | 2792 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2793 | | if (_queryParameters.Count > 0) |
| | 2794 | | { |
| 0 | 2795 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 2796 | | } |
| | 2797 | | // Create HTTP transport objects |
| 0 | 2798 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2799 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2800 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 2801 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2802 | | // Set Headers |
| 0 | 2803 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 2804 | | { |
| 0 | 2805 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); |
| | 2806 | | } |
| 0 | 2807 | | if (Client.AcceptLanguage != null) |
| | 2808 | | { |
| 0 | 2809 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 2810 | | { |
| 0 | 2811 | | _httpRequest.Headers.Remove("accept-language"); |
| | 2812 | | } |
| 0 | 2813 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 2814 | | } |
| 0 | 2815 | | if (clientRequestId != null) |
| | 2816 | | { |
| 0 | 2817 | | if (_httpRequest.Headers.Contains("client-request-id")) |
| | 2818 | | { |
| 0 | 2819 | | _httpRequest.Headers.Remove("client-request-id"); |
| | 2820 | | } |
| 0 | 2821 | | _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client |
| | 2822 | | } |
| 0 | 2823 | | if (returnClientRequestId != null) |
| | 2824 | | { |
| 0 | 2825 | | if (_httpRequest.Headers.Contains("return-client-request-id")) |
| | 2826 | | { |
| 0 | 2827 | | _httpRequest.Headers.Remove("return-client-request-id"); |
| | 2828 | | } |
| 0 | 2829 | | _httpRequest.Headers.TryAddWithoutValidation("return-client-request-id", SafeJsonConvert.SerializeObject |
| | 2830 | | } |
| 0 | 2831 | | if (ocpDate != null) |
| | 2832 | | { |
| 0 | 2833 | | if (_httpRequest.Headers.Contains("ocp-date")) |
| | 2834 | | { |
| 0 | 2835 | | _httpRequest.Headers.Remove("ocp-date"); |
| | 2836 | | } |
| 0 | 2837 | | _httpRequest.Headers.TryAddWithoutValidation("ocp-date", SafeJsonConvert.SerializeObject(ocpDate, new Da |
| | 2838 | | } |
| | 2839 | |
|
| | 2840 | |
|
| 0 | 2841 | | if (customHeaders != null) |
| | 2842 | | { |
| 0 | 2843 | | foreach(var _header in customHeaders) |
| | 2844 | | { |
| 0 | 2845 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2846 | | { |
| 0 | 2847 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2848 | | } |
| 0 | 2849 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2850 | | } |
| | 2851 | | } |
| | 2852 | |
|
| | 2853 | | // Serialize Request |
| 0 | 2854 | | string _requestContent = null; |
| | 2855 | | // Set Credentials |
| 0 | 2856 | | if (Client.Credentials != null) |
| | 2857 | | { |
| 0 | 2858 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2859 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2860 | | } |
| | 2861 | | // Send Request |
| 0 | 2862 | | if (_shouldTrace) |
| | 2863 | | { |
| 0 | 2864 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2865 | | } |
| 0 | 2866 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2867 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2868 | | if (_shouldTrace) |
| | 2869 | | { |
| 0 | 2870 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2871 | | } |
| 0 | 2872 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2873 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2874 | | string _responseContent = null; |
| 0 | 2875 | | if ((int)_statusCode != 200) |
| | 2876 | | { |
| 0 | 2877 | | var ex = new BatchErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 2878 | | try |
| | 2879 | | { |
| 0 | 2880 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2881 | | BatchError _errorBody = SafeJsonConvert.DeserializeObject<BatchError>(_responseContent, Client.Dese |
| 0 | 2882 | | if (_errorBody != null) |
| | 2883 | | { |
| 0 | 2884 | | ex.Body = _errorBody; |
| | 2885 | | } |
| 0 | 2886 | | } |
| 0 | 2887 | | catch (JsonException) |
| | 2888 | | { |
| | 2889 | | // Ignore the exception |
| 0 | 2890 | | } |
| 0 | 2891 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2892 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2893 | | if (_shouldTrace) |
| | 2894 | | { |
| 0 | 2895 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2896 | | } |
| 0 | 2897 | | _httpRequest.Dispose(); |
| 0 | 2898 | | if (_httpResponse != null) |
| | 2899 | | { |
| 0 | 2900 | | _httpResponse.Dispose(); |
| | 2901 | | } |
| 0 | 2902 | | throw ex; |
| | 2903 | | } |
| | 2904 | | // Create Result |
| 0 | 2905 | | var _result = new AzureOperationResponse<IPage<CloudTask>,TaskListHeaders>(); |
| 0 | 2906 | | _result.Request = _httpRequest; |
| 0 | 2907 | | _result.Response = _httpResponse; |
| 0 | 2908 | | if (_httpResponse.Headers.Contains("request-id")) |
| | 2909 | | { |
| 0 | 2910 | | _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | 2911 | | } |
| | 2912 | | // Deserialize Response |
| 0 | 2913 | | if ((int)_statusCode == 200) |
| | 2914 | | { |
| 0 | 2915 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2916 | | try |
| | 2917 | | { |
| 0 | 2918 | | _result.Body = SafeJsonConvert.DeserializeObject<Page<CloudTask>>(_responseContent, Client.Deseriali |
| 0 | 2919 | | } |
| 0 | 2920 | | catch (JsonException ex) |
| | 2921 | | { |
| 0 | 2922 | | _httpRequest.Dispose(); |
| 0 | 2923 | | if (_httpResponse != null) |
| | 2924 | | { |
| 0 | 2925 | | _httpResponse.Dispose(); |
| | 2926 | | } |
| 0 | 2927 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2928 | | } |
| | 2929 | | } |
| | 2930 | | try |
| | 2931 | | { |
| 0 | 2932 | | _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<TaskListHeaders>(JsonSerializer.Create(Clien |
| 0 | 2933 | | } |
| 0 | 2934 | | catch (JsonException ex) |
| | 2935 | | { |
| 0 | 2936 | | _httpRequest.Dispose(); |
| 0 | 2937 | | if (_httpResponse != null) |
| | 2938 | | { |
| 0 | 2939 | | _httpResponse.Dispose(); |
| | 2940 | | } |
| 0 | 2941 | | throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson(). |
| | 2942 | | } |
| 0 | 2943 | | if (_shouldTrace) |
| | 2944 | | { |
| 0 | 2945 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2946 | | } |
| 0 | 2947 | | return _result; |
| 0 | 2948 | | } |
| | 2949 | |
|
| | 2950 | | } |
| | 2951 | | } |