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