| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. See License.txt in the project root for license information. |
| | | 3 | | |
| | | 4 | | namespace Microsoft.Azure.Batch |
| | | 5 | | { |
| | | 6 | | using System; |
| | | 7 | | using System.Collections; |
| | | 8 | | using System.Collections.Generic; |
| | | 9 | | using System.IO; |
| | | 10 | | using System.Linq; |
| | | 11 | | using System.Net.Http.Headers; |
| | | 12 | | using System.Reflection; |
| | | 13 | | using System.Threading; |
| | | 14 | | using System.Threading.Tasks; |
| | | 15 | | using Microsoft.Azure.Batch.Protocol; |
| | | 16 | | using Microsoft.Rest.Azure; |
| | | 17 | | using Protocol.BatchRequests; |
| | | 18 | | using Rest; |
| | | 19 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | | 20 | | |
| | | 21 | | internal class ProtocolLayer : IProtocolLayer |
| | | 22 | | { |
| | | 23 | | private Protocol.BatchServiceClient _client; |
| | | 24 | | private readonly bool _internalClient; |
| | | 25 | | |
| | | 26 | | private const int StreamCopyBufferSize = 4096; //This is the same as the default for Stream.CopyToAsync() |
| | | 27 | | |
| | | 28 | | private static Models.NodeFile CreateNodeFileFromHeadersType(string filePath, Models.IProtocolNodeFile protocolN |
| | | 29 | | { |
| | 12 | 30 | | Models.NodeFile file = new Models.NodeFile() |
| | 12 | 31 | | { |
| | 12 | 32 | | IsDirectory = protocolNodeFile.OcpBatchFileIsdirectory, |
| | 12 | 33 | | Name = filePath, |
| | 12 | 34 | | Properties = new Models.FileProperties() |
| | 12 | 35 | | { |
| | 12 | 36 | | ContentLength = protocolNodeFile.ContentLength.GetValueOrDefault(), |
| | 12 | 37 | | ContentType = protocolNodeFile.ContentType, |
| | 12 | 38 | | CreationTime = protocolNodeFile.OcpCreationTime, |
| | 12 | 39 | | LastModified = protocolNodeFile.LastModified.GetValueOrDefault(), |
| | 12 | 40 | | FileMode = protocolNodeFile.OcpBatchFileMode |
| | 12 | 41 | | }, |
| | 12 | 42 | | Url = protocolNodeFile.OcpBatchFileUrl |
| | 12 | 43 | | }; |
| | | 44 | | |
| | 12 | 45 | | return file; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | #region // constructors |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// instantiate based on creds and base url |
| | | 52 | | /// </summary> |
| | 138 | 53 | | internal ProtocolLayer(string baseUrl, ServiceClientCredentials credentials) |
| | | 54 | | { |
| | 138 | 55 | | this._client = new Protocol.BatchServiceClient(credentials); |
| | 138 | 56 | | this._client.BatchUrl = baseUrl; |
| | 138 | 57 | | this._client.HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(InternalConstants.Use |
| | | 58 | | |
| | 138 | 59 | | this._client.HttpClient.Timeout = Timeout.InfiniteTimeSpan; //Client side timeout will be set per-request |
| | 138 | 60 | | this._client.SetRetryPolicy(null); //Set the retry policy to null to turn off inner-client retries |
| | 138 | 61 | | this._internalClient = true; |
| | 138 | 62 | | } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// instantiate based on customer provided rest proxy |
| | | 66 | | /// </summary> |
| | | 67 | | /// <param name="clientToUse"></param> |
| | 9 | 68 | | internal ProtocolLayer(Protocol.BatchServiceClient clientToUse) |
| | | 69 | | { |
| | 9 | 70 | | this._client = clientToUse; |
| | 9 | 71 | | this._internalClient = false; |
| | 9 | 72 | | } |
| | | 73 | | |
| | | 74 | | #endregion // constructors |
| | | 75 | | |
| | | 76 | | #region // IProtocolLayer |
| | | 77 | | |
| | | 78 | | public Task<AzureOperationResponse<IPage<Models.CloudJobSchedule>, Models.JobScheduleListHeaders>> ListJobSchedu |
| | | 79 | | string skipToken, |
| | | 80 | | BehaviorManager bhMgr, |
| | | 81 | | DetailLevel detailLevel, |
| | | 82 | | CancellationToken cancellationToken) |
| | | 83 | | { |
| | | 84 | | Task<AzureOperationResponse<IPage<Models.CloudJobSchedule>, Models.JobScheduleListHeaders>> asyncTask; |
| | | 85 | | |
| | 4 | 86 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 87 | | { |
| | 3 | 88 | | var request = new JobScheduleListBatchRequest(this._client, cancellationToken); |
| | | 89 | | |
| | 3 | 90 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 91 | | |
| | 0 | 92 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ListWithHttpMessagesA |
| | 0 | 93 | | request.Options, request.CustomHeaders, lambdaCancelToken); |
| | 3 | 94 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 95 | | } |
| | | 96 | | else |
| | | 97 | | { |
| | 1 | 98 | | var request = new JobScheduleListNextBatchRequest(this._client, cancellationToken); |
| | | 99 | | |
| | 0 | 100 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ListNextWithHttpMessa |
| | 1 | 101 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 102 | | } |
| | | 103 | | |
| | 4 | 104 | | return asyncTask; |
| | | 105 | | } |
| | | 106 | | |
| | | 107 | | public Task<AzureOperationResponse<Models.CloudJobSchedule, Models.JobScheduleGetHeaders>> GetJobSchedule(string |
| | | 108 | | { |
| | 14 | 109 | | var request = new JobScheduleGetBatchRequest(this._client, cancellationToken); |
| | | 110 | | |
| | 15 | 111 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.GetWithHttpMessagesAsync( |
| | 15 | 112 | | jobScheduleId, |
| | 15 | 113 | | request.Options, |
| | 15 | 114 | | request.CustomHeaders, |
| | 15 | 115 | | lambdaCancelToken); |
| | | 116 | | |
| | 14 | 117 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 118 | | |
| | 14 | 119 | | return asyncTask; |
| | | 120 | | } |
| | | 121 | | |
| | | 122 | | public async Task<AzureOperationResponse<bool, Models.JobScheduleExistsHeaders>> JobScheduleExists(string jobSch |
| | | 123 | | { |
| | 0 | 124 | | var request = new JobScheduleExistsBatchRequest(this._client, cancellationToken); |
| | | 125 | | |
| | 0 | 126 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ExistsWithHttpMessagesAsy |
| | 0 | 127 | | jobScheduleId, |
| | 0 | 128 | | request.Options, |
| | 0 | 129 | | request.CustomHeaders, |
| | 0 | 130 | | lambdaCancelToken); |
| | | 131 | | |
| | 0 | 132 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 133 | | |
| | | 134 | | //Force disposal of the response because the HEAD request doesn't read the body stream, which leaves the con |
| | 0 | 135 | | using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false)) |
| | | 136 | | { |
| | 0 | 137 | | var result = new AzureOperationResponse<bool, Models.JobScheduleExistsHeaders>() |
| | 0 | 138 | | { |
| | 0 | 139 | | Body = response.Body, |
| | 0 | 140 | | RequestId = response.RequestId, |
| | 0 | 141 | | Headers = response.Headers |
| | 0 | 142 | | }; |
| | | 143 | | |
| | 0 | 144 | | return result; |
| | | 145 | | } |
| | 0 | 146 | | } |
| | | 147 | | |
| | | 148 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleAddHeaders>> AddJobSchedule(Models.JobScheduleAddPara |
| | | 149 | | { |
| | 3 | 150 | | var request = new JobScheduleAddBatchRequest(this._client, cloudJobSchedule, cancellationToken); |
| | | 151 | | |
| | 0 | 152 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.AddWithHttpMessagesAsync( |
| | 0 | 153 | | request.Parameters, |
| | 0 | 154 | | request.Options, |
| | 0 | 155 | | request.CustomHeaders, |
| | 0 | 156 | | lambdaCancelToken); |
| | | 157 | | |
| | 3 | 158 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 159 | | |
| | 3 | 160 | | return asyncTask; |
| | | 161 | | } |
| | | 162 | | |
| | | 163 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleUpdateHeaders>> UpdateJobSchedule( |
| | | 164 | | string jobScheduleId, |
| | | 165 | | Models.JobSpecification jobSpecification, |
| | | 166 | | IList<Models.MetadataItem> metadata, |
| | | 167 | | Models.Schedule schedule, |
| | | 168 | | BehaviorManager bhMgr, |
| | | 169 | | CancellationToken cancellationToken) |
| | | 170 | | { |
| | 0 | 171 | | var parameters = new Models.JobScheduleUpdateParameter(schedule, jobSpecification, metadata); |
| | 0 | 172 | | var request = new JobScheduleUpdateBatchRequest(this._client, parameters, cancellationToken); |
| | | 173 | | |
| | 0 | 174 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.UpdateWithHttpMessagesAsy |
| | 0 | 175 | | jobScheduleId, |
| | 0 | 176 | | request.Parameters, |
| | 0 | 177 | | request.Options, |
| | 0 | 178 | | request.CustomHeaders, |
| | 0 | 179 | | lambdaCancelToken); |
| | | 180 | | |
| | 0 | 181 | | Task<AzureOperationHeaderResponse<Models.JobScheduleUpdateHeaders>> asyncTask = ProcessAndExecuteBatchReques |
| | | 182 | | |
| | 0 | 183 | | return asyncTask; |
| | | 184 | | } |
| | | 185 | | |
| | | 186 | | public Task<AzureOperationHeaderResponse<Models.JobSchedulePatchHeaders>> PatchJobSchedule( |
| | | 187 | | string jobScheduleId, |
| | | 188 | | Models.JobSpecification jobSpecification, |
| | | 189 | | IList<Models.MetadataItem> metadata, |
| | | 190 | | Models.Schedule schedule, |
| | | 191 | | BehaviorManager bhMgr, |
| | | 192 | | CancellationToken cancellationToken) |
| | | 193 | | { |
| | 5 | 194 | | var parameters = new Models.JobSchedulePatchParameter(schedule, jobSpecification, metadata); |
| | 5 | 195 | | var request = new JobSchedulePatchBatchRequest(this._client, parameters, cancellationToken); |
| | | 196 | | |
| | 0 | 197 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.PatchWithHttpMessagesAsyn |
| | 0 | 198 | | jobScheduleId, |
| | 0 | 199 | | request.Parameters, |
| | 0 | 200 | | request.Options, |
| | 0 | 201 | | request.CustomHeaders, |
| | 0 | 202 | | lambdaCancelToken); |
| | | 203 | | |
| | 5 | 204 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 205 | | |
| | 5 | 206 | | return asyncTask; |
| | | 207 | | } |
| | | 208 | | |
| | | 209 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleEnableHeaders>> EnableJobSchedule(string jobScheduleI |
| | | 210 | | { |
| | 1 | 211 | | var request = new JobScheduleEnableBatchRequest(this._client, cancellationToken); |
| | | 212 | | |
| | 0 | 213 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.EnableWithHttpMessagesAsy |
| | 0 | 214 | | jobScheduleId, |
| | 0 | 215 | | request.Options, |
| | 0 | 216 | | request.CustomHeaders, |
| | 0 | 217 | | lambdaCancelToken); |
| | | 218 | | |
| | 1 | 219 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 220 | | |
| | 1 | 221 | | return asyncTask; |
| | | 222 | | } |
| | | 223 | | |
| | | 224 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleDisableHeaders>> DisableJobSchedule(string jobSchedul |
| | | 225 | | { |
| | 1 | 226 | | var request = new JobScheduleDisableBatchRequest(this._client, cancellationToken); |
| | | 227 | | |
| | 0 | 228 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.DisableWithHttpMessagesAs |
| | 0 | 229 | | jobScheduleId, |
| | 0 | 230 | | request.Options, |
| | 0 | 231 | | request.CustomHeaders, |
| | 0 | 232 | | lambdaCancelToken); |
| | | 233 | | |
| | 1 | 234 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 235 | | |
| | 1 | 236 | | return asyncTask; |
| | | 237 | | } |
| | | 238 | | |
| | | 239 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleTerminateHeaders>> TerminateJobSchedule(string jobSch |
| | | 240 | | { |
| | 1 | 241 | | var request = new JobScheduleTerminateBatchRequest(this._client, cancellationToken); |
| | | 242 | | |
| | 0 | 243 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.TerminateWithHttpMessages |
| | 0 | 244 | | jobScheduleId, |
| | 0 | 245 | | request.Options, |
| | 0 | 246 | | request.CustomHeaders, |
| | 0 | 247 | | lambdaCancelToken); |
| | | 248 | | |
| | 1 | 249 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 250 | | |
| | 1 | 251 | | return asyncTask; |
| | | 252 | | } |
| | | 253 | | |
| | | 254 | | public Task<AzureOperationHeaderResponse<Models.JobScheduleDeleteHeaders>> DeleteJobSchedule(string jobScheduleI |
| | | 255 | | { |
| | 1 | 256 | | var request = new JobScheduleDeleteBatchRequest(this._client, cancellationToken); |
| | | 257 | | |
| | 0 | 258 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.DeleteWithHttpMessagesAsy |
| | 0 | 259 | | jobScheduleId, |
| | 0 | 260 | | request.Options, |
| | 0 | 261 | | request.CustomHeaders, |
| | 0 | 262 | | lambdaCancelToken); |
| | | 263 | | |
| | 1 | 264 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 265 | | |
| | 1 | 266 | | return asyncTask; |
| | | 267 | | } |
| | | 268 | | |
| | | 269 | | public Task<AzureOperationHeaderResponse<Models.JobAddHeaders>> AddJob(Models.JobAddParameter job, BehaviorManag |
| | | 270 | | { |
| | 4 | 271 | | var request = new JobAddBatchRequest(this._client, job, cancellationToken); |
| | | 272 | | |
| | 0 | 273 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.AddWithHttpMessagesAsync( |
| | 0 | 274 | | request.Parameters, |
| | 0 | 275 | | request.Options, |
| | 0 | 276 | | request.CustomHeaders, |
| | 0 | 277 | | lambdaCancelToken); |
| | | 278 | | |
| | 4 | 279 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 280 | | |
| | 4 | 281 | | return asyncTask; |
| | | 282 | | } |
| | | 283 | | |
| | | 284 | | public Task<AzureOperationResponse<IPage<Models.CloudJob>, Models.JobListHeaders>> ListJobsAll(string skipToken, |
| | | 285 | | { |
| | | 286 | | Task<AzureOperationResponse<IPage<Models.CloudJob>, Models.JobListHeaders>> asyncTask; |
| | | 287 | | |
| | 4 | 288 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 289 | | { |
| | 3 | 290 | | var request = new JobListBatchRequest(this._client, cancellationToken); |
| | | 291 | | |
| | 3 | 292 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 293 | | |
| | 0 | 294 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListWithHttpMessagesAsync( |
| | 0 | 295 | | request.Options, |
| | 0 | 296 | | request.CustomHeaders, |
| | 0 | 297 | | lambdaCancelToken); |
| | 3 | 298 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 299 | | } |
| | | 300 | | else |
| | | 301 | | { |
| | 1 | 302 | | var request = new JobListNextBatchRequest(this._client, cancellationToken); |
| | | 303 | | |
| | 0 | 304 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListNextWithHttpMessagesAsync |
| | 1 | 305 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 306 | | } |
| | | 307 | | |
| | 4 | 308 | | return asyncTask; |
| | | 309 | | } |
| | | 310 | | |
| | | 311 | | public Task<AzureOperationResponse<IPage<Models.CloudJob>, Models.JobListFromJobScheduleHeaders>> ListJobsBySche |
| | | 312 | | string jobScheduleId, |
| | | 313 | | string skipToken, |
| | | 314 | | BehaviorManager bhMgr, |
| | | 315 | | DetailLevel detailLevel, |
| | | 316 | | CancellationToken cancellationToken) |
| | | 317 | | { |
| | | 318 | | Task<AzureOperationResponse<IPage<Models.CloudJob>, Models.JobListFromJobScheduleHeaders>> asyncTask; |
| | | 319 | | |
| | 2 | 320 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 321 | | { |
| | 1 | 322 | | var request = new JobListFromJobScheduleBatchRequest(this._client, cancellationToken); |
| | | 323 | | |
| | 1 | 324 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 325 | | |
| | 0 | 326 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListFromJobScheduleWithHttpMe |
| | 0 | 327 | | jobScheduleId, |
| | 0 | 328 | | request.Options, |
| | 0 | 329 | | request.CustomHeaders, |
| | 0 | 330 | | lambdaCancelToken); |
| | | 331 | | |
| | 1 | 332 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 333 | | } |
| | | 334 | | else |
| | | 335 | | { |
| | 1 | 336 | | var request = new JobListFromJobScheduleNextBatchRequest(this._client, cancellationToken); |
| | | 337 | | |
| | 0 | 338 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListFromJobScheduleNextWithHt |
| | 1 | 339 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 340 | | } |
| | | 341 | | |
| | 2 | 342 | | return asyncTask; |
| | | 343 | | } |
| | | 344 | | |
| | | 345 | | public Task<AzureOperationResponse<IPage<Models.JobPreparationAndReleaseTaskExecutionInformation>, Models.JobLis |
| | | 346 | | string jobId, |
| | | 347 | | string skipToken, |
| | | 348 | | BehaviorManager bhMgr, |
| | | 349 | | DetailLevel detailLevel, |
| | | 350 | | CancellationToken cancellationToken) |
| | | 351 | | { |
| | | 352 | | Task<AzureOperationResponse<IPage<Models.JobPreparationAndReleaseTaskExecutionInformation>, Models.JobListPr |
| | | 353 | | |
| | 3 | 354 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 355 | | { |
| | 2 | 356 | | var request = new JobListPreparationAndReleaseTaskStatusBatchRequest(this._client, cancellationToken); |
| | | 357 | | |
| | 2 | 358 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 359 | | |
| | 0 | 360 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListPreparationAndReleaseTask |
| | 0 | 361 | | jobId, |
| | 0 | 362 | | request.Options, |
| | 0 | 363 | | request.CustomHeaders, |
| | 0 | 364 | | lambdaCancelToken); |
| | | 365 | | |
| | 2 | 366 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 367 | | } |
| | | 368 | | else |
| | | 369 | | { |
| | 1 | 370 | | var request = new JobListPreparationAndReleaseTaskStatusNextBatchRequest(this._client, cancellationToken |
| | | 371 | | |
| | 0 | 372 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListPreparationAndReleaseTask |
| | 1 | 373 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 374 | | } |
| | | 375 | | |
| | 3 | 376 | | return asyncTask; |
| | | 377 | | } |
| | | 378 | | |
| | | 379 | | public Task<AzureOperationResponse<Models.CloudJob, Models.JobGetHeaders>> GetJob(string jobId, BehaviorManager |
| | | 380 | | { |
| | 29 | 381 | | var request = new JobGetBatchRequest(this._client, cancellationToken); |
| | | 382 | | |
| | 30 | 383 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetWithHttpMessagesAsync( |
| | 30 | 384 | | jobId, |
| | 30 | 385 | | request.Options, |
| | 30 | 386 | | request.CustomHeaders, |
| | 30 | 387 | | lambdaCancelToken); |
| | | 388 | | |
| | 29 | 389 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 390 | | |
| | 29 | 391 | | return asyncTask; |
| | | 392 | | } |
| | | 393 | | |
| | | 394 | | public Task<AzureOperationResponse<Models.TaskCounts, Models.JobGetTaskCountsHeaders>> GetJobTaskCounts(string j |
| | | 395 | | { |
| | 1 | 396 | | var request = new JobGetTaskCountsBatchRequest(this._client, cancellationToken); |
| | | 397 | | |
| | 0 | 398 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetTaskCountsWithHttpMessagesAsyn |
| | 0 | 399 | | jobId, |
| | 0 | 400 | | request.Options, |
| | 0 | 401 | | request.CustomHeaders, |
| | 0 | 402 | | lambdaCancelToken); |
| | | 403 | | |
| | 1 | 404 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 405 | | |
| | 1 | 406 | | return asyncTask; |
| | | 407 | | } |
| | | 408 | | |
| | | 409 | | public Task<AzureOperationHeaderResponse<Models.JobUpdateHeaders>> UpdateJob( |
| | | 410 | | string jobId, |
| | | 411 | | int? priority, |
| | | 412 | | Models.OnAllTasksComplete? onAllTasksComplete, |
| | | 413 | | Models.PoolInformation poolInfo, |
| | | 414 | | Models.JobConstraints constraints, |
| | | 415 | | IList<Models.MetadataItem> metadata, |
| | | 416 | | BehaviorManager bhMgr, |
| | | 417 | | CancellationToken cancellationToken) |
| | | 418 | | { |
| | 0 | 419 | | var parameters = new Models.JobUpdateParameter(poolInfo, priority, constraints, metadata, onAllTasksComplete |
| | 0 | 420 | | var request = new JobUpdateBatchRequest(this._client, parameters, cancellationToken); |
| | | 421 | | |
| | 0 | 422 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.UpdateWithHttpMessagesAsync( |
| | 0 | 423 | | jobId, |
| | 0 | 424 | | request.Parameters, |
| | 0 | 425 | | request.Options, |
| | 0 | 426 | | request.CustomHeaders, |
| | 0 | 427 | | lambdaCancelToken); |
| | | 428 | | |
| | 0 | 429 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 430 | | |
| | 0 | 431 | | return asyncTask; |
| | | 432 | | } |
| | | 433 | | |
| | | 434 | | public Task<AzureOperationHeaderResponse<Models.JobPatchHeaders>> PatchJob( |
| | | 435 | | string jobId, |
| | | 436 | | int? priority, |
| | | 437 | | Models.OnAllTasksComplete? onAllTasksComplete, |
| | | 438 | | Models.PoolInformation poolInfo, |
| | | 439 | | Models.JobConstraints constraints, |
| | | 440 | | IList<Models.MetadataItem> metadata, |
| | | 441 | | BehaviorManager bhMgr, |
| | | 442 | | CancellationToken cancellationToken) |
| | | 443 | | { |
| | 6 | 444 | | var parameters = new Models.JobPatchParameter(priority, onAllTasksComplete, constraints, poolInfo, metadata) |
| | 6 | 445 | | var request = new JobPatchBatchRequest(this._client, parameters, cancellationToken); |
| | | 446 | | |
| | 0 | 447 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.PatchWithHttpMessagesAsync( |
| | 0 | 448 | | jobId, |
| | 0 | 449 | | request.Parameters, |
| | 0 | 450 | | request.Options, |
| | 0 | 451 | | request.CustomHeaders, |
| | 0 | 452 | | lambdaCancelToken); |
| | | 453 | | |
| | 6 | 454 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 455 | | |
| | 6 | 456 | | return asyncTask; |
| | | 457 | | } |
| | | 458 | | |
| | | 459 | | public Task<AzureOperationHeaderResponse<Models.JobEnableHeaders>> EnableJob(string jobId, BehaviorManager bhMgr |
| | | 460 | | { |
| | 1 | 461 | | var request = new JobEnableBatchRequest(this._client, cancellationToken); |
| | | 462 | | |
| | 0 | 463 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.EnableWithHttpMessagesAsync( |
| | 0 | 464 | | jobId, |
| | 0 | 465 | | request.Options, |
| | 0 | 466 | | request.CustomHeaders, |
| | 0 | 467 | | lambdaCancelToken); |
| | | 468 | | |
| | 1 | 469 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 470 | | |
| | 1 | 471 | | return asyncTask; |
| | | 472 | | } |
| | | 473 | | |
| | | 474 | | public Task<AzureOperationHeaderResponse<Models.JobDisableHeaders>> DisableJob(string jobId, Common.DisableJobOp |
| | | 475 | | { |
| | 1 | 476 | | var parameter = UtilitiesInternal.MapEnum<Common.DisableJobOption, Protocol.Models.DisableJobOption>(disable |
| | 1 | 477 | | var request = new JobDisableBatchRequest(this._client, parameter, cancellationToken); |
| | | 478 | | |
| | 0 | 479 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.DisableWithHttpMessagesAsync( |
| | 0 | 480 | | jobId, |
| | 0 | 481 | | request.Parameters, |
| | 0 | 482 | | request.Options, |
| | 0 | 483 | | request.CustomHeaders, |
| | 0 | 484 | | lambdaCancelToken); |
| | | 485 | | |
| | 1 | 486 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 487 | | |
| | 1 | 488 | | return asyncTask; |
| | | 489 | | } |
| | | 490 | | |
| | | 491 | | public Task<AzureOperationHeaderResponse<Models.JobTerminateHeaders>> TerminateJob(string jobId, string terminat |
| | | 492 | | { |
| | 1 | 493 | | var parameters = terminateReason; |
| | 1 | 494 | | var request = new JobTerminateBatchRequest(this._client, parameters, cancellationToken); |
| | | 495 | | |
| | 0 | 496 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.TerminateWithHttpMessagesAsync( |
| | 0 | 497 | | jobId, |
| | 0 | 498 | | request.Parameters, |
| | 0 | 499 | | request.Options, |
| | 0 | 500 | | request.CustomHeaders, |
| | 0 | 501 | | lambdaCancelToken); |
| | | 502 | | |
| | 1 | 503 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 504 | | |
| | 1 | 505 | | return asyncTask; |
| | | 506 | | } |
| | | 507 | | |
| | | 508 | | public Task<AzureOperationHeaderResponse<Models.JobDeleteHeaders>> DeleteJob(string jobId, BehaviorManager bhMgr |
| | | 509 | | { |
| | 1 | 510 | | var request = new JobDeleteBatchRequest(this._client, cancellationToken); |
| | | 511 | | |
| | 0 | 512 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.DeleteWithHttpMessagesAsync( |
| | 0 | 513 | | jobId, |
| | 0 | 514 | | request.Options, |
| | 0 | 515 | | request.CustomHeaders, |
| | 0 | 516 | | lambdaCancelToken); |
| | | 517 | | |
| | 1 | 518 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 519 | | |
| | 1 | 520 | | return asyncTask; |
| | | 521 | | } |
| | | 522 | | |
| | | 523 | | public Task<AzureOperationResponse<IPage<Models.CloudTask>, Models.TaskListHeaders>> ListTasks(string jobId, str |
| | | 524 | | { |
| | | 525 | | Task<AzureOperationResponse<IPage<Models.CloudTask>, Models.TaskListHeaders>> asyncTask; |
| | | 526 | | |
| | 7 | 527 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 528 | | { |
| | 6 | 529 | | var request = new TaskListBatchRequest(this._client, cancellationToken); |
| | | 530 | | |
| | 6 | 531 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 532 | | |
| | 0 | 533 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListWithHttpMessagesAsync( |
| | 0 | 534 | | jobId, |
| | 0 | 535 | | request.Options, |
| | 0 | 536 | | request.CustomHeaders, |
| | 0 | 537 | | lambdaCancelToken); |
| | | 538 | | |
| | 6 | 539 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 540 | | } |
| | | 541 | | else |
| | | 542 | | { |
| | 1 | 543 | | var request = new TaskListNextBatchRequest(this._client, cancellationToken); |
| | | 544 | | |
| | 0 | 545 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListNextWithHttpMessagesAsyn |
| | 1 | 546 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 547 | | } |
| | | 548 | | |
| | 7 | 549 | | return asyncTask; |
| | | 550 | | } |
| | | 551 | | |
| | | 552 | | public Task<AzureOperationResponse<IPage<Models.NodeFile>, Models.FileListFromTaskHeaders>> ListNodeFilesByTask( |
| | | 553 | | string jobId, |
| | | 554 | | string taskId, |
| | | 555 | | bool? recursive, |
| | | 556 | | string skipToken, |
| | | 557 | | BehaviorManager bhMgr, |
| | | 558 | | DetailLevel detailLevel, |
| | | 559 | | CancellationToken cancellationToken) |
| | | 560 | | { |
| | | 561 | | Task<AzureOperationResponse<IPage<Models.NodeFile>, Models.FileListFromTaskHeaders>> asyncTask; |
| | | 562 | | |
| | 1 | 563 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 564 | | { |
| | 1 | 565 | | var request = new FileListFromTaskBatchRequest(this._client, recursive, cancellationToken); |
| | | 566 | | |
| | 1 | 567 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 568 | | |
| | 0 | 569 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromTaskWithHttpMessages |
| | 0 | 570 | | jobId, |
| | 0 | 571 | | taskId, |
| | 0 | 572 | | request.Parameters, |
| | 0 | 573 | | request.Options, |
| | 0 | 574 | | request.CustomHeaders, |
| | 0 | 575 | | lambdaCancelToken); |
| | | 576 | | |
| | 1 | 577 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 578 | | } |
| | | 579 | | else |
| | | 580 | | { |
| | 0 | 581 | | var request = new FileListFromTaskNextBatchRequest(this._client, cancellationToken); |
| | | 582 | | |
| | 0 | 583 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromTaskNextWithHttpMess |
| | 0 | 584 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 585 | | } |
| | | 586 | | |
| | 1 | 587 | | return asyncTask; |
| | | 588 | | } |
| | | 589 | | |
| | | 590 | | public Task<AzureOperationResponse<Models.CloudTask, Models.TaskGetHeaders>> GetTask(string jobId, string taskId |
| | | 591 | | { |
| | 3 | 592 | | var request = new TaskGetBatchRequest(this._client, cancellationToken); |
| | | 593 | | |
| | 0 | 594 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.GetWithHttpMessagesAsync( |
| | 0 | 595 | | jobId, |
| | 0 | 596 | | taskId, |
| | 0 | 597 | | request.Options, |
| | 0 | 598 | | request.CustomHeaders, |
| | 0 | 599 | | lambdaCancelToken); |
| | | 600 | | |
| | 3 | 601 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 602 | | |
| | 3 | 603 | | return asyncTask; |
| | | 604 | | } |
| | | 605 | | |
| | | 606 | | public Task<AzureOperationResponse<Models.CloudTaskListSubtasksResult, Models.TaskListSubtasksHeaders>> ListSubt |
| | | 607 | | string jobId, |
| | | 608 | | string taskId, |
| | | 609 | | string skipToken, |
| | | 610 | | BehaviorManager bhMgr, |
| | | 611 | | DetailLevel detailLevel, |
| | | 612 | | CancellationToken cancellationToken) |
| | | 613 | | { |
| | | 614 | | Task<AzureOperationResponse<Models.CloudTaskListSubtasksResult, Models.TaskListSubtasksHeaders>> asyncTask; |
| | | 615 | | |
| | 1 | 616 | | var request = new TaskListSubtasksBatchRequest(this._client, cancellationToken); |
| | | 617 | | |
| | 1 | 618 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 619 | | |
| | 0 | 620 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListSubtasksWithHttpMessagesAsyn |
| | 0 | 621 | | jobId, |
| | 0 | 622 | | taskId, |
| | 0 | 623 | | request.Options, |
| | 0 | 624 | | request.CustomHeaders, |
| | 0 | 625 | | lambdaCancelToken); |
| | | 626 | | |
| | 1 | 627 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 628 | | |
| | | 629 | | //TODO: This branch exists in the hope that one day there will be a skiptoken for this API. |
| | | 630 | | //if (string.IsNullOrEmpty(skipToken)) |
| | | 631 | | //{ |
| | | 632 | | |
| | | 633 | | //} |
| | | 634 | | //else |
| | | 635 | | //{ |
| | | 636 | | // var request = new TaskListSubtasksNextBatchRequest(this._client, cancellationToken); |
| | | 637 | | // request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListSubtasksNextWithHttpMe |
| | | 638 | | // asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 639 | | //} |
| | | 640 | | |
| | 1 | 641 | | return asyncTask; |
| | | 642 | | } |
| | | 643 | | |
| | | 644 | | // BUGBUG: TODO: fix this up with ranged GETs or whatever... |
| | | 645 | | public async Task<AzureOperationResponse<Models.NodeFile, Models.FileGetFromTaskHeaders>> GetNodeFileByTask( |
| | | 646 | | string jobId, |
| | | 647 | | string taskId, |
| | | 648 | | string filePath, |
| | | 649 | | Stream stream, |
| | | 650 | | GetFileRequestByteRange byteRange, |
| | | 651 | | BehaviorManager bhMgr, |
| | | 652 | | CancellationToken cancellationToken) |
| | | 653 | | { |
| | 5 | 654 | | var request = new FileGetFromTaskBatchRequest(this._client, cancellationToken); |
| | | 655 | | |
| | 5 | 656 | | if (byteRange != null) |
| | | 657 | | { |
| | 2 | 658 | | request.Options.OcpRange = byteRange.GetOcpRangeHeader(); |
| | | 659 | | } |
| | | 660 | | |
| | 6 | 661 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetFromTaskWithHttpMessagesAsync |
| | 6 | 662 | | jobId, |
| | 6 | 663 | | taskId, |
| | 6 | 664 | | filePath, |
| | 6 | 665 | | request.Options, |
| | 6 | 666 | | request.CustomHeaders, |
| | 6 | 667 | | lambdaCancelToken); |
| | | 668 | | |
| | 5 | 669 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 670 | | |
| | 5 | 671 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | | 672 | | |
| | 3 | 673 | | await CopyStreamAsync(response.Body, stream, cancellationToken).ConfigureAwait(continueOnCapturedContext: fa |
| | | 674 | | |
| | 3 | 675 | | var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetFromTaskHeaders>() |
| | 3 | 676 | | { |
| | 3 | 677 | | Body = CreateNodeFileFromHeadersType(filePath, response.Headers), |
| | 3 | 678 | | RequestId = response.RequestId, |
| | 3 | 679 | | Headers = response.Headers, |
| | 3 | 680 | | }; |
| | | 681 | | |
| | 3 | 682 | | return result; |
| | 3 | 683 | | } |
| | | 684 | | |
| | | 685 | | public async Task<AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromTaskHeaders>> GetNodeFileP |
| | | 686 | | string jobId, |
| | | 687 | | string taskId, |
| | | 688 | | string filePath, |
| | | 689 | | BehaviorManager bhMgr, |
| | | 690 | | CancellationToken cancellationToken) |
| | | 691 | | { |
| | 4 | 692 | | var request = new FileGetNodeFilePropertiesFromTaskBatchRequest(this._client, cancellationToken); |
| | | 693 | | |
| | 5 | 694 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetPropertiesFromTaskWithHttpMes |
| | 5 | 695 | | jobId, |
| | 5 | 696 | | taskId, |
| | 5 | 697 | | filePath, |
| | 5 | 698 | | request.Options, |
| | 5 | 699 | | request.CustomHeaders, |
| | 5 | 700 | | lambdaCancelToken); |
| | | 701 | | |
| | 4 | 702 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 703 | | |
| | | 704 | | //Force disposal of the response because the HEAD request doesn't read the body stream, which leaves the con |
| | 4 | 705 | | using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false)) |
| | | 706 | | { |
| | 3 | 707 | | var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromTaskHeaders>() |
| | 3 | 708 | | { |
| | 3 | 709 | | Body = CreateNodeFileFromHeadersType(filePath, response.Headers), |
| | 3 | 710 | | RequestId = response.RequestId, |
| | 3 | 711 | | Headers = response.Headers, |
| | 3 | 712 | | }; |
| | | 713 | | |
| | 3 | 714 | | return result; |
| | | 715 | | } |
| | 3 | 716 | | } |
| | | 717 | | |
| | | 718 | | public Task<AzureOperationHeaderResponse<Models.TaskAddHeaders>> AddTask(string jobId, Models.TaskAddParameter t |
| | | 719 | | { |
| | 8 | 720 | | var request = new TaskAddBatchRequest(this._client, task, cancellationToken); |
| | | 721 | | |
| | 0 | 722 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.AddWithHttpMessagesAsync( |
| | 0 | 723 | | jobId, |
| | 0 | 724 | | request.Parameters, |
| | 0 | 725 | | request.Options, |
| | 0 | 726 | | request.CustomHeaders, |
| | 0 | 727 | | lambdaCancelToken); |
| | | 728 | | |
| | 8 | 729 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 730 | | |
| | 8 | 731 | | return asyncTask; |
| | | 732 | | } |
| | | 733 | | |
| | | 734 | | public Task<AzureOperationHeaderResponse<Models.TaskTerminateHeaders>> TerminateTask(string jobId, string taskId |
| | | 735 | | { |
| | 1 | 736 | | var request = new TaskTerminateBatchRequest(this._client, cancellationToken); |
| | | 737 | | |
| | 0 | 738 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.TerminateWithHttpMessagesAsync( |
| | 0 | 739 | | jobId, |
| | 0 | 740 | | taskId, |
| | 0 | 741 | | request.Options, |
| | 0 | 742 | | request.CustomHeaders, |
| | 0 | 743 | | lambdaCancelToken); |
| | | 744 | | |
| | 1 | 745 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 746 | | |
| | 1 | 747 | | return asyncTask; |
| | | 748 | | } |
| | | 749 | | |
| | | 750 | | public Task<AzureOperationHeaderResponse<Models.TaskDeleteHeaders>> DeleteTask(string jobId, string taskId, Beha |
| | | 751 | | { |
| | 1 | 752 | | var request = new TaskDeleteBatchRequest(this._client, cancellationToken); |
| | | 753 | | |
| | 0 | 754 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.DeleteWithHttpMessagesAsync( |
| | 0 | 755 | | jobId, |
| | 0 | 756 | | taskId, |
| | 0 | 757 | | request.Options, |
| | 0 | 758 | | request.CustomHeaders, |
| | 0 | 759 | | lambdaCancelToken); |
| | | 760 | | |
| | 1 | 761 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 762 | | |
| | 1 | 763 | | return asyncTask; |
| | | 764 | | } |
| | | 765 | | |
| | | 766 | | public Task<AzureOperationHeaderResponse<Models.TaskReactivateHeaders>> ReactivateTask(string jobId, string task |
| | | 767 | | { |
| | 1 | 768 | | var request = new TaskReactivateBatchRequest(this._client, cancellationToken); |
| | | 769 | | |
| | 0 | 770 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ReactivateWithHttpMessagesAsync( |
| | 0 | 771 | | jobId, |
| | 0 | 772 | | taskId, |
| | 0 | 773 | | request.Options, |
| | 0 | 774 | | request.CustomHeaders, |
| | 0 | 775 | | lambdaCancelToken); |
| | | 776 | | |
| | 1 | 777 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 778 | | |
| | 1 | 779 | | return asyncTask; |
| | | 780 | | } |
| | | 781 | | |
| | | 782 | | |
| | | 783 | | public Task<AzureOperationResponse<IPage<Models.CloudPool>, Models.PoolListHeaders>> ListPools(string skipToken, |
| | | 784 | | { |
| | | 785 | | Task<AzureOperationResponse<IPage<Models.CloudPool>, Models.PoolListHeaders>> asyncTask; |
| | | 786 | | |
| | 4 | 787 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 788 | | { |
| | 3 | 789 | | var request = new PoolListBatchRequest(this._client, cancellationToken); |
| | | 790 | | |
| | 3 | 791 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 792 | | |
| | 0 | 793 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListWithHttpMessagesAsync( |
| | 0 | 794 | | request.Options, |
| | 0 | 795 | | request.CustomHeaders, |
| | 0 | 796 | | lambdaCancelToken); |
| | 3 | 797 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 798 | | } |
| | | 799 | | else |
| | | 800 | | { |
| | 1 | 801 | | var request = new PoolListNextBatchRequest(this._client, cancellationToken); |
| | | 802 | | |
| | 0 | 803 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListNextWithHttpMessagesAsyn |
| | 1 | 804 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 805 | | } |
| | | 806 | | |
| | 4 | 807 | | return asyncTask; |
| | | 808 | | } |
| | | 809 | | |
| | | 810 | | public Task<AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders>> GetPool(string poolId, BehaviorMana |
| | | 811 | | { |
| | 31 | 812 | | var request = new PoolGetBatchRequest(this._client, cancellationToken); |
| | | 813 | | |
| | 32 | 814 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.GetWithHttpMessagesAsync( |
| | 32 | 815 | | poolId, |
| | 32 | 816 | | request.Options, |
| | 32 | 817 | | request.CustomHeaders, |
| | 32 | 818 | | lambdaCancelToken); |
| | | 819 | | |
| | 31 | 820 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 821 | | |
| | 31 | 822 | | return asyncTask; |
| | | 823 | | } |
| | | 824 | | |
| | | 825 | | public async Task<AzureOperationResponse<bool, Models.PoolExistsHeaders>> PoolExists(string poolId, BehaviorMana |
| | | 826 | | { |
| | 0 | 827 | | var request = new PoolExistsBatchRequest(this._client, cancellationToken); |
| | | 828 | | |
| | 0 | 829 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ExistsWithHttpMessagesAsync( |
| | 0 | 830 | | poolId, |
| | 0 | 831 | | request.Options, |
| | 0 | 832 | | request.CustomHeaders, |
| | 0 | 833 | | lambdaCancelToken); |
| | | 834 | | |
| | 0 | 835 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 836 | | //Force disposal of the response because the HEAD request doesn't read the body stream, which leaves the con |
| | 0 | 837 | | using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false)) |
| | | 838 | | { |
| | 0 | 839 | | var result = new AzureOperationResponse<bool, Models.PoolExistsHeaders>() |
| | 0 | 840 | | { |
| | 0 | 841 | | Body = response.Body, |
| | 0 | 842 | | RequestId = response.RequestId, |
| | 0 | 843 | | Headers = response.Headers |
| | 0 | 844 | | }; |
| | | 845 | | |
| | 0 | 846 | | return result; |
| | | 847 | | } |
| | 0 | 848 | | } |
| | | 849 | | |
| | | 850 | | public Task<AzureOperationHeaderResponse<Models.PoolAddHeaders>> AddPool(Models.PoolAddParameter pool, BehaviorM |
| | | 851 | | { |
| | 3 | 852 | | var request = new PoolAddBatchRequest(this._client, pool, cancellationToken); |
| | | 853 | | |
| | 0 | 854 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.AddWithHttpMessagesAsync( |
| | 0 | 855 | | request.Parameters, |
| | 0 | 856 | | request.Options, |
| | 0 | 857 | | request.CustomHeaders, |
| | 0 | 858 | | lambdaCancelToken); |
| | | 859 | | |
| | 3 | 860 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 861 | | |
| | 3 | 862 | | return asyncTask; |
| | | 863 | | } |
| | | 864 | | |
| | | 865 | | public Task<AzureOperationHeaderResponse<Models.PoolUpdatePropertiesHeaders>> UpdatePool( |
| | | 866 | | string poolId, |
| | | 867 | | Models.StartTask startTask, |
| | | 868 | | Models.CertificateReference[] certRefs, |
| | | 869 | | Models.ApplicationPackageReference[] applicationPackageReferences, |
| | | 870 | | Models.MetadataItem[] metaData, |
| | | 871 | | BehaviorManager bhMgr, |
| | | 872 | | CancellationToken cancellationToken) |
| | | 873 | | { |
| | | 874 | | // The REST API for UpdatePool for some reason requires mapping null to empty lists even though no other upd |
| | | 875 | | // According to Pradeep this is fixed in OData 4 |
| | 1 | 876 | | certRefs = certRefs ?? new Models.CertificateReference[0]; |
| | 1 | 877 | | metaData = metaData ?? new Models.MetadataItem[0]; |
| | 1 | 878 | | applicationPackageReferences = applicationPackageReferences ?? new Models.ApplicationPackageReference[0]; |
| | | 879 | | |
| | 1 | 880 | | var parameters = new Models.PoolUpdatePropertiesParameter(certRefs, applicationPackageReferences, metaData, |
| | 1 | 881 | | var request = new PoolUpdatePropertiesBatchRequest(this._client, parameters, cancellationToken); |
| | | 882 | | |
| | 0 | 883 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.UpdatePropertiesWithHttpMessages |
| | 0 | 884 | | poolId, |
| | 0 | 885 | | request.Parameters, |
| | 0 | 886 | | request.Options, |
| | 0 | 887 | | request.CustomHeaders, |
| | 0 | 888 | | lambdaCancelToken); |
| | | 889 | | |
| | 1 | 890 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 891 | | |
| | 1 | 892 | | return asyncTask; |
| | | 893 | | } |
| | | 894 | | |
| | | 895 | | public Task<AzureOperationHeaderResponse<Models.PoolPatchHeaders>> PatchPool( |
| | | 896 | | string poolId, |
| | | 897 | | Models.StartTask startTask, |
| | | 898 | | Models.CertificateReference[] certificateReferences, |
| | | 899 | | Models.ApplicationPackageReference[] applicationPackageReferences, |
| | | 900 | | Models.MetadataItem[] metadata, |
| | | 901 | | BehaviorManager bhMgr, |
| | | 902 | | CancellationToken cancellationToken) |
| | | 903 | | { |
| | 5 | 904 | | var parameters = new Models.PoolPatchParameter(startTask, certificateReferences, applicationPackageReference |
| | 5 | 905 | | var request = new PoolPatchBatchRequest(this._client, parameters, cancellationToken); |
| | | 906 | | |
| | 0 | 907 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.PatchWithHttpMessagesAsync( |
| | 0 | 908 | | poolId, |
| | 0 | 909 | | request.Parameters, |
| | 0 | 910 | | request.Options, |
| | 0 | 911 | | request.CustomHeaders, |
| | 0 | 912 | | lambdaCancelToken); |
| | | 913 | | |
| | 5 | 914 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 915 | | |
| | 5 | 916 | | return asyncTask; |
| | | 917 | | } |
| | | 918 | | |
| | | 919 | | public Task<AzureOperationHeaderResponse<Models.PoolDeleteHeaders>> DeletePool(string poolId, BehaviorManager bh |
| | | 920 | | { |
| | 5 | 921 | | var request = new PoolDeleteBatchRequest(this._client, cancellationToken); |
| | | 922 | | |
| | 9 | 923 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.DeleteWithHttpMessagesAsync( |
| | 9 | 924 | | poolId, |
| | 9 | 925 | | request.Options, |
| | 9 | 926 | | request.CustomHeaders, |
| | 9 | 927 | | lambdaCancelToken); |
| | | 928 | | |
| | 5 | 929 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 930 | | |
| | 5 | 931 | | return asyncTask; |
| | | 932 | | } |
| | | 933 | | |
| | | 934 | | public Task<AzureOperationHeaderResponse<Models.PoolResizeHeaders>> ResizePool( |
| | | 935 | | string poolId, |
| | | 936 | | int? targetDedicatedComputeNodes, |
| | | 937 | | int? targetLowPriorityComputeNodes, |
| | | 938 | | TimeSpan? resizeTimeout, |
| | | 939 | | Common.ComputeNodeDeallocationOption? deallocationOption, |
| | | 940 | | BehaviorManager bhMgr, |
| | | 941 | | CancellationToken cancellationToken) |
| | | 942 | | { |
| | 1 | 943 | | var parameters = new Models.PoolResizeParameter( |
| | 1 | 944 | | targetDedicatedComputeNodes, |
| | 1 | 945 | | targetLowPriorityComputeNodes, |
| | 1 | 946 | | resizeTimeout, |
| | 1 | 947 | | UtilitiesInternal.MapNullableEnum<Common.ComputeNodeDeallocationOption, Protocol.Models.ComputeNodeDeall |
| | | 948 | | |
| | 1 | 949 | | var request = new PoolResizeBatchRequest(this._client, parameters, cancellationToken); |
| | | 950 | | |
| | 0 | 951 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ResizeWithHttpMessagesAsync( |
| | 0 | 952 | | poolId, |
| | 0 | 953 | | request.Parameters, |
| | 0 | 954 | | request.Options, |
| | 0 | 955 | | request.CustomHeaders, |
| | 0 | 956 | | lambdaCancelToken); |
| | | 957 | | |
| | 1 | 958 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 959 | | |
| | 1 | 960 | | return asyncTask; |
| | | 961 | | } |
| | | 962 | | |
| | | 963 | | public Task<AzureOperationHeaderResponse<Models.PoolStopResizeHeaders>> StopResizePool(string poolId, BehaviorMa |
| | | 964 | | { |
| | 1 | 965 | | var request = new PoolStopResizeBatchRequest(this._client, cancellationToken); |
| | | 966 | | |
| | 0 | 967 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.StopResizeWithHttpMessagesAsync( |
| | 0 | 968 | | poolId, |
| | 0 | 969 | | request.Options, |
| | 0 | 970 | | request.CustomHeaders, |
| | 0 | 971 | | lambdaCancelToken); |
| | | 972 | | |
| | 1 | 973 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 974 | | |
| | 1 | 975 | | return asyncTask; |
| | | 976 | | } |
| | | 977 | | |
| | | 978 | | public Task<AzureOperationHeaderResponse<Models.PoolEnableAutoScaleHeaders>> EnableAutoScale( |
| | | 979 | | string poolId, |
| | | 980 | | string autoscaleFormula, |
| | | 981 | | TimeSpan? autoscaleEvaluationInterval, |
| | | 982 | | BehaviorManager bhMgr, |
| | | 983 | | CancellationToken cancellationToken) |
| | | 984 | | { |
| | 1 | 985 | | var parameters = new Models.PoolEnableAutoScaleParameter(autoscaleFormula, autoscaleEvaluationInterval); |
| | 1 | 986 | | var request = new PoolEnableAutoScaleBatchRequest(this._client, parameters, cancellationToken); |
| | | 987 | | |
| | 0 | 988 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.EnableAutoScaleWithHttpMessagesA |
| | 0 | 989 | | poolId, |
| | 0 | 990 | | request.Parameters, |
| | 0 | 991 | | request.Options, |
| | 0 | 992 | | request.CustomHeaders, |
| | 0 | 993 | | lambdaCancelToken); |
| | | 994 | | |
| | 1 | 995 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 996 | | |
| | 1 | 997 | | return asyncTask; |
| | | 998 | | } |
| | | 999 | | |
| | | 1000 | | public Task<AzureOperationHeaderResponse<Models.PoolDisableAutoScaleHeaders>> DisableAutoScale(string poolId, Be |
| | | 1001 | | { |
| | 1 | 1002 | | var request = new PoolDisableAutoScaleBatchRequest(this._client, cancellationToken); |
| | | 1003 | | |
| | 0 | 1004 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.DisableAutoScaleWithHttpMessages |
| | 0 | 1005 | | poolId, |
| | 0 | 1006 | | request.Options, |
| | 0 | 1007 | | request.CustomHeaders, |
| | 0 | 1008 | | lambdaCancelToken); |
| | | 1009 | | |
| | 1 | 1010 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1011 | | |
| | 1 | 1012 | | return asyncTask; |
| | | 1013 | | } |
| | | 1014 | | |
| | | 1015 | | public Task<AzureOperationResponse<Models.AutoScaleRun, Models.PoolEvaluateAutoScaleHeaders>> EvaluateAutoScale( |
| | | 1016 | | { |
| | 1 | 1017 | | var parameters = autoscaleFomula; |
| | 1 | 1018 | | var request = new PoolEvaluateAutoScaleBatchRequest(this._client, parameters, cancellationToken); |
| | | 1019 | | |
| | 0 | 1020 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.EvaluateAutoScaleWithHttpMessage |
| | 0 | 1021 | | poolId, |
| | 0 | 1022 | | autoscaleFomula, |
| | 0 | 1023 | | request.Options, |
| | 0 | 1024 | | request.CustomHeaders, |
| | 0 | 1025 | | lambdaCancelToken); |
| | | 1026 | | |
| | 1 | 1027 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1028 | | |
| | 1 | 1029 | | return asyncTask; |
| | | 1030 | | } |
| | | 1031 | | |
| | | 1032 | | public Task<AzureOperationResponse<IPage<Models.ComputeNode>, Models.ComputeNodeListHeaders>> ListComputeNodes( |
| | | 1033 | | string poolId, |
| | | 1034 | | string skipToken, |
| | | 1035 | | BehaviorManager bhMgr, |
| | | 1036 | | DetailLevel detailLevel, |
| | | 1037 | | CancellationToken cancellationToken) |
| | | 1038 | | { |
| | | 1039 | | Task<AzureOperationResponse<IPage<Models.ComputeNode>, Models.ComputeNodeListHeaders>> asyncTask; |
| | | 1040 | | |
| | | 1041 | | |
| | 4 | 1042 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1043 | | { |
| | 3 | 1044 | | var request = new ComputeNodeListBatchRequest(this._client, cancellationToken); |
| | | 1045 | | |
| | 3 | 1046 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1047 | | |
| | 0 | 1048 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ListWithHttpMessagesA |
| | 0 | 1049 | | poolId, |
| | 0 | 1050 | | request.Options, |
| | 0 | 1051 | | request.CustomHeaders, |
| | 0 | 1052 | | lambdaCancelToken); |
| | | 1053 | | |
| | 3 | 1054 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1055 | | } |
| | | 1056 | | else |
| | | 1057 | | { |
| | 1 | 1058 | | var request = new ComputeNodeListNextBatchRequest(this._client, cancellationToken); |
| | 0 | 1059 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ListNextWithHttpMessa |
| | | 1060 | | |
| | 1 | 1061 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1062 | | } |
| | | 1063 | | |
| | 4 | 1064 | | return asyncTask; |
| | | 1065 | | } |
| | | 1066 | | |
| | | 1067 | | public Task<AzureOperationHeaderResponse<Models.PoolRemoveNodesHeaders>> RemovePoolComputeNodes( |
| | | 1068 | | string poolId, |
| | | 1069 | | IEnumerable<string> computeNodeIds, |
| | | 1070 | | Common.ComputeNodeDeallocationOption? deallocationOption, |
| | | 1071 | | TimeSpan? resizeTimeout, |
| | | 1072 | | BehaviorManager bhMgr, |
| | | 1073 | | CancellationToken cancellationToken) |
| | | 1074 | | { |
| | | 1075 | | //TODO: Ideally we wouldn't have to do this ToList stuff |
| | 2 | 1076 | | List<string> computeNodeIdList = computeNodeIds == null ? null : computeNodeIds.ToList(); |
| | 2 | 1077 | | var parameters = new Models.NodeRemoveParameter( |
| | 2 | 1078 | | computeNodeIdList, |
| | 2 | 1079 | | resizeTimeout, |
| | 2 | 1080 | | UtilitiesInternal.MapNullableEnum<Common.ComputeNodeDeallocationOption, Protocol.Models.ComputeNodeDeall |
| | | 1081 | | |
| | 2 | 1082 | | var request = new PoolRemoveNodesBatchRequest(this._client, parameters, cancellationToken); |
| | | 1083 | | |
| | 0 | 1084 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.RemoveNodesWithHttpMessagesAsync |
| | 0 | 1085 | | poolId, |
| | 0 | 1086 | | request.Parameters, |
| | 0 | 1087 | | request.Options, |
| | 0 | 1088 | | request.CustomHeaders, |
| | 0 | 1089 | | lambdaCancelToken); |
| | | 1090 | | |
| | 2 | 1091 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1092 | | |
| | 2 | 1093 | | return asyncTask; |
| | | 1094 | | } |
| | | 1095 | | |
| | | 1096 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeAddUserHeaders>> AddComputeNodeUser(string poolId, st |
| | | 1097 | | { |
| | 0 | 1098 | | var request = new ComputeNodeAddUserBatchRequest(this._client, protoUser, cancellationToken); |
| | | 1099 | | |
| | 0 | 1100 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.AddUserWithHttpMessagesAs |
| | 0 | 1101 | | poolId, |
| | 0 | 1102 | | computeNodeId, |
| | 0 | 1103 | | request.Parameters, |
| | 0 | 1104 | | request.Options, |
| | 0 | 1105 | | request.CustomHeaders, |
| | 0 | 1106 | | lambdaCancelToken); |
| | | 1107 | | |
| | 0 | 1108 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1109 | | |
| | 0 | 1110 | | return asyncTask; |
| | | 1111 | | } |
| | | 1112 | | |
| | | 1113 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeUpdateUserHeaders>> UpdateComputeNodeUser( |
| | | 1114 | | string poolId, |
| | | 1115 | | string computeNodeId, |
| | | 1116 | | string userName, |
| | | 1117 | | string password, |
| | | 1118 | | DateTime? expiryTime, |
| | | 1119 | | string sshPublicKey, |
| | | 1120 | | BehaviorManager bhMgr, |
| | | 1121 | | CancellationToken cancellationToken) |
| | | 1122 | | { |
| | 0 | 1123 | | var parameters = new Models.NodeUpdateUserParameter(password, expiryTime, sshPublicKey); |
| | | 1124 | | |
| | 0 | 1125 | | var request = new ComputeNodeUpdateUserBatchRequest(this._client, parameters, cancellationToken); |
| | | 1126 | | |
| | 0 | 1127 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.UpdateUserWithHttpMessage |
| | 0 | 1128 | | poolId, |
| | 0 | 1129 | | computeNodeId, |
| | 0 | 1130 | | userName, |
| | 0 | 1131 | | request.Parameters, |
| | 0 | 1132 | | request.Options, |
| | 0 | 1133 | | request.CustomHeaders, |
| | 0 | 1134 | | lambdaCancelToken); |
| | | 1135 | | |
| | 0 | 1136 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1137 | | |
| | 0 | 1138 | | return asyncTask; |
| | | 1139 | | } |
| | | 1140 | | |
| | | 1141 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeDeleteUserHeaders>> DeleteComputeNodeUser(string pool |
| | | 1142 | | { |
| | 1 | 1143 | | var request = new ComputeNodeDeleteUserBatchRequest(this._client, cancellationToken); |
| | | 1144 | | |
| | 0 | 1145 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.DeleteUserWithHttpMessage |
| | 0 | 1146 | | poolId, |
| | 0 | 1147 | | computeNodeId, |
| | 0 | 1148 | | userName, |
| | 0 | 1149 | | request.Options, |
| | 0 | 1150 | | request.CustomHeaders, |
| | 0 | 1151 | | lambdaCancelToken); |
| | | 1152 | | |
| | 1 | 1153 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1154 | | |
| | 1 | 1155 | | return asyncTask; |
| | | 1156 | | } |
| | | 1157 | | |
| | | 1158 | | public Task<AzureOperationResponse<Models.UploadBatchServiceLogsResult, Models.ComputeNodeUploadBatchServiceLogs |
| | | 1159 | | string poolId, |
| | | 1160 | | string nodeId, |
| | | 1161 | | string containerUrl, |
| | | 1162 | | DateTime startTime, |
| | | 1163 | | DateTime? endTime, |
| | | 1164 | | BehaviorManager bhMgr, |
| | | 1165 | | CancellationToken cancellationToken) |
| | | 1166 | | { |
| | 1 | 1167 | | var parameters = new Models.UploadBatchServiceLogsConfiguration(containerUrl, startTime, endTime); |
| | 1 | 1168 | | var request = new ComputeNodeUploadBatchServiceLogsBatchRequest(this._client, cancellationToken); |
| | | 1169 | | |
| | 0 | 1170 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.UploadBatchServiceLogsWit |
| | 0 | 1171 | | poolId, |
| | 0 | 1172 | | nodeId, |
| | 0 | 1173 | | parameters, |
| | 0 | 1174 | | request.Options, |
| | 0 | 1175 | | request.CustomHeaders, |
| | 0 | 1176 | | lambdaCancelToken); |
| | | 1177 | | |
| | 1 | 1178 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1179 | | |
| | 1 | 1180 | | return asyncTask; |
| | | 1181 | | } |
| | | 1182 | | |
| | | 1183 | | public async Task<AzureOperationHeaderResponse<Models.ComputeNodeGetRemoteDesktopHeaders>> GetComputeNodeRDPFile |
| | | 1184 | | { |
| | 2 | 1185 | | var request = new ComputeNodeGetRemoteDesktopBatchRequest(this._client, cancellationToken); |
| | | 1186 | | |
| | 0 | 1187 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetRemoteDesktopWithHttpM |
| | 0 | 1188 | | poolId, |
| | 0 | 1189 | | computeNodeId, |
| | 0 | 1190 | | request.Options, |
| | 0 | 1191 | | request.CustomHeaders, |
| | 0 | 1192 | | lambdaCancelToken); |
| | | 1193 | | |
| | 2 | 1194 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1195 | | |
| | 2 | 1196 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | | 1197 | | |
| | 0 | 1198 | | await CopyStreamAsync(response.Body, rdpStream, cancellationToken).ConfigureAwait(continueOnCapturedContext: |
| | | 1199 | | |
| | 0 | 1200 | | var result = new AzureOperationHeaderResponse<Models.ComputeNodeGetRemoteDesktopHeaders>() |
| | 0 | 1201 | | { |
| | 0 | 1202 | | Request = response.Request, |
| | 0 | 1203 | | RequestId = response.RequestId, |
| | 0 | 1204 | | Response = response.Response, |
| | 0 | 1205 | | Headers = response.Headers |
| | 0 | 1206 | | }; |
| | | 1207 | | |
| | 0 | 1208 | | return result; |
| | 0 | 1209 | | } |
| | | 1210 | | |
| | | 1211 | | public Task<AzureOperationResponse<Models.ComputeNodeGetRemoteLoginSettingsResult, Models.ComputeNodeGetRemoteLo |
| | | 1212 | | { |
| | 1 | 1213 | | var request = new ComputeNodeGetRemoteLoginSettingsBatchRequest(this._client, cancellationToken); |
| | | 1214 | | |
| | 0 | 1215 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetRemoteLoginSettingsWit |
| | 0 | 1216 | | poolId, |
| | 0 | 1217 | | computeNodeId, |
| | 0 | 1218 | | request.Options, |
| | 0 | 1219 | | request.CustomHeaders, |
| | 0 | 1220 | | lambdaCancelToken); |
| | | 1221 | | |
| | 1 | 1222 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1223 | | |
| | 1 | 1224 | | return asyncTask; |
| | | 1225 | | } |
| | | 1226 | | |
| | | 1227 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeRebootHeaders>> RebootComputeNode(string poolId, stri |
| | | 1228 | | { |
| | 1 | 1229 | | var parameters = UtilitiesInternal.MapNullableEnum<Common.ComputeNodeRebootOption, Protocol.Models.ComputeNo |
| | 1 | 1230 | | var request = new ComputeNodeRebootBatchRequest(this._client, parameters, cancellationToken); |
| | | 1231 | | |
| | 0 | 1232 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.RebootWithHttpMessagesAsy |
| | 0 | 1233 | | poolId, |
| | 0 | 1234 | | computeNodeId, |
| | 0 | 1235 | | request.Parameters, |
| | 0 | 1236 | | request.Options, |
| | 0 | 1237 | | request.CustomHeaders, |
| | 0 | 1238 | | lambdaCancelToken); |
| | | 1239 | | |
| | 1 | 1240 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1241 | | |
| | 1 | 1242 | | return asyncTask; |
| | | 1243 | | } |
| | | 1244 | | |
| | | 1245 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeReimageHeaders>> ReimageComputeNode(string poolId, st |
| | | 1246 | | { |
| | 1 | 1247 | | var parameters = UtilitiesInternal.MapNullableEnum<Common.ComputeNodeReimageOption, Protocol.Models.ComputeN |
| | 1 | 1248 | | var request = new ComputeNodeReimageBatchRequest(this._client, parameters, cancellationToken); |
| | | 1249 | | |
| | 0 | 1250 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ReimageWithHttpMessagesAs |
| | 0 | 1251 | | poolId, |
| | 0 | 1252 | | computeNodeId, |
| | 0 | 1253 | | request.Parameters, |
| | 0 | 1254 | | request.Options, |
| | 0 | 1255 | | request.CustomHeaders, |
| | 0 | 1256 | | lambdaCancelToken); |
| | | 1257 | | |
| | 1 | 1258 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1259 | | |
| | 1 | 1260 | | return asyncTask; |
| | | 1261 | | } |
| | | 1262 | | |
| | | 1263 | | public Task<AzureOperationHeaderResponse<Models.FileDeleteFromTaskHeaders>> DeleteNodeFileByTask(string jobId, s |
| | | 1264 | | { |
| | 1 | 1265 | | var request = new FileDeleteFromTaskBatchRequest(this._client, recursive, cancellationToken); |
| | | 1266 | | |
| | 0 | 1267 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.DeleteFromTaskWithHttpMessagesAs |
| | 0 | 1268 | | jobId, |
| | 0 | 1269 | | taskId, |
| | 0 | 1270 | | filePath, |
| | 0 | 1271 | | request.Parameters, |
| | 0 | 1272 | | request.Options, |
| | 0 | 1273 | | request.CustomHeaders, |
| | 0 | 1274 | | lambdaCancelToken); |
| | | 1275 | | |
| | 1 | 1276 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1277 | | |
| | 1 | 1278 | | return asyncTask; |
| | | 1279 | | } |
| | | 1280 | | |
| | | 1281 | | public Task<AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders>> GetComputeNode(string pool |
| | | 1282 | | { |
| | 2 | 1283 | | var request = new ComputeNodeGetBatchRequest(this._client, cancellationToken); |
| | | 1284 | | |
| | 0 | 1285 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetWithHttpMessagesAsync( |
| | 0 | 1286 | | poolId, |
| | 0 | 1287 | | computeNodeId, |
| | 0 | 1288 | | request.Options, |
| | 0 | 1289 | | request.CustomHeaders, |
| | 0 | 1290 | | lambdaCancelToken); |
| | | 1291 | | |
| | 2 | 1292 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1293 | | |
| | 2 | 1294 | | return asyncTask; |
| | | 1295 | | } |
| | | 1296 | | |
| | | 1297 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeEnableSchedulingHeaders>> EnableComputeNodeScheduling |
| | | 1298 | | { |
| | 1 | 1299 | | var request = new ComputeNodeEnableSchedulingBatchRequest(this._client, cancellationToken); |
| | | 1300 | | |
| | 0 | 1301 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.EnableSchedulingWithHttpM |
| | 0 | 1302 | | poolId, |
| | 0 | 1303 | | computeNodeId, |
| | 0 | 1304 | | request.Options, |
| | 0 | 1305 | | request.CustomHeaders, |
| | 0 | 1306 | | lambdaCancelToken); |
| | | 1307 | | |
| | 1 | 1308 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1309 | | |
| | 1 | 1310 | | return asyncTask; |
| | | 1311 | | } |
| | | 1312 | | |
| | | 1313 | | public Task<AzureOperationHeaderResponse<Models.ComputeNodeDisableSchedulingHeaders>> DisableComputeNodeScheduli |
| | | 1314 | | { |
| | 1 | 1315 | | var parameters = UtilitiesInternal.MapNullableEnum<Common.DisableComputeNodeSchedulingOption, Models.Disable |
| | | 1316 | | |
| | 1 | 1317 | | var request = new ComputeNodeDisableSchedulingBatchRequest(this._client, parameters, cancellationToken); |
| | | 1318 | | |
| | 0 | 1319 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.DisableSchedulingWithHttp |
| | 0 | 1320 | | poolId, |
| | 0 | 1321 | | computeNodeId, |
| | 0 | 1322 | | request.Parameters, |
| | 0 | 1323 | | request.Options, |
| | 0 | 1324 | | request.CustomHeaders, |
| | 0 | 1325 | | lambdaCancelToken); |
| | | 1326 | | |
| | 1 | 1327 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1328 | | |
| | 1 | 1329 | | return asyncTask; |
| | | 1330 | | } |
| | | 1331 | | |
| | | 1332 | | public Task<AzureOperationHeaderResponse<Models.TaskUpdateHeaders>> UpdateTask(string jobId, string taskId, Mode |
| | | 1333 | | { |
| | 0 | 1334 | | var parameters = taskConstraints; |
| | 0 | 1335 | | var request = new TaskUpdateBatchRequest(this._client, parameters, cancellationToken); |
| | | 1336 | | |
| | 0 | 1337 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.UpdateWithHttpMessagesAsync( |
| | 0 | 1338 | | jobId, |
| | 0 | 1339 | | taskId, |
| | 0 | 1340 | | request.Parameters, |
| | 0 | 1341 | | request.Options, |
| | 0 | 1342 | | request.CustomHeaders, |
| | 0 | 1343 | | lambdaCancelToken); |
| | | 1344 | | |
| | 0 | 1345 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1346 | | |
| | 0 | 1347 | | return asyncTask; |
| | | 1348 | | } |
| | | 1349 | | |
| | | 1350 | | public Task<AzureOperationHeaderResponse<Models.FileDeleteFromComputeNodeHeaders>> DeleteNodeFileByNode(string p |
| | | 1351 | | { |
| | 1 | 1352 | | var request = new FileDeleteFromComputeNodeBatchRequest(this._client, recursive, cancellationToken); |
| | | 1353 | | |
| | 0 | 1354 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.DeleteFromComputeNodeWithHttpMes |
| | 0 | 1355 | | poolId, |
| | 0 | 1356 | | computeNodeId, |
| | 0 | 1357 | | filePath, |
| | 0 | 1358 | | request.Parameters, |
| | 0 | 1359 | | request.Options, |
| | 0 | 1360 | | request.CustomHeaders, |
| | 0 | 1361 | | lambdaCancelToken); |
| | | 1362 | | |
| | 1 | 1363 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1364 | | |
| | 1 | 1365 | | return asyncTask; |
| | | 1366 | | } |
| | | 1367 | | |
| | | 1368 | | // BUGBUG: TODO: fix this up with ranged GETs or whatever... |
| | | 1369 | | public async Task<AzureOperationResponse<Models.NodeFile, Models.FileGetFromComputeNodeHeaders>> GetNodeFileByNo |
| | | 1370 | | string poolId, |
| | | 1371 | | string computeNodeId, |
| | | 1372 | | string filePath, |
| | | 1373 | | Stream stream, |
| | | 1374 | | GetFileRequestByteRange byteRange, |
| | | 1375 | | BehaviorManager bhMgr, |
| | | 1376 | | CancellationToken cancellationToken) |
| | | 1377 | | { |
| | 5 | 1378 | | var request = new FileGetFromComputeNodeBatchRequest(this._client, cancellationToken); |
| | | 1379 | | |
| | 5 | 1380 | | if (byteRange != null) |
| | | 1381 | | { |
| | 2 | 1382 | | request.Options.OcpRange = byteRange.GetOcpRangeHeader(); |
| | | 1383 | | } |
| | | 1384 | | |
| | 6 | 1385 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetFromComputeNodeWithHttpMessag |
| | 6 | 1386 | | poolId, |
| | 6 | 1387 | | computeNodeId, |
| | 6 | 1388 | | filePath, |
| | 6 | 1389 | | request.Options, |
| | 6 | 1390 | | request.CustomHeaders, |
| | 6 | 1391 | | lambdaCancelToken); |
| | | 1392 | | |
| | 5 | 1393 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1394 | | |
| | 5 | 1395 | | var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| | | 1396 | | |
| | 3 | 1397 | | await CopyStreamAsync(response.Body, stream, cancellationToken).ConfigureAwait(continueOnCapturedContext: fa |
| | | 1398 | | |
| | 3 | 1399 | | var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetFromComputeNodeHeaders>() |
| | 3 | 1400 | | { |
| | 3 | 1401 | | Body = CreateNodeFileFromHeadersType(filePath, response.Headers), |
| | 3 | 1402 | | RequestId = response.RequestId, |
| | 3 | 1403 | | Headers = response.Headers |
| | 3 | 1404 | | }; |
| | | 1405 | | |
| | 3 | 1406 | | return result; |
| | 3 | 1407 | | } |
| | | 1408 | | |
| | | 1409 | | public async Task<AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromComputeNodeHeaders>> GetNo |
| | | 1410 | | string poolId, |
| | | 1411 | | string computeNodeId, |
| | | 1412 | | string filePath, |
| | | 1413 | | BehaviorManager bhMgr, |
| | | 1414 | | CancellationToken cancellationToken) |
| | | 1415 | | { |
| | 4 | 1416 | | var request = new FileGetNodeFilePropertiesFromComputeNodeBatchRequest(this._client, cancellationToken); |
| | | 1417 | | |
| | 5 | 1418 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetPropertiesFromComputeNodeWith |
| | 5 | 1419 | | poolId, |
| | 5 | 1420 | | computeNodeId, |
| | 5 | 1421 | | filePath, |
| | 5 | 1422 | | request.Options, |
| | 5 | 1423 | | request.CustomHeaders, |
| | 5 | 1424 | | lambdaCancelToken); |
| | | 1425 | | |
| | 4 | 1426 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1427 | | |
| | | 1428 | | //Force disposal of the response because the HEAD request doesn't read the body stream, which leaves the con |
| | 4 | 1429 | | using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false)) |
| | | 1430 | | { |
| | 3 | 1431 | | var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromComputeNodeHeaders> |
| | 3 | 1432 | | { |
| | 3 | 1433 | | Body = CreateNodeFileFromHeadersType(filePath, response.Headers), |
| | 3 | 1434 | | RequestId = response.RequestId, |
| | 3 | 1435 | | Headers = response.Headers |
| | 3 | 1436 | | }; |
| | | 1437 | | |
| | 3 | 1438 | | return result; |
| | | 1439 | | } |
| | 3 | 1440 | | } |
| | | 1441 | | |
| | | 1442 | | public Task<AzureOperationResponse<IPage<Models.NodeFile>, Models.FileListFromComputeNodeHeaders>> ListNodeFiles |
| | | 1443 | | string poolId, |
| | | 1444 | | string computeNodeId, |
| | | 1445 | | bool? recursive, |
| | | 1446 | | string skipToken, |
| | | 1447 | | BehaviorManager bhMgr, |
| | | 1448 | | DetailLevel detailLevel, |
| | | 1449 | | CancellationToken cancellationToken) |
| | | 1450 | | { |
| | | 1451 | | Task<AzureOperationResponse<IPage<Models.NodeFile>, Models.FileListFromComputeNodeHeaders>> asyncTask; |
| | | 1452 | | |
| | 1 | 1453 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1454 | | { |
| | 1 | 1455 | | var request = new FileListFromComputeNodeBatchRequest(this._client, recursive, cancellationToken); |
| | | 1456 | | |
| | 1 | 1457 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1458 | | |
| | 0 | 1459 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromComputeNodeWithHttpM |
| | 0 | 1460 | | poolId, |
| | 0 | 1461 | | computeNodeId, |
| | 0 | 1462 | | request.Parameters, |
| | 0 | 1463 | | request.Options, |
| | 0 | 1464 | | request.CustomHeaders, |
| | 0 | 1465 | | lambdaCancelToken); |
| | 1 | 1466 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1467 | | } |
| | | 1468 | | else |
| | | 1469 | | { |
| | 0 | 1470 | | var request = new FileListFromComputeNodeNextBatchRequest(this._client, cancellationToken); |
| | 0 | 1471 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromComputeNodeNextWithH |
| | 0 | 1472 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1473 | | } |
| | | 1474 | | |
| | 1 | 1475 | | return asyncTask; |
| | | 1476 | | } |
| | | 1477 | | |
| | | 1478 | | public Task<AzureOperationResponse<Models.JobStatistics, Models.JobGetAllLifetimeStatisticsHeaders>> GetAllJobLi |
| | | 1479 | | { |
| | 1 | 1480 | | var request = new JobGetAllJobsLifetimeStatisticsBatchRequest(this._client, cancellationToken); |
| | | 1481 | | |
| | 0 | 1482 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetAllLifetimeStatisticsWithHttpM |
| | 0 | 1483 | | request.Options, |
| | 0 | 1484 | | request.CustomHeaders, |
| | 0 | 1485 | | lambdaCancelToken); |
| | | 1486 | | |
| | 1 | 1487 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1488 | | |
| | 1 | 1489 | | return asyncTask; |
| | | 1490 | | } |
| | | 1491 | | |
| | | 1492 | | public Task<AzureOperationResponse<Models.PoolStatistics, Models.PoolGetAllLifetimeStatisticsHeaders>> GetAllPoo |
| | | 1493 | | { |
| | 1 | 1494 | | var request = new PoolGetAllPoolsLifetimeStatisticsBatchRequest(this._client, cancellationToken); |
| | | 1495 | | |
| | 0 | 1496 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.GetAllLifetimeStatisticsWithHttp |
| | 0 | 1497 | | request.Options, |
| | 0 | 1498 | | request.CustomHeaders, |
| | 0 | 1499 | | lambdaCancelToken); |
| | | 1500 | | |
| | 1 | 1501 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1502 | | |
| | 1 | 1503 | | return asyncTask; |
| | | 1504 | | } |
| | | 1505 | | |
| | | 1506 | | public Task<AzureOperationResponse<Models.Certificate, Models.CertificateGetHeaders>> GetCertificate(string thum |
| | | 1507 | | { |
| | 3 | 1508 | | var request = new CertificateGetBatchRequest(this._client, cancellationToken); |
| | | 1509 | | |
| | 4 | 1510 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.GetWithHttpMessagesAsync( |
| | 4 | 1511 | | thumbprintAlgorithm, |
| | 4 | 1512 | | thumbprint, |
| | 4 | 1513 | | request.Options, |
| | 4 | 1514 | | request.CustomHeaders, |
| | 4 | 1515 | | lambdaCancelToken); |
| | | 1516 | | |
| | 3 | 1517 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1518 | | |
| | 3 | 1519 | | return asyncTask; |
| | | 1520 | | } |
| | | 1521 | | |
| | | 1522 | | public Task<AzureOperationResponse<IPage<Models.PoolUsageMetrics>, Models.PoolListUsageMetricsHeaders>> ListPool |
| | | 1523 | | DateTime? startTime, |
| | | 1524 | | DateTime? endTime, |
| | | 1525 | | string skipToken, |
| | | 1526 | | BehaviorManager bhMgr, |
| | | 1527 | | DetailLevel detailLevel, |
| | | 1528 | | CancellationToken cancellationToken) |
| | | 1529 | | { |
| | | 1530 | | Task<AzureOperationResponse<IPage<Models.PoolUsageMetrics>, Models.PoolListUsageMetricsHeaders>> asyncTask; |
| | | 1531 | | |
| | 1 | 1532 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1533 | | { |
| | 1 | 1534 | | var request = new PoolListPoolUsageMetricsBatchRequest(this._client, cancellationToken); |
| | | 1535 | | |
| | 1 | 1536 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1537 | | |
| | 1 | 1538 | | request.Options.StartTime = startTime; |
| | 1 | 1539 | | request.Options.EndTime = endTime; |
| | | 1540 | | |
| | 0 | 1541 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListUsageMetricsWithHttpMess |
| | 0 | 1542 | | request.Options, |
| | 0 | 1543 | | request.CustomHeaders, |
| | 0 | 1544 | | lambdaCancelToken); |
| | | 1545 | | |
| | 1 | 1546 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1547 | | } |
| | | 1548 | | else |
| | | 1549 | | { |
| | 0 | 1550 | | var request = new PoolListPoolUsageMetricsNextBatchRequest(this._client, cancellationToken); |
| | 0 | 1551 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListUsageMetricsNextWithHttp |
| | | 1552 | | |
| | 0 | 1553 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1554 | | } |
| | | 1555 | | |
| | 1 | 1556 | | return asyncTask; |
| | | 1557 | | } |
| | | 1558 | | |
| | | 1559 | | public Task<AzureOperationResponse<IPage<Models.ImageInformation>, Models.AccountListSupportedImagesHeaders>> Li |
| | | 1560 | | string skipToken, |
| | | 1561 | | BehaviorManager bhMgr, |
| | | 1562 | | DetailLevel detailLevel, |
| | | 1563 | | CancellationToken cancellationToken) |
| | | 1564 | | { |
| | | 1565 | | Task<AzureOperationResponse<IPage<Models.ImageInformation>, Models.AccountListSupportedImagesHeaders>> async |
| | | 1566 | | |
| | 1 | 1567 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1568 | | { |
| | 1 | 1569 | | var request = new AccountListSupportedImagesBatchRequest(this._client, cancellationToken); |
| | | 1570 | | |
| | 1 | 1571 | | if (request.Options == null) |
| | | 1572 | | { |
| | 0 | 1573 | | request.Options = new Models.AccountListSupportedImagesOptions(); |
| | | 1574 | | } |
| | | 1575 | | |
| | 1 | 1576 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1577 | | |
| | 0 | 1578 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListSupportedImagesWithHt |
| | 0 | 1579 | | request.Options, |
| | 0 | 1580 | | request.CustomHeaders, |
| | 0 | 1581 | | lambdaCancelToken); |
| | | 1582 | | |
| | 1 | 1583 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1584 | | } |
| | | 1585 | | else |
| | | 1586 | | { |
| | 0 | 1587 | | var request = new AccountListSupportedImagesNextBatchRequest(this._client, cancellationToken); |
| | | 1588 | | |
| | 0 | 1589 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListSupportedImagesNextWi |
| | 0 | 1590 | | skipToken, request.Options, request.CustomHeaders, lambdaCancelToken); |
| | | 1591 | | |
| | 0 | 1592 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1593 | | } |
| | | 1594 | | |
| | 1 | 1595 | | return asyncTask; |
| | | 1596 | | } |
| | | 1597 | | |
| | | 1598 | | public Task<AzureOperationResponse<IPage<Models.Certificate>, Models.CertificateListHeaders>> ListCertificates(s |
| | | 1599 | | { |
| | | 1600 | | Task<AzureOperationResponse<IPage<Models.Certificate>, Models.CertificateListHeaders>> asyncTask; |
| | | 1601 | | |
| | 3 | 1602 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1603 | | { |
| | 2 | 1604 | | var request = new CertificateListBatchRequest(this._client, cancellationToken); |
| | | 1605 | | |
| | 2 | 1606 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1607 | | |
| | 0 | 1608 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.ListWithHttpMessagesA |
| | 0 | 1609 | | request.Options, |
| | 0 | 1610 | | request.CustomHeaders, |
| | 0 | 1611 | | lambdaCancelToken); |
| | | 1612 | | |
| | 2 | 1613 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1614 | | } |
| | | 1615 | | else |
| | | 1616 | | { |
| | 1 | 1617 | | var request = new CertificateListNextBatchRequest(this._client, cancellationToken); |
| | 0 | 1618 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.ListNextWithHttpMessa |
| | | 1619 | | |
| | 1 | 1620 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1621 | | } |
| | | 1622 | | |
| | 3 | 1623 | | return asyncTask; |
| | | 1624 | | } |
| | | 1625 | | |
| | | 1626 | | public Task<AzureOperationHeaderResponse<Models.CertificateAddHeaders>> AddCertificate(Models.CertificateAddPara |
| | | 1627 | | { |
| | 1 | 1628 | | var request = new CertificateAddBatchRequest(this._client, protoCert, cancellationToken); |
| | | 1629 | | |
| | 0 | 1630 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.AddWithHttpMessagesAsync( |
| | 0 | 1631 | | request.Parameters, |
| | 0 | 1632 | | request.Options, |
| | 0 | 1633 | | request.CustomHeaders, |
| | 0 | 1634 | | lambdaCancelToken); |
| | | 1635 | | |
| | 1 | 1636 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1637 | | |
| | 1 | 1638 | | return asyncTask; |
| | | 1639 | | } |
| | | 1640 | | |
| | | 1641 | | public Task<AzureOperationHeaderResponse<Models.CertificateDeleteHeaders>> DeleteCertificate(string thumbprintAl |
| | | 1642 | | { |
| | 1 | 1643 | | var request = new CertificateDeleteBatchRequest(this._client, cancellationToken); |
| | | 1644 | | |
| | 0 | 1645 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.DeleteWithHttpMessagesAsy |
| | 0 | 1646 | | thumbprintAlgorithm, |
| | 0 | 1647 | | thumbprint, |
| | 0 | 1648 | | request.Options, |
| | 0 | 1649 | | request.CustomHeaders, |
| | 0 | 1650 | | lambdaCancelToken); |
| | | 1651 | | |
| | 1 | 1652 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1653 | | |
| | 1 | 1654 | | return asyncTask; |
| | | 1655 | | } |
| | | 1656 | | |
| | | 1657 | | public Task<AzureOperationHeaderResponse<Models.CertificateCancelDeletionHeaders>> CancelDeleteCertificate(strin |
| | | 1658 | | { |
| | 1 | 1659 | | var request = new CertificateCancelDeletionBatchRequest(this._client, cancellationToken); |
| | | 1660 | | |
| | 0 | 1661 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.CancelDeletionWithHttpMes |
| | 0 | 1662 | | thumbprintAlgorithm, |
| | 0 | 1663 | | thumbprint, |
| | 0 | 1664 | | request.Options, |
| | 0 | 1665 | | request.CustomHeaders, |
| | 0 | 1666 | | lambdaCancelToken); |
| | | 1667 | | |
| | 1 | 1668 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1669 | | |
| | 1 | 1670 | | return asyncTask; |
| | | 1671 | | } |
| | | 1672 | | |
| | | 1673 | | public Task<AzureOperationResponse<Models.TaskAddCollectionResult, Models.TaskAddCollectionHeaders>> AddTaskColl |
| | | 1674 | | string jobId, |
| | | 1675 | | IEnumerable<Models.TaskAddParameter> tasks, |
| | | 1676 | | BehaviorManager bhMgr, |
| | | 1677 | | CancellationToken cancellationToken) |
| | | 1678 | | { |
| | 10 | 1679 | | var request = new TaskAddCollectionBatchRequest(this._client, tasks.ToList(), cancellationToken); |
| | | 1680 | | |
| | 0 | 1681 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.AddCollectionWithHttpMessagesAsy |
| | 0 | 1682 | | jobId, |
| | 0 | 1683 | | request.Parameters, |
| | 0 | 1684 | | request.Options, |
| | 0 | 1685 | | request.CustomHeaders, |
| | 0 | 1686 | | lambdaCancelToken); |
| | | 1687 | | |
| | 10 | 1688 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1689 | | |
| | 10 | 1690 | | return asyncTask; |
| | | 1691 | | } |
| | | 1692 | | |
| | | 1693 | | public Task<AzureOperationResponse<Models.ApplicationSummary, Models.ApplicationGetHeaders>> GetApplicationSumma |
| | | 1694 | | { |
| | 2 | 1695 | | var request = new ApplicationGetBatchRequest(this._client, cancellationToken); |
| | | 1696 | | |
| | 0 | 1697 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.GetWithHttpMessagesAsync( |
| | 0 | 1698 | | applicationId, |
| | 0 | 1699 | | request.Options, |
| | 0 | 1700 | | request.CustomHeaders, |
| | 0 | 1701 | | lambdaCancelToken); |
| | | 1702 | | |
| | 2 | 1703 | | var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1704 | | |
| | 2 | 1705 | | return asyncTask; |
| | | 1706 | | } |
| | | 1707 | | |
| | | 1708 | | public Task<AzureOperationResponse<IPage<Models.ApplicationSummary>, Models.ApplicationListHeaders>> ListApplica |
| | | 1709 | | string skipToken, |
| | | 1710 | | BehaviorManager bhMgr, |
| | | 1711 | | DetailLevel detailLevel, |
| | | 1712 | | CancellationToken cancellationToken) |
| | | 1713 | | { |
| | | 1714 | | Task<AzureOperationResponse<IPage<Models.ApplicationSummary>, Models.ApplicationListHeaders>> asyncTask; |
| | | 1715 | | |
| | 6 | 1716 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1717 | | { |
| | 4 | 1718 | | var request = new ApplicationListBatchRequest(this._client, cancellationToken); |
| | | 1719 | | |
| | 4 | 1720 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1721 | | |
| | 6 | 1722 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.ListWithHttpMessagesA |
| | 6 | 1723 | | request.Options, |
| | 6 | 1724 | | request.CustomHeaders, |
| | 6 | 1725 | | lambdaCancelToken); |
| | | 1726 | | |
| | 4 | 1727 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1728 | | } |
| | | 1729 | | else |
| | | 1730 | | { |
| | 2 | 1731 | | var request = new ApplicationListNextBatchRequest(this._client, cancellationToken); |
| | 4 | 1732 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.ListNextWithHttpMessa |
| | | 1733 | | |
| | 2 | 1734 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1735 | | } |
| | | 1736 | | |
| | 6 | 1737 | | return asyncTask; |
| | | 1738 | | } |
| | | 1739 | | |
| | | 1740 | | public Task<AzureOperationResponse<IPage<Models.PoolNodeCounts>, Models.AccountListPoolNodeCountsHeaders>> ListP |
| | | 1741 | | string skipToken, |
| | | 1742 | | BehaviorManager bhMgr, |
| | | 1743 | | DetailLevel detailLevel, |
| | | 1744 | | CancellationToken cancellationToken) |
| | | 1745 | | { |
| | | 1746 | | Task<AzureOperationResponse<IPage<Models.PoolNodeCounts>, Models.AccountListPoolNodeCountsHeaders>> asyncTas |
| | | 1747 | | |
| | 1 | 1748 | | if (string.IsNullOrEmpty(skipToken)) |
| | | 1749 | | { |
| | 1 | 1750 | | var request = new AccountListPoolNodeCountsBatchRequest(this._client, cancellationToken); |
| | | 1751 | | |
| | 1 | 1752 | | bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel); |
| | | 1753 | | |
| | 0 | 1754 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListPoolNodeCountsWithHtt |
| | 0 | 1755 | | request.Options, |
| | 0 | 1756 | | request.CustomHeaders, |
| | 0 | 1757 | | lambdaCancelToken); |
| | | 1758 | | |
| | 1 | 1759 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1760 | | } |
| | | 1761 | | else |
| | | 1762 | | { |
| | 0 | 1763 | | var request = new AccountListPoolNodeCountsNextBatchRequest(this._client, cancellationToken); |
| | 0 | 1764 | | request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListPoolNodeCountsNextWit |
| | 0 | 1765 | | skipToken, |
| | 0 | 1766 | | request.Options, |
| | 0 | 1767 | | request.CustomHeaders, |
| | 0 | 1768 | | lambdaCancelToken); |
| | | 1769 | | |
| | 0 | 1770 | | asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr); |
| | | 1771 | | } |
| | | 1772 | | |
| | 1 | 1773 | | return asyncTask; |
| | | 1774 | | } |
| | | 1775 | | |
| | | 1776 | | #endregion // IProtocolLayer |
| | | 1777 | | |
| | | 1778 | | #region // internal/private |
| | | 1779 | | |
| | | 1780 | | private static async Task CopyStreamAsync(Stream inputStream, Stream outputStream, CancellationToken cancellatio |
| | | 1781 | | { |
| | | 1782 | | //Copy the stream to the target stream and dispose of it |
| | 6 | 1783 | | using (Stream responseStream = inputStream) |
| | | 1784 | | { |
| | 6 | 1785 | | await responseStream.CopyToAsync(outputStream, StreamCopyBufferSize, cancellationToken).ConfigureAwait(c |
| | 6 | 1786 | | } |
| | 6 | 1787 | | } |
| | | 1788 | | |
| | | 1789 | | /// <summary> |
| | | 1790 | | /// Applies and executes the RequestInterceptors found in behaviors collection. |
| | | 1791 | | /// </summary> |
| | | 1792 | | /// <returns></returns> |
| | | 1793 | | private static void ExecuteRequestInterceptors<TResponse>(IBatchRequest<TResponse> request, IEnumerable<BatchCli |
| | | 1794 | | where TResponse : class, IAzureOperationResponse |
| | | 1795 | | { |
| | 230 | 1796 | | if (null != behaviors) |
| | | 1797 | | { |
| | 1251 | 1798 | | foreach (BatchClientBehavior curBehavior in behaviors) |
| | | 1799 | | { |
| | 429 | 1800 | | Protocol.RequestReplacementInterceptor replacementIntercept = curBehavior as Protocol.RequestReplace |
| | | 1801 | | |
| | 429 | 1802 | | if (null != replacementIntercept) |
| | | 1803 | | { |
| | 266 | 1804 | | IBatchRequest proxyObj = request; |
| | | 1805 | | |
| | | 1806 | | // call the delegate and let custom code modify/replace the context and/or the request |
| | 266 | 1807 | | replacementIntercept.ReplacementInterceptHandler(ref proxyObj); |
| | | 1808 | | |
| | | 1809 | | // enforce that the returned object is the required type |
| | 199 | 1810 | | ValidateReturnObject(request, typeof(IBatchRequest<TResponse>)); |
| | | 1811 | | |
| | | 1812 | | // any changes must be communcated back to the caller |
| | 199 | 1813 | | request = (Protocol.IBatchRequest<TResponse>)proxyObj; |
| | | 1814 | | } |
| | | 1815 | | } |
| | | 1816 | | } |
| | 163 | 1817 | | } |
| | | 1818 | | |
| | | 1819 | | private static async Task<TResponse> ExecuteResponseInterceptors<TResponse>( |
| | | 1820 | | TResponse originalResponse, |
| | | 1821 | | Protocol.IBatchRequest<TResponse> request, |
| | | 1822 | | IEnumerable<BatchClientBehavior> behaviors) |
| | | 1823 | | where TResponse : class, IAzureOperationResponse |
| | | 1824 | | { |
| | | 1825 | | // now we have a response... maybe there are response interceptors? |
| | 138 | 1826 | | List<Protocol.ResponseInterceptor> allRespInterceptors = new List<Protocol.ResponseInterceptor>(); |
| | | 1827 | | |
| | | 1828 | | // filter out the response interceptors |
| | 872 | 1829 | | foreach (BatchClientBehavior curBehavior in behaviors) |
| | | 1830 | | { |
| | 298 | 1831 | | Protocol.ResponseInterceptor realRespIntr = curBehavior as Protocol.ResponseInterceptor; |
| | | 1832 | | |
| | 298 | 1833 | | if (null != realRespIntr) |
| | | 1834 | | { |
| | 0 | 1835 | | allRespInterceptors.Add(realRespIntr); |
| | | 1836 | | } |
| | | 1837 | | } |
| | | 1838 | | |
| | | 1839 | | // start with original response and daisy-chain through interceptors |
| | 138 | 1840 | | TResponse response = originalResponse; |
| | | 1841 | | |
| | | 1842 | | // if there are any interceptors |
| | 138 | 1843 | | if (null != allRespInterceptors) |
| | | 1844 | | { |
| | | 1845 | | // call each response interceptor |
| | 0 | 1846 | | foreach (Protocol.ResponseInterceptor curRespInter in allRespInterceptors) |
| | | 1847 | | { |
| | | 1848 | | // start next interceptor |
| | 0 | 1849 | | Task<IAzureOperationResponse> fromIntercept = curRespInter.ResponseInterceptHandler(response, reques |
| | | 1850 | | |
| | | 1851 | | // let interceptor complete |
| | 0 | 1852 | | IAzureOperationResponse responseFromIntercept = await fromIntercept.ConfigureAwait(continueOnCapture |
| | | 1853 | | |
| | | 1854 | | // enforce that the returned object is the required type |
| | 0 | 1855 | | ValidateReturnObject(responseFromIntercept, typeof(TResponse)); |
| | | 1856 | | |
| | | 1857 | | // promote the intercetor response to official response |
| | 0 | 1858 | | response = (TResponse)responseFromIntercept; |
| | | 1859 | | } |
| | | 1860 | | } |
| | | 1861 | | |
| | | 1862 | | // return possibly intercepted response |
| | 138 | 1863 | | return response; |
| | 138 | 1864 | | } |
| | | 1865 | | |
| | | 1866 | | /// <summary> |
| | | 1867 | | /// Process and executes a BatchRequest. |
| | | 1868 | | /// </summary> |
| | | 1869 | | private static async Task<TResponse> ProcessAndExecuteBatchRequest<TResponse>(IBatchRequest<TResponse> request, |
| | | 1870 | | where TResponse : class, IAzureOperationResponse |
| | | 1871 | | { |
| | | 1872 | | // finalize the behaviors and get the master list |
| | 230 | 1873 | | IEnumerable<BatchClientBehavior> behaviors = bhMgr.MasterListOfBehaviors; |
| | | 1874 | | |
| | 230 | 1875 | | ExecuteRequestInterceptors(request, behaviors); |
| | | 1876 | | |
| | | 1877 | | // at this point, the batch service call has not yet been started. |
| | | 1878 | | // this means that the delegate in the request has not yet been called. |
| | | 1879 | | |
| | | 1880 | | //Execute the batch request |
| | 163 | 1881 | | Task<TResponse> requestTask = request.ExecuteRequestAsync(); |
| | | 1882 | | |
| | | 1883 | | // wait for call to complete |
| | 163 | 1884 | | TResponse response = await requestTask.ConfigureAwait(continueOnCapturedContext: false); |
| | | 1885 | | |
| | | 1886 | | // execute the response interceptors |
| | 138 | 1887 | | Task<TResponse> finalResponseTask = ExecuteResponseInterceptors(response, request, behaviors); |
| | | 1888 | | |
| | | 1889 | | // wait for response interceptors |
| | 138 | 1890 | | TResponse finalResponse = await finalResponseTask.ConfigureAwait(continueOnCapturedContext: false); |
| | | 1891 | | |
| | | 1892 | | // return final result to caller |
| | 138 | 1893 | | return finalResponse; |
| | 138 | 1894 | | } |
| | | 1895 | | |
| | | 1896 | | /// <summary> |
| | | 1897 | | /// Common validation that will throw if an incorrect instance is returned by a custom behavior. |
| | | 1898 | | /// </summary> |
| | | 1899 | | /// <param name="proxyObj"></param> |
| | | 1900 | | /// <param name="expectedType"></param> |
| | | 1901 | | private static void ValidateReturnObject(object proxyObj, Type expectedType) |
| | | 1902 | | { |
| | | 1903 | | // test that the returned value has the correct type |
| | 199 | 1904 | | if (!expectedType.GetTypeInfo().IsAssignableFrom(proxyObj.GetType().GetTypeInfo())) |
| | | 1905 | | { |
| | 0 | 1906 | | Exception ex = UtilitiesInternal.IncorrectTypeReturned; |
| | | 1907 | | |
| | 0 | 1908 | | throw ex; |
| | | 1909 | | } |
| | 199 | 1910 | | } |
| | | 1911 | | |
| | | 1912 | | #endregion // internal/private |
| | | 1913 | | |
| | | 1914 | | #region // IDisposable |
| | | 1915 | | |
| | | 1916 | | /// <summary> |
| | | 1917 | | /// A value indicating whether or not the ServiceClient has already |
| | | 1918 | | /// been disposed. |
| | | 1919 | | /// </summary> |
| | | 1920 | | private bool _disposed; |
| | | 1921 | | |
| | | 1922 | | /// <summary> |
| | | 1923 | | /// Dispose the ProtocolLayer class. This function is not thread-safe. |
| | | 1924 | | /// </summary> |
| | | 1925 | | public void Dispose() |
| | | 1926 | | { |
| | 145 | 1927 | | Dispose(true); |
| | 145 | 1928 | | GC.SuppressFinalize(this); |
| | 145 | 1929 | | } |
| | | 1930 | | |
| | | 1931 | | protected virtual void Dispose(bool disposing) |
| | | 1932 | | { |
| | 145 | 1933 | | if (this._disposed) |
| | | 1934 | | { |
| | 0 | 1935 | | return; |
| | | 1936 | | } |
| | | 1937 | | |
| | 145 | 1938 | | if (disposing && this._internalClient) |
| | | 1939 | | { |
| | 137 | 1940 | | this._client.Dispose(); |
| | | 1941 | | } |
| | | 1942 | | |
| | 145 | 1943 | | this._client = null; |
| | 145 | 1944 | | this._disposed = true; |
| | 145 | 1945 | | } |
| | | 1946 | | |
| | | 1947 | | #endregion // IDisposable |
| | | 1948 | | } |
| | | 1949 | | } |