< Summary

Class:Microsoft.Azure.Batch.ProtocolLayer
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ProtocolLayer.cs
Covered lines:446
Uncovered lines:460
Coverable lines:906
Total lines:1949
Line coverage:49.2% (446 of 906)
Covered branches:52
Total branches:64
Branch coverage:81.2% (52 of 64)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CreateNodeFileFromHeadersType(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
ListJobSchedules(...)-70%100%
GetJobSchedule(...)-100%100%
JobScheduleExists()-0%100%
AddJobSchedule(...)-37.5%100%
UpdateJobSchedule(...)-0%100%
PatchJobSchedule(...)-40%100%
EnableJobSchedule(...)-37.5%100%
DisableJobSchedule(...)-37.5%100%
TerminateJobSchedule(...)-37.5%100%
DeleteJobSchedule(...)-37.5%100%
AddJob(...)-37.5%100%
ListJobsAll(...)-58.33%100%
ListJobsBySchedule(...)-53.85%100%
ListJobPreparationAndReleaseTaskStatus(...)-53.85%100%
GetJob(...)-100%100%
GetJobTaskCounts(...)-37.5%100%
UpdateJob(...)-0%100%
PatchJob(...)-40%100%
EnableJob(...)-37.5%100%
DisableJob(...)-40%100%
TerminateJob(...)-40%100%
DeleteJob(...)-37.5%100%
ListTasks(...)-53.85%100%
ListNodeFilesByTask(...)-33.33%50%
GetTask(...)-33.33%100%
ListSubtasks(...)-40%100%
GetNodeFileByTask()-100%100%
GetNodeFilePropertiesByTask()-100%100%
AddTask(...)-33.33%100%
TerminateTask(...)-33.33%100%
DeleteTask(...)-33.33%100%
ReactivateTask(...)-33.33%100%
ListPools(...)-58.33%100%
GetPool(...)-100%100%
PoolExists()-0%100%
AddPool(...)-37.5%100%
UpdatePool(...)-53.85%83.33%
PatchPool(...)-40%100%
DeletePool(...)-100%100%
ResizePool(...)-57.14%100%
StopResizePool(...)-37.5%100%
EnableAutoScale(...)-40%100%
DisableAutoScale(...)-37.5%100%
EvaluateAutoScale(...)-40%100%
ListComputeNodes(...)-53.85%100%
RemovePoolComputeNodes(...)-57.14%50%
AddComputeNodeUser(...)-0%100%
UpdateComputeNodeUser(...)-0%100%
DeleteComputeNodeUser(...)-30%100%
UploadBatchServiceLogs(...)-36.36%100%
GetComputeNodeRDPFile()-15.79%100%
GetRemoteLoginSettings(...)-33.33%100%
RebootComputeNode(...)-36.36%100%
ReimageComputeNode(...)-36.36%100%
DeleteNodeFileByTask(...)-27.27%100%
GetComputeNode(...)-33.33%100%
EnableComputeNodeScheduling(...)-33.33%100%
DisableComputeNodeScheduling(...)-36.36%100%
UpdateTask(...)-0%100%
DeleteNodeFileByNode(...)-27.27%100%
GetNodeFileByNode()-100%100%
GetNodeFilePropertiesByNode()-100%100%
ListNodeFilesByNode(...)-33.33%50%
GetAllJobLifetimeStats(...)-42.86%100%
GetAllPoolLifetimeStats(...)-42.86%100%
GetCertificate(...)-100%100%
ListPoolUsageMetrics(...)-50%50%
ListSupportedImages(...)-40%50%
ListCertificates(...)-58.33%100%
AddCertificate(...)-37.5%100%
DeleteCertificate(...)-33.33%100%
CancelDeleteCertificate(...)-33.33%100%
AddTaskCollection(...)-33.33%100%
GetApplicationSummary(...)-37.5%100%
ListApplicationSummaries(...)-100%100%
ListPoolNodeCounts(...)-31.25%50%
CopyStreamAsync()-100%100%
ExecuteRequestInterceptors(...)-100%100%
ExecuteResponseInterceptors()-57.14%75%
ProcessAndExecuteBatchRequest()-100%100%
ValidateReturnObject(...)-50%50%
Dispose()-100%100%
Dispose(...)-85.71%83.33%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ProtocolLayer.cs

#LineLine coverage
 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
 4namespace 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        {
 1230            Models.NodeFile file = new Models.NodeFile()
 1231                {
 1232                    IsDirectory = protocolNodeFile.OcpBatchFileIsdirectory,
 1233                    Name = filePath,
 1234                    Properties = new Models.FileProperties()
 1235                        {
 1236                            ContentLength = protocolNodeFile.ContentLength.GetValueOrDefault(),
 1237                            ContentType = protocolNodeFile.ContentType,
 1238                            CreationTime = protocolNodeFile.OcpCreationTime,
 1239                            LastModified = protocolNodeFile.LastModified.GetValueOrDefault(),
 1240                            FileMode = protocolNodeFile.OcpBatchFileMode
 1241                        },
 1242                    Url = protocolNodeFile.OcpBatchFileUrl
 1243                };
 44
 1245            return file;
 46        }
 47
 48#region // constructors
 49
 50        /// <summary>
 51        /// instantiate based on creds and base url
 52        /// </summary>
 13853        internal ProtocolLayer(string baseUrl, ServiceClientCredentials credentials)
 54        {
 13855            this._client = new Protocol.BatchServiceClient(credentials);
 13856            this._client.BatchUrl = baseUrl;
 13857            this._client.HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(InternalConstants.Use
 58
 13859            this._client.HttpClient.Timeout = Timeout.InfiniteTimeSpan; //Client side timeout will be set per-request
 13860            this._client.SetRetryPolicy(null); //Set the retry policy to null to turn off inner-client retries
 13861            this._internalClient = true;
 13862        }
 63
 64        /// <summary>
 65        /// instantiate based on customer provided rest proxy
 66        /// </summary>
 67        /// <param name="clientToUse"></param>
 968        internal ProtocolLayer(Protocol.BatchServiceClient clientToUse)
 69        {
 970            this._client = clientToUse;
 971            this._internalClient = false;
 972        }
 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
 486            if (string.IsNullOrEmpty(skipToken))
 87            {
 388                var request = new JobScheduleListBatchRequest(this._client, cancellationToken);
 89
 390                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 91
 092                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ListWithHttpMessagesA
 093                        request.Options, request.CustomHeaders, lambdaCancelToken);
 394                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 95            }
 96            else
 97            {
 198                var request = new JobScheduleListNextBatchRequest(this._client, cancellationToken);
 99
 0100                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ListNextWithHttpMessa
 1101                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 102            }
 103
 4104            return asyncTask;
 105        }
 106
 107        public Task<AzureOperationResponse<Models.CloudJobSchedule, Models.JobScheduleGetHeaders>> GetJobSchedule(string
 108        {
 14109            var request = new JobScheduleGetBatchRequest(this._client, cancellationToken);
 110
 15111            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.GetWithHttpMessagesAsync(
 15112                    jobScheduleId,
 15113                    request.Options,
 15114                    request.CustomHeaders,
 15115                    lambdaCancelToken);
 116
 14117            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 118
 14119            return asyncTask;
 120        }
 121
 122        public async Task<AzureOperationResponse<bool, Models.JobScheduleExistsHeaders>> JobScheduleExists(string jobSch
 123        {
 0124            var request = new JobScheduleExistsBatchRequest(this._client, cancellationToken);
 125
 0126            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.ExistsWithHttpMessagesAsy
 0127                    jobScheduleId,
 0128                    request.Options,
 0129                    request.CustomHeaders,
 0130                    lambdaCancelToken);
 131
 0132            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
 0135            using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false))
 136            {
 0137                var result = new AzureOperationResponse<bool, Models.JobScheduleExistsHeaders>()
 0138                    {
 0139                        Body = response.Body,
 0140                        RequestId = response.RequestId,
 0141                        Headers = response.Headers
 0142                    };
 143
 0144                return result;
 145            }
 0146        }
 147
 148        public Task<AzureOperationHeaderResponse<Models.JobScheduleAddHeaders>> AddJobSchedule(Models.JobScheduleAddPara
 149        {
 3150            var request = new JobScheduleAddBatchRequest(this._client, cloudJobSchedule, cancellationToken);
 151
 0152            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.AddWithHttpMessagesAsync(
 0153                    request.Parameters,
 0154                    request.Options,
 0155                    request.CustomHeaders,
 0156                    lambdaCancelToken);
 157
 3158            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 159
 3160            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        {
 0171            var parameters = new Models.JobScheduleUpdateParameter(schedule, jobSpecification, metadata);
 0172            var request = new JobScheduleUpdateBatchRequest(this._client, parameters, cancellationToken);
 173
 0174            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.UpdateWithHttpMessagesAsy
 0175                    jobScheduleId,
 0176                    request.Parameters,
 0177                    request.Options,
 0178                    request.CustomHeaders,
 0179                    lambdaCancelToken);
 180
 0181            Task<AzureOperationHeaderResponse<Models.JobScheduleUpdateHeaders>> asyncTask = ProcessAndExecuteBatchReques
 182
 0183            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        {
 5194            var parameters = new Models.JobSchedulePatchParameter(schedule, jobSpecification, metadata);
 5195            var request = new JobSchedulePatchBatchRequest(this._client, parameters, cancellationToken);
 196
 0197            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.PatchWithHttpMessagesAsyn
 0198                    jobScheduleId,
 0199                    request.Parameters,
 0200                    request.Options,
 0201                    request.CustomHeaders,
 0202                    lambdaCancelToken);
 203
 5204            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 205
 5206            return asyncTask;
 207        }
 208
 209        public Task<AzureOperationHeaderResponse<Models.JobScheduleEnableHeaders>> EnableJobSchedule(string jobScheduleI
 210        {
 1211            var request = new JobScheduleEnableBatchRequest(this._client, cancellationToken);
 212
 0213            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.EnableWithHttpMessagesAsy
 0214                    jobScheduleId,
 0215                    request.Options,
 0216                    request.CustomHeaders,
 0217                    lambdaCancelToken);
 218
 1219            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 220
 1221            return asyncTask;
 222        }
 223
 224        public Task<AzureOperationHeaderResponse<Models.JobScheduleDisableHeaders>> DisableJobSchedule(string jobSchedul
 225        {
 1226            var request = new JobScheduleDisableBatchRequest(this._client, cancellationToken);
 227
 0228            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.DisableWithHttpMessagesAs
 0229                    jobScheduleId,
 0230                    request.Options,
 0231                    request.CustomHeaders,
 0232                    lambdaCancelToken);
 233
 1234            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 235
 1236            return asyncTask;
 237        }
 238
 239        public Task<AzureOperationHeaderResponse<Models.JobScheduleTerminateHeaders>> TerminateJobSchedule(string jobSch
 240        {
 1241            var request = new JobScheduleTerminateBatchRequest(this._client, cancellationToken);
 242
 0243            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.TerminateWithHttpMessages
 0244                    jobScheduleId,
 0245                    request.Options,
 0246                    request.CustomHeaders,
 0247                    lambdaCancelToken);
 248
 1249            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 250
 1251            return asyncTask;
 252        }
 253
 254        public Task<AzureOperationHeaderResponse<Models.JobScheduleDeleteHeaders>> DeleteJobSchedule(string jobScheduleI
 255        {
 1256            var request = new JobScheduleDeleteBatchRequest(this._client, cancellationToken);
 257
 0258            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.JobSchedule.DeleteWithHttpMessagesAsy
 0259                    jobScheduleId,
 0260                    request.Options,
 0261                    request.CustomHeaders,
 0262                    lambdaCancelToken);
 263
 1264            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 265
 1266            return asyncTask;
 267        }
 268
 269        public Task<AzureOperationHeaderResponse<Models.JobAddHeaders>> AddJob(Models.JobAddParameter job, BehaviorManag
 270        {
 4271            var request = new JobAddBatchRequest(this._client, job, cancellationToken);
 272
 0273            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.AddWithHttpMessagesAsync(
 0274                    request.Parameters,
 0275                    request.Options,
 0276                    request.CustomHeaders,
 0277                    lambdaCancelToken);
 278
 4279            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 280
 4281            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
 4288            if (string.IsNullOrEmpty(skipToken))
 289            {
 3290                var request = new JobListBatchRequest(this._client, cancellationToken);
 291
 3292                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 293
 0294                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListWithHttpMessagesAsync(
 0295                        request.Options,
 0296                        request.CustomHeaders,
 0297                        lambdaCancelToken);
 3298                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 299            }
 300            else
 301            {
 1302                var request = new JobListNextBatchRequest(this._client, cancellationToken);
 303
 0304                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListNextWithHttpMessagesAsync
 1305                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 306            }
 307
 4308            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
 2320            if (string.IsNullOrEmpty(skipToken))
 321            {
 1322                var request = new JobListFromJobScheduleBatchRequest(this._client, cancellationToken);
 323
 1324                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 325
 0326                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListFromJobScheduleWithHttpMe
 0327                    jobScheduleId,
 0328                    request.Options,
 0329                    request.CustomHeaders,
 0330                    lambdaCancelToken);
 331
 1332                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 333            }
 334            else
 335            {
 1336                var request = new JobListFromJobScheduleNextBatchRequest(this._client, cancellationToken);
 337
 0338                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListFromJobScheduleNextWithHt
 1339                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 340            }
 341
 2342            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
 3354            if (string.IsNullOrEmpty(skipToken))
 355            {
 2356                var request = new JobListPreparationAndReleaseTaskStatusBatchRequest(this._client, cancellationToken);
 357
 2358                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 359
 0360                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListPreparationAndReleaseTask
 0361                    jobId,
 0362                    request.Options,
 0363                    request.CustomHeaders,
 0364                    lambdaCancelToken);
 365
 2366                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 367            }
 368            else
 369            {
 1370                var request = new JobListPreparationAndReleaseTaskStatusNextBatchRequest(this._client, cancellationToken
 371
 0372                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.ListPreparationAndReleaseTask
 1373                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 374            }
 375
 3376            return asyncTask;
 377        }
 378
 379        public Task<AzureOperationResponse<Models.CloudJob, Models.JobGetHeaders>> GetJob(string jobId, BehaviorManager 
 380        {
 29381            var request = new JobGetBatchRequest(this._client, cancellationToken);
 382
 30383            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetWithHttpMessagesAsync(
 30384                    jobId,
 30385                    request.Options,
 30386                    request.CustomHeaders,
 30387                    lambdaCancelToken);
 388
 29389            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 390
 29391            return asyncTask;
 392        }
 393
 394        public Task<AzureOperationResponse<Models.TaskCounts, Models.JobGetTaskCountsHeaders>> GetJobTaskCounts(string j
 395        {
 1396            var request = new JobGetTaskCountsBatchRequest(this._client, cancellationToken);
 397
 0398            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetTaskCountsWithHttpMessagesAsyn
 0399                jobId,
 0400                request.Options,
 0401                request.CustomHeaders,
 0402                lambdaCancelToken);
 403
 1404            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 405
 1406            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        {
 0419            var parameters = new Models.JobUpdateParameter(poolInfo, priority, constraints, metadata, onAllTasksComplete
 0420            var request = new JobUpdateBatchRequest(this._client, parameters, cancellationToken);
 421
 0422            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.UpdateWithHttpMessagesAsync(
 0423                    jobId,
 0424                    request.Parameters,
 0425                    request.Options,
 0426                    request.CustomHeaders,
 0427                    lambdaCancelToken);
 428
 0429            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 430
 0431            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        {
 6444            var parameters = new Models.JobPatchParameter(priority, onAllTasksComplete, constraints, poolInfo, metadata)
 6445            var request = new JobPatchBatchRequest(this._client, parameters, cancellationToken);
 446
 0447            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.PatchWithHttpMessagesAsync(
 0448                    jobId,
 0449                    request.Parameters,
 0450                    request.Options,
 0451                    request.CustomHeaders,
 0452                    lambdaCancelToken);
 453
 6454            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 455
 6456            return asyncTask;
 457        }
 458
 459        public Task<AzureOperationHeaderResponse<Models.JobEnableHeaders>> EnableJob(string jobId, BehaviorManager bhMgr
 460        {
 1461            var request = new JobEnableBatchRequest(this._client, cancellationToken);
 462
 0463            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.EnableWithHttpMessagesAsync(
 0464                    jobId,
 0465                    request.Options,
 0466                    request.CustomHeaders,
 0467                    lambdaCancelToken);
 468
 1469            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 470
 1471            return asyncTask;
 472        }
 473
 474        public Task<AzureOperationHeaderResponse<Models.JobDisableHeaders>> DisableJob(string jobId, Common.DisableJobOp
 475        {
 1476            var parameter = UtilitiesInternal.MapEnum<Common.DisableJobOption, Protocol.Models.DisableJobOption>(disable
 1477            var request = new JobDisableBatchRequest(this._client, parameter, cancellationToken);
 478
 0479            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.DisableWithHttpMessagesAsync(
 0480                    jobId,
 0481                    request.Parameters,
 0482                    request.Options,
 0483                    request.CustomHeaders,
 0484                    lambdaCancelToken);
 485
 1486            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 487
 1488            return asyncTask;
 489        }
 490
 491        public Task<AzureOperationHeaderResponse<Models.JobTerminateHeaders>> TerminateJob(string jobId, string terminat
 492        {
 1493            var parameters = terminateReason;
 1494            var request = new JobTerminateBatchRequest(this._client, parameters, cancellationToken);
 495
 0496            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.TerminateWithHttpMessagesAsync(
 0497                    jobId,
 0498                    request.Parameters,
 0499                    request.Options,
 0500                    request.CustomHeaders,
 0501                    lambdaCancelToken);
 502
 1503            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 504
 1505            return asyncTask;
 506        }
 507
 508        public Task<AzureOperationHeaderResponse<Models.JobDeleteHeaders>> DeleteJob(string jobId, BehaviorManager bhMgr
 509        {
 1510            var request = new JobDeleteBatchRequest(this._client, cancellationToken);
 511
 0512            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.DeleteWithHttpMessagesAsync(
 0513                    jobId,
 0514                    request.Options,
 0515                    request.CustomHeaders,
 0516                    lambdaCancelToken);
 517
 1518            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 519
 1520            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
 7527            if (string.IsNullOrEmpty(skipToken))
 528            {
 6529                var request = new TaskListBatchRequest(this._client, cancellationToken);
 530
 6531                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 532
 0533                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListWithHttpMessagesAsync(
 0534                    jobId,
 0535                    request.Options,
 0536                    request.CustomHeaders,
 0537                    lambdaCancelToken);
 538
 6539                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 540            }
 541            else
 542            {
 1543                var request = new TaskListNextBatchRequest(this._client, cancellationToken);
 544
 0545                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListNextWithHttpMessagesAsyn
 1546                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 547            }
 548
 7549            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
 1563            if (string.IsNullOrEmpty(skipToken))
 564            {
 1565                var request = new FileListFromTaskBatchRequest(this._client, recursive, cancellationToken);
 566
 1567                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 568
 0569                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromTaskWithHttpMessages
 0570                    jobId,
 0571                    taskId,
 0572                    request.Parameters,
 0573                    request.Options,
 0574                    request.CustomHeaders,
 0575                    lambdaCancelToken);
 576
 1577                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 578            }
 579            else
 580            {
 0581                var request = new FileListFromTaskNextBatchRequest(this._client, cancellationToken);
 582
 0583                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromTaskNextWithHttpMess
 0584                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 585            }
 586
 1587            return asyncTask;
 588        }
 589
 590        public Task<AzureOperationResponse<Models.CloudTask, Models.TaskGetHeaders>> GetTask(string jobId, string taskId
 591        {
 3592            var request = new TaskGetBatchRequest(this._client, cancellationToken);
 593
 0594            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.GetWithHttpMessagesAsync(
 0595                    jobId,
 0596                    taskId,
 0597                    request.Options,
 0598                    request.CustomHeaders,
 0599                    lambdaCancelToken);
 600
 3601            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 602
 3603            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
 1616            var request = new TaskListSubtasksBatchRequest(this._client, cancellationToken);
 617
 1618            bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 619
 0620            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ListSubtasksWithHttpMessagesAsyn
 0621                jobId,
 0622                taskId,
 0623                request.Options,
 0624                request.CustomHeaders,
 0625                lambdaCancelToken);
 626
 1627            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
 1641            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        {
 5654            var request = new FileGetFromTaskBatchRequest(this._client, cancellationToken);
 655
 5656            if (byteRange != null)
 657            {
 2658                request.Options.OcpRange = byteRange.GetOcpRangeHeader();
 659            }
 660
 6661            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetFromTaskWithHttpMessagesAsync
 6662                    jobId,
 6663                    taskId,
 6664                    filePath,
 6665                    request.Options,
 6666                    request.CustomHeaders,
 6667                    lambdaCancelToken);
 668
 5669            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 670
 5671            var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 672
 3673            await CopyStreamAsync(response.Body, stream, cancellationToken).ConfigureAwait(continueOnCapturedContext: fa
 674
 3675            var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetFromTaskHeaders>()
 3676                {
 3677                    Body = CreateNodeFileFromHeadersType(filePath, response.Headers),
 3678                    RequestId = response.RequestId,
 3679                    Headers = response.Headers,
 3680                };
 681
 3682            return result;
 3683        }
 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        {
 4692            var request = new FileGetNodeFilePropertiesFromTaskBatchRequest(this._client, cancellationToken);
 693
 5694            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetPropertiesFromTaskWithHttpMes
 5695                    jobId,
 5696                    taskId,
 5697                    filePath,
 5698                    request.Options,
 5699                    request.CustomHeaders,
 5700                    lambdaCancelToken);
 701
 4702            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
 4705            using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false))
 706            {
 3707                var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromTaskHeaders>()
 3708                    {
 3709                        Body = CreateNodeFileFromHeadersType(filePath, response.Headers),
 3710                        RequestId = response.RequestId,
 3711                        Headers = response.Headers,
 3712                    };
 713
 3714                return result;
 715            }
 3716        }
 717
 718        public Task<AzureOperationHeaderResponse<Models.TaskAddHeaders>> AddTask(string jobId, Models.TaskAddParameter t
 719        {
 8720            var request = new TaskAddBatchRequest(this._client, task, cancellationToken);
 721
 0722            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.AddWithHttpMessagesAsync(
 0723                    jobId,
 0724                    request.Parameters,
 0725                    request.Options,
 0726                    request.CustomHeaders,
 0727                    lambdaCancelToken);
 728
 8729            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 730
 8731            return asyncTask;
 732        }
 733
 734        public Task<AzureOperationHeaderResponse<Models.TaskTerminateHeaders>> TerminateTask(string jobId, string taskId
 735        {
 1736            var request = new TaskTerminateBatchRequest(this._client, cancellationToken);
 737
 0738            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.TerminateWithHttpMessagesAsync(
 0739                    jobId,
 0740                    taskId,
 0741                    request.Options,
 0742                    request.CustomHeaders,
 0743                    lambdaCancelToken);
 744
 1745            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 746
 1747            return asyncTask;
 748        }
 749
 750        public Task<AzureOperationHeaderResponse<Models.TaskDeleteHeaders>> DeleteTask(string jobId, string taskId, Beha
 751        {
 1752            var request = new TaskDeleteBatchRequest(this._client, cancellationToken);
 753
 0754            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.DeleteWithHttpMessagesAsync(
 0755                    jobId,
 0756                    taskId,
 0757                    request.Options,
 0758                    request.CustomHeaders,
 0759                    lambdaCancelToken);
 760
 1761            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 762
 1763            return asyncTask;
 764        }
 765
 766        public Task<AzureOperationHeaderResponse<Models.TaskReactivateHeaders>> ReactivateTask(string jobId, string task
 767        {
 1768            var request = new TaskReactivateBatchRequest(this._client, cancellationToken);
 769
 0770            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.ReactivateWithHttpMessagesAsync(
 0771                    jobId,
 0772                    taskId,
 0773                    request.Options,
 0774                    request.CustomHeaders,
 0775                    lambdaCancelToken);
 776
 1777            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 778
 1779            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
 4787            if (string.IsNullOrEmpty(skipToken))
 788            {
 3789                var request = new PoolListBatchRequest(this._client, cancellationToken);
 790
 3791                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 792
 0793                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListWithHttpMessagesAsync(
 0794                    request.Options,
 0795                    request.CustomHeaders,
 0796                    lambdaCancelToken);
 3797                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 798            }
 799            else
 800            {
 1801                var request = new PoolListNextBatchRequest(this._client, cancellationToken);
 802
 0803                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListNextWithHttpMessagesAsyn
 1804                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 805            }
 806
 4807            return asyncTask;
 808        }
 809
 810        public Task<AzureOperationResponse<Models.CloudPool, Models.PoolGetHeaders>> GetPool(string poolId, BehaviorMana
 811        {
 31812            var request = new PoolGetBatchRequest(this._client, cancellationToken);
 813
 32814            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.GetWithHttpMessagesAsync(
 32815                    poolId,
 32816                    request.Options,
 32817                    request.CustomHeaders,
 32818                    lambdaCancelToken);
 819
 31820            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 821
 31822            return asyncTask;
 823        }
 824
 825        public async Task<AzureOperationResponse<bool, Models.PoolExistsHeaders>> PoolExists(string poolId, BehaviorMana
 826        {
 0827            var request = new PoolExistsBatchRequest(this._client, cancellationToken);
 828
 0829            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ExistsWithHttpMessagesAsync(
 0830                    poolId,
 0831                    request.Options,
 0832                    request.CustomHeaders,
 0833                    lambdaCancelToken);
 834
 0835            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
 0837            using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false))
 838            {
 0839                var result = new AzureOperationResponse<bool, Models.PoolExistsHeaders>()
 0840                    {
 0841                        Body = response.Body,
 0842                        RequestId = response.RequestId,
 0843                        Headers = response.Headers
 0844                    };
 845
 0846                return result;
 847            }
 0848        }
 849
 850        public Task<AzureOperationHeaderResponse<Models.PoolAddHeaders>> AddPool(Models.PoolAddParameter pool, BehaviorM
 851        {
 3852            var request = new PoolAddBatchRequest(this._client, pool, cancellationToken);
 853
 0854            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.AddWithHttpMessagesAsync(
 0855                    request.Parameters,
 0856                    request.Options,
 0857                    request.CustomHeaders,
 0858                    lambdaCancelToken);
 859
 3860            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 861
 3862            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
 1876            certRefs = certRefs ?? new Models.CertificateReference[0];
 1877            metaData = metaData ?? new Models.MetadataItem[0];
 1878            applicationPackageReferences = applicationPackageReferences ?? new Models.ApplicationPackageReference[0];
 879
 1880            var parameters = new Models.PoolUpdatePropertiesParameter(certRefs, applicationPackageReferences, metaData, 
 1881            var request = new PoolUpdatePropertiesBatchRequest(this._client, parameters, cancellationToken);
 882
 0883            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.UpdatePropertiesWithHttpMessages
 0884                    poolId,
 0885                    request.Parameters,
 0886                    request.Options,
 0887                    request.CustomHeaders,
 0888                    lambdaCancelToken);
 889
 1890            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 891
 1892            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        {
 5904            var parameters = new Models.PoolPatchParameter(startTask, certificateReferences, applicationPackageReference
 5905            var request = new PoolPatchBatchRequest(this._client, parameters, cancellationToken);
 906
 0907            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.PatchWithHttpMessagesAsync(
 0908                    poolId,
 0909                    request.Parameters,
 0910                    request.Options,
 0911                    request.CustomHeaders,
 0912                    lambdaCancelToken);
 913
 5914            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 915
 5916            return asyncTask;
 917        }
 918
 919        public Task<AzureOperationHeaderResponse<Models.PoolDeleteHeaders>> DeletePool(string poolId, BehaviorManager bh
 920        {
 5921            var request = new PoolDeleteBatchRequest(this._client, cancellationToken);
 922
 9923            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.DeleteWithHttpMessagesAsync(
 9924                    poolId,
 9925                    request.Options,
 9926                    request.CustomHeaders,
 9927                    lambdaCancelToken);
 928
 5929            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 930
 5931            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        {
 1943            var parameters = new Models.PoolResizeParameter(
 1944                targetDedicatedComputeNodes,
 1945                targetLowPriorityComputeNodes,
 1946                resizeTimeout,
 1947                UtilitiesInternal.MapNullableEnum<Common.ComputeNodeDeallocationOption, Protocol.Models.ComputeNodeDeall
 948
 1949            var request = new PoolResizeBatchRequest(this._client, parameters, cancellationToken);
 950
 0951            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ResizeWithHttpMessagesAsync(
 0952                    poolId,
 0953                    request.Parameters,
 0954                    request.Options,
 0955                    request.CustomHeaders,
 0956                    lambdaCancelToken);
 957
 1958            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 959
 1960            return asyncTask;
 961        }
 962
 963        public Task<AzureOperationHeaderResponse<Models.PoolStopResizeHeaders>> StopResizePool(string poolId, BehaviorMa
 964        {
 1965            var request = new PoolStopResizeBatchRequest(this._client, cancellationToken);
 966
 0967            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.StopResizeWithHttpMessagesAsync(
 0968                    poolId,
 0969                    request.Options,
 0970                    request.CustomHeaders,
 0971                    lambdaCancelToken);
 972
 1973            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 974
 1975            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        {
 1985            var parameters = new Models.PoolEnableAutoScaleParameter(autoscaleFormula, autoscaleEvaluationInterval);
 1986            var request = new PoolEnableAutoScaleBatchRequest(this._client, parameters, cancellationToken);
 987
 0988            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.EnableAutoScaleWithHttpMessagesA
 0989                    poolId,
 0990                    request.Parameters,
 0991                    request.Options,
 0992                    request.CustomHeaders,
 0993                    lambdaCancelToken);
 994
 1995            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 996
 1997            return asyncTask;
 998        }
 999
 1000        public Task<AzureOperationHeaderResponse<Models.PoolDisableAutoScaleHeaders>> DisableAutoScale(string poolId, Be
 1001        {
 11002            var request = new PoolDisableAutoScaleBatchRequest(this._client, cancellationToken);
 1003
 01004            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.DisableAutoScaleWithHttpMessages
 01005                    poolId,
 01006                    request.Options,
 01007                    request.CustomHeaders,
 01008                    lambdaCancelToken);
 1009
 11010            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1011
 11012            return asyncTask;
 1013        }
 1014
 1015        public Task<AzureOperationResponse<Models.AutoScaleRun, Models.PoolEvaluateAutoScaleHeaders>> EvaluateAutoScale(
 1016        {
 11017            var parameters = autoscaleFomula;
 11018            var request = new PoolEvaluateAutoScaleBatchRequest(this._client, parameters, cancellationToken);
 1019
 01020            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.EvaluateAutoScaleWithHttpMessage
 01021                    poolId,
 01022                    autoscaleFomula,
 01023                    request.Options,
 01024                    request.CustomHeaders,
 01025                    lambdaCancelToken);
 1026
 11027            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1028
 11029            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
 41042            if (string.IsNullOrEmpty(skipToken))
 1043            {
 31044                var request = new ComputeNodeListBatchRequest(this._client, cancellationToken);
 1045
 31046                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1047
 01048                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ListWithHttpMessagesA
 01049                    poolId,
 01050                    request.Options,
 01051                    request.CustomHeaders,
 01052                    lambdaCancelToken);
 1053
 31054                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1055            }
 1056            else
 1057            {
 11058                var request = new ComputeNodeListNextBatchRequest(this._client, cancellationToken);
 01059                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ListNextWithHttpMessa
 1060
 11061                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1062            }
 1063
 41064            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
 21076            List<string> computeNodeIdList = computeNodeIds == null ? null : computeNodeIds.ToList();
 21077            var parameters = new Models.NodeRemoveParameter(
 21078                computeNodeIdList,
 21079                resizeTimeout,
 21080                UtilitiesInternal.MapNullableEnum<Common.ComputeNodeDeallocationOption, Protocol.Models.ComputeNodeDeall
 1081
 21082            var request = new PoolRemoveNodesBatchRequest(this._client, parameters, cancellationToken);
 1083
 01084            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.RemoveNodesWithHttpMessagesAsync
 01085                poolId,
 01086                request.Parameters,
 01087                request.Options,
 01088                request.CustomHeaders,
 01089                lambdaCancelToken);
 1090
 21091            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1092
 21093            return asyncTask;
 1094        }
 1095
 1096        public Task<AzureOperationHeaderResponse<Models.ComputeNodeAddUserHeaders>> AddComputeNodeUser(string poolId, st
 1097        {
 01098            var request = new ComputeNodeAddUserBatchRequest(this._client, protoUser, cancellationToken);
 1099
 01100            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.AddUserWithHttpMessagesAs
 01101                poolId,
 01102                computeNodeId,
 01103                request.Parameters,
 01104                request.Options,
 01105                request.CustomHeaders,
 01106                lambdaCancelToken);
 1107
 01108            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1109
 01110            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        {
 01123            var parameters = new Models.NodeUpdateUserParameter(password, expiryTime, sshPublicKey);
 1124
 01125            var request = new ComputeNodeUpdateUserBatchRequest(this._client, parameters, cancellationToken);
 1126
 01127            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.UpdateUserWithHttpMessage
 01128                poolId,
 01129                computeNodeId,
 01130                userName,
 01131                request.Parameters,
 01132                request.Options,
 01133                request.CustomHeaders,
 01134                lambdaCancelToken);
 1135
 01136            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1137
 01138            return asyncTask;
 1139        }
 1140
 1141        public Task<AzureOperationHeaderResponse<Models.ComputeNodeDeleteUserHeaders>> DeleteComputeNodeUser(string pool
 1142        {
 11143            var request = new ComputeNodeDeleteUserBatchRequest(this._client, cancellationToken);
 1144
 01145            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.DeleteUserWithHttpMessage
 01146                poolId,
 01147                computeNodeId,
 01148                userName,
 01149                request.Options,
 01150                request.CustomHeaders,
 01151                lambdaCancelToken);
 1152
 11153            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1154
 11155            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        {
 11167            var parameters = new Models.UploadBatchServiceLogsConfiguration(containerUrl, startTime, endTime);
 11168            var request = new ComputeNodeUploadBatchServiceLogsBatchRequest(this._client, cancellationToken);
 1169
 01170            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.UploadBatchServiceLogsWit
 01171                poolId,
 01172                nodeId,
 01173                parameters,
 01174                request.Options,
 01175                request.CustomHeaders,
 01176                lambdaCancelToken);
 1177
 11178            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1179
 11180            return asyncTask;
 1181        }
 1182
 1183        public async Task<AzureOperationHeaderResponse<Models.ComputeNodeGetRemoteDesktopHeaders>> GetComputeNodeRDPFile
 1184        {
 21185            var request = new ComputeNodeGetRemoteDesktopBatchRequest(this._client, cancellationToken);
 1186
 01187            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetRemoteDesktopWithHttpM
 01188                poolId,
 01189                computeNodeId,
 01190                request.Options,
 01191                request.CustomHeaders,
 01192                lambdaCancelToken);
 1193
 21194            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1195
 21196            var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 1197
 01198            await CopyStreamAsync(response.Body, rdpStream, cancellationToken).ConfigureAwait(continueOnCapturedContext:
 1199
 01200            var result = new AzureOperationHeaderResponse<Models.ComputeNodeGetRemoteDesktopHeaders>()
 01201                {
 01202                    Request = response.Request,
 01203                    RequestId = response.RequestId,
 01204                    Response = response.Response,
 01205                    Headers = response.Headers
 01206                };
 1207
 01208            return result;
 01209        }
 1210
 1211        public Task<AzureOperationResponse<Models.ComputeNodeGetRemoteLoginSettingsResult, Models.ComputeNodeGetRemoteLo
 1212        {
 11213            var request = new ComputeNodeGetRemoteLoginSettingsBatchRequest(this._client, cancellationToken);
 1214
 01215            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetRemoteLoginSettingsWit
 01216                poolId,
 01217                computeNodeId,
 01218                request.Options,
 01219                request.CustomHeaders,
 01220                lambdaCancelToken);
 1221
 11222            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1223
 11224            return asyncTask;
 1225        }
 1226
 1227        public Task<AzureOperationHeaderResponse<Models.ComputeNodeRebootHeaders>> RebootComputeNode(string poolId, stri
 1228        {
 11229            var parameters = UtilitiesInternal.MapNullableEnum<Common.ComputeNodeRebootOption, Protocol.Models.ComputeNo
 11230            var request = new ComputeNodeRebootBatchRequest(this._client, parameters, cancellationToken);
 1231
 01232            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.RebootWithHttpMessagesAsy
 01233                poolId,
 01234                computeNodeId,
 01235                request.Parameters,
 01236                request.Options,
 01237                request.CustomHeaders,
 01238                lambdaCancelToken);
 1239
 11240            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1241
 11242            return asyncTask;
 1243        }
 1244
 1245        public Task<AzureOperationHeaderResponse<Models.ComputeNodeReimageHeaders>> ReimageComputeNode(string poolId, st
 1246        {
 11247            var parameters = UtilitiesInternal.MapNullableEnum<Common.ComputeNodeReimageOption, Protocol.Models.ComputeN
 11248            var request = new ComputeNodeReimageBatchRequest(this._client, parameters, cancellationToken);
 1249
 01250            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.ReimageWithHttpMessagesAs
 01251                poolId,
 01252                computeNodeId,
 01253                request.Parameters,
 01254                request.Options,
 01255                request.CustomHeaders,
 01256                lambdaCancelToken);
 1257
 11258            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1259
 11260            return asyncTask;
 1261        }
 1262
 1263        public Task<AzureOperationHeaderResponse<Models.FileDeleteFromTaskHeaders>> DeleteNodeFileByTask(string jobId, s
 1264        {
 11265            var request = new FileDeleteFromTaskBatchRequest(this._client, recursive, cancellationToken);
 1266
 01267            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.DeleteFromTaskWithHttpMessagesAs
 01268                jobId,
 01269                taskId,
 01270                filePath,
 01271                request.Parameters,
 01272                request.Options,
 01273                request.CustomHeaders,
 01274                lambdaCancelToken);
 1275
 11276            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1277
 11278            return asyncTask;
 1279        }
 1280
 1281        public Task<AzureOperationResponse<Models.ComputeNode, Models.ComputeNodeGetHeaders>> GetComputeNode(string pool
 1282        {
 21283            var request = new ComputeNodeGetBatchRequest(this._client, cancellationToken);
 1284
 01285            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.GetWithHttpMessagesAsync(
 01286                poolId,
 01287                computeNodeId,
 01288                request.Options,
 01289                request.CustomHeaders,
 01290                lambdaCancelToken);
 1291
 21292            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1293
 21294            return asyncTask;
 1295        }
 1296
 1297        public Task<AzureOperationHeaderResponse<Models.ComputeNodeEnableSchedulingHeaders>> EnableComputeNodeScheduling
 1298        {
 11299            var request = new ComputeNodeEnableSchedulingBatchRequest(this._client, cancellationToken);
 1300
 01301            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.EnableSchedulingWithHttpM
 01302                poolId,
 01303                computeNodeId,
 01304                request.Options,
 01305                request.CustomHeaders,
 01306                lambdaCancelToken);
 1307
 11308            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1309
 11310            return asyncTask;
 1311        }
 1312
 1313        public Task<AzureOperationHeaderResponse<Models.ComputeNodeDisableSchedulingHeaders>> DisableComputeNodeScheduli
 1314        {
 11315            var parameters = UtilitiesInternal.MapNullableEnum<Common.DisableComputeNodeSchedulingOption, Models.Disable
 1316
 11317            var request = new ComputeNodeDisableSchedulingBatchRequest(this._client, parameters, cancellationToken);
 1318
 01319            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.ComputeNode.DisableSchedulingWithHttp
 01320                poolId,
 01321                computeNodeId,
 01322                request.Parameters,
 01323                request.Options,
 01324                request.CustomHeaders,
 01325                lambdaCancelToken);
 1326
 11327            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1328
 11329            return asyncTask;
 1330        }
 1331
 1332        public Task<AzureOperationHeaderResponse<Models.TaskUpdateHeaders>> UpdateTask(string jobId, string taskId, Mode
 1333        {
 01334            var parameters = taskConstraints;
 01335            var request = new TaskUpdateBatchRequest(this._client, parameters, cancellationToken);
 1336
 01337            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.UpdateWithHttpMessagesAsync(
 01338                jobId,
 01339                taskId,
 01340                request.Parameters,
 01341                request.Options,
 01342                request.CustomHeaders,
 01343                lambdaCancelToken);
 1344
 01345            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1346
 01347            return asyncTask;
 1348        }
 1349
 1350        public Task<AzureOperationHeaderResponse<Models.FileDeleteFromComputeNodeHeaders>> DeleteNodeFileByNode(string p
 1351        {
 11352            var request = new FileDeleteFromComputeNodeBatchRequest(this._client, recursive, cancellationToken);
 1353
 01354            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.DeleteFromComputeNodeWithHttpMes
 01355                poolId,
 01356                computeNodeId,
 01357                filePath,
 01358                request.Parameters,
 01359                request.Options,
 01360                request.CustomHeaders,
 01361                lambdaCancelToken);
 1362
 11363            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1364
 11365            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        {
 51378            var request = new FileGetFromComputeNodeBatchRequest(this._client, cancellationToken);
 1379
 51380            if (byteRange != null)
 1381            {
 21382                request.Options.OcpRange = byteRange.GetOcpRangeHeader();
 1383            }
 1384
 61385            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetFromComputeNodeWithHttpMessag
 61386                    poolId,
 61387                    computeNodeId,
 61388                    filePath,
 61389                    request.Options,
 61390                    request.CustomHeaders,
 61391                    lambdaCancelToken);
 1392
 51393            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1394
 51395            var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 1396
 31397            await CopyStreamAsync(response.Body, stream, cancellationToken).ConfigureAwait(continueOnCapturedContext: fa
 1398
 31399            var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetFromComputeNodeHeaders>()
 31400            {
 31401                Body = CreateNodeFileFromHeadersType(filePath, response.Headers),
 31402                RequestId = response.RequestId,
 31403                Headers = response.Headers
 31404            };
 1405
 31406            return result;
 31407        }
 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        {
 41416            var request = new FileGetNodeFilePropertiesFromComputeNodeBatchRequest(this._client, cancellationToken);
 1417
 51418            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.GetPropertiesFromComputeNodeWith
 51419                poolId,
 51420                computeNodeId,
 51421                filePath,
 51422                request.Options,
 51423                request.CustomHeaders,
 51424                lambdaCancelToken);
 1425
 41426            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
 41429            using (var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false))
 1430            {
 31431                var result = new AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromComputeNodeHeaders>
 31432                    {
 31433                        Body = CreateNodeFileFromHeadersType(filePath, response.Headers),
 31434                        RequestId = response.RequestId,
 31435                        Headers = response.Headers
 31436                    };
 1437
 31438                return result;
 1439            }
 31440        }
 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
 11453            if (string.IsNullOrEmpty(skipToken))
 1454            {
 11455                var request = new FileListFromComputeNodeBatchRequest(this._client, recursive, cancellationToken);
 1456
 11457                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1458
 01459                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromComputeNodeWithHttpM
 01460                    poolId,
 01461                    computeNodeId,
 01462                    request.Parameters,
 01463                    request.Options,
 01464                    request.CustomHeaders,
 01465                    lambdaCancelToken);
 11466                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1467            }
 1468            else
 1469            {
 01470                var request = new FileListFromComputeNodeNextBatchRequest(this._client, cancellationToken);
 01471                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.File.ListFromComputeNodeNextWithH
 01472                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1473            }
 1474
 11475            return asyncTask;
 1476        }
 1477
 1478        public Task<AzureOperationResponse<Models.JobStatistics, Models.JobGetAllLifetimeStatisticsHeaders>> GetAllJobLi
 1479        {
 11480            var request = new JobGetAllJobsLifetimeStatisticsBatchRequest(this._client, cancellationToken);
 1481
 01482            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Job.GetAllLifetimeStatisticsWithHttpM
 01483                request.Options,
 01484                request.CustomHeaders,
 01485                lambdaCancelToken);
 1486
 11487            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1488
 11489            return asyncTask;
 1490        }
 1491
 1492        public Task<AzureOperationResponse<Models.PoolStatistics, Models.PoolGetAllLifetimeStatisticsHeaders>> GetAllPoo
 1493        {
 11494            var request = new PoolGetAllPoolsLifetimeStatisticsBatchRequest(this._client, cancellationToken);
 1495
 01496            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.GetAllLifetimeStatisticsWithHttp
 01497                request.Options,
 01498                request.CustomHeaders,
 01499                lambdaCancelToken);
 1500
 11501            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1502
 11503            return asyncTask;
 1504        }
 1505
 1506        public Task<AzureOperationResponse<Models.Certificate, Models.CertificateGetHeaders>> GetCertificate(string thum
 1507        {
 31508            var request = new CertificateGetBatchRequest(this._client, cancellationToken);
 1509
 41510            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.GetWithHttpMessagesAsync(
 41511                thumbprintAlgorithm,
 41512                thumbprint,
 41513                request.Options,
 41514                request.CustomHeaders,
 41515                lambdaCancelToken);
 1516
 31517            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1518
 31519            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
 11532            if (string.IsNullOrEmpty(skipToken))
 1533            {
 11534                var request = new PoolListPoolUsageMetricsBatchRequest(this._client, cancellationToken);
 1535
 11536                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1537
 11538                request.Options.StartTime = startTime;
 11539                request.Options.EndTime = endTime;
 1540
 01541                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListUsageMetricsWithHttpMess
 01542                    request.Options,
 01543                    request.CustomHeaders,
 01544                    lambdaCancelToken);
 1545
 11546                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1547            }
 1548            else
 1549            {
 01550                var request = new PoolListPoolUsageMetricsNextBatchRequest(this._client, cancellationToken);
 01551                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Pool.ListUsageMetricsNextWithHttp
 1552
 01553                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1554            }
 1555
 11556            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
 11567            if (string.IsNullOrEmpty(skipToken))
 1568            {
 11569                var request = new AccountListSupportedImagesBatchRequest(this._client, cancellationToken);
 1570
 11571                if (request.Options == null)
 1572                {
 01573                    request.Options = new Models.AccountListSupportedImagesOptions();
 1574                }
 1575
 11576                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1577
 01578                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListSupportedImagesWithHt
 01579                    request.Options,
 01580                    request.CustomHeaders,
 01581                    lambdaCancelToken);
 1582
 11583                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1584            }
 1585            else
 1586            {
 01587                var request = new AccountListSupportedImagesNextBatchRequest(this._client, cancellationToken);
 1588
 01589                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListSupportedImagesNextWi
 01590                    skipToken, request.Options, request.CustomHeaders, lambdaCancelToken);
 1591
 01592                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1593            }
 1594
 11595            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
 31602            if (string.IsNullOrEmpty(skipToken))
 1603            {
 21604                var request = new CertificateListBatchRequest(this._client, cancellationToken);
 1605
 21606                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1607
 01608                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.ListWithHttpMessagesA
 01609                    request.Options,
 01610                    request.CustomHeaders,
 01611                    lambdaCancelToken);
 1612
 21613                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1614            }
 1615            else
 1616            {
 11617                var request = new CertificateListNextBatchRequest(this._client, cancellationToken);
 01618                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.ListNextWithHttpMessa
 1619
 11620                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1621            }
 1622
 31623            return asyncTask;
 1624        }
 1625
 1626        public Task<AzureOperationHeaderResponse<Models.CertificateAddHeaders>> AddCertificate(Models.CertificateAddPara
 1627        {
 11628            var request = new CertificateAddBatchRequest(this._client, protoCert, cancellationToken);
 1629
 01630            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.AddWithHttpMessagesAsync(
 01631                request.Parameters,
 01632                request.Options,
 01633                request.CustomHeaders,
 01634                lambdaCancelToken);
 1635
 11636            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1637
 11638            return asyncTask;
 1639        }
 1640
 1641        public Task<AzureOperationHeaderResponse<Models.CertificateDeleteHeaders>> DeleteCertificate(string thumbprintAl
 1642        {
 11643            var request = new CertificateDeleteBatchRequest(this._client, cancellationToken);
 1644
 01645            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.DeleteWithHttpMessagesAsy
 01646                thumbprintAlgorithm,
 01647                thumbprint,
 01648                request.Options,
 01649                request.CustomHeaders,
 01650                lambdaCancelToken);
 1651
 11652            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1653
 11654            return asyncTask;
 1655        }
 1656
 1657        public Task<AzureOperationHeaderResponse<Models.CertificateCancelDeletionHeaders>> CancelDeleteCertificate(strin
 1658        {
 11659            var request = new CertificateCancelDeletionBatchRequest(this._client, cancellationToken);
 1660
 01661            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Certificate.CancelDeletionWithHttpMes
 01662                thumbprintAlgorithm,
 01663                thumbprint,
 01664                request.Options,
 01665                request.CustomHeaders,
 01666                lambdaCancelToken);
 1667
 11668            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1669
 11670            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        {
 101679            var request = new TaskAddCollectionBatchRequest(this._client, tasks.ToList(), cancellationToken);
 1680
 01681            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Task.AddCollectionWithHttpMessagesAsy
 01682                jobId,
 01683                request.Parameters,
 01684                request.Options,
 01685                request.CustomHeaders,
 01686                lambdaCancelToken);
 1687
 101688            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1689
 101690            return asyncTask;
 1691        }
 1692
 1693        public Task<AzureOperationResponse<Models.ApplicationSummary, Models.ApplicationGetHeaders>> GetApplicationSumma
 1694        {
 21695            var request = new ApplicationGetBatchRequest(this._client, cancellationToken);
 1696
 01697            request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.GetWithHttpMessagesAsync(
 01698                applicationId,
 01699                request.Options,
 01700                request.CustomHeaders,
 01701                lambdaCancelToken);
 1702
 21703            var asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1704
 21705            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
 61716            if (string.IsNullOrEmpty(skipToken))
 1717            {
 41718                var request = new ApplicationListBatchRequest(this._client, cancellationToken);
 1719
 41720                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1721
 61722                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.ListWithHttpMessagesA
 61723                    request.Options,
 61724                    request.CustomHeaders,
 61725                    lambdaCancelToken);
 1726
 41727                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1728            }
 1729            else
 1730            {
 21731                var request = new ApplicationListNextBatchRequest(this._client, cancellationToken);
 41732                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Application.ListNextWithHttpMessa
 1733
 21734                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1735            }
 1736
 61737            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
 11748            if (string.IsNullOrEmpty(skipToken))
 1749            {
 11750                var request = new AccountListPoolNodeCountsBatchRequest(this._client, cancellationToken);
 1751
 11752                bhMgr = bhMgr.CreateBehaviorManagerWithDetailLevel(detailLevel);
 1753
 01754                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListPoolNodeCountsWithHtt
 01755                    request.Options,
 01756                    request.CustomHeaders,
 01757                    lambdaCancelToken);
 1758
 11759                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1760            }
 1761            else
 1762            {
 01763                var request = new AccountListPoolNodeCountsNextBatchRequest(this._client, cancellationToken);
 01764                request.ServiceRequestFunc = (lambdaCancelToken) => request.RestClient.Account.ListPoolNodeCountsNextWit
 01765                    skipToken,
 01766                    request.Options,
 01767                    request.CustomHeaders,
 01768                    lambdaCancelToken);
 1769
 01770                asyncTask = ProcessAndExecuteBatchRequest(request, bhMgr);
 1771            }
 1772
 11773            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
 61783            using (Stream responseStream = inputStream)
 1784            {
 61785                await responseStream.CopyToAsync(outputStream, StreamCopyBufferSize, cancellationToken).ConfigureAwait(c
 61786            }
 61787        }
 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        {
 2301796            if (null != behaviors)
 1797            {
 12511798                foreach (BatchClientBehavior curBehavior in behaviors)
 1799                {
 4291800                    Protocol.RequestReplacementInterceptor replacementIntercept = curBehavior as Protocol.RequestReplace
 1801
 4291802                    if (null != replacementIntercept)
 1803                    {
 2661804                        IBatchRequest proxyObj = request;
 1805
 1806                        // call the delegate and let custom code modify/replace the context and/or the request
 2661807                        replacementIntercept.ReplacementInterceptHandler(ref proxyObj);
 1808
 1809                        // enforce that the returned object is the required type
 1991810                        ValidateReturnObject(request, typeof(IBatchRequest<TResponse>));
 1811
 1812                        // any changes must be communcated back to the caller
 1991813                        request = (Protocol.IBatchRequest<TResponse>)proxyObj;
 1814                    }
 1815                }
 1816            }
 1631817        }
 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?
 1381826            List<Protocol.ResponseInterceptor> allRespInterceptors = new List<Protocol.ResponseInterceptor>();
 1827
 1828            // filter out the response interceptors
 8721829            foreach (BatchClientBehavior curBehavior in behaviors)
 1830            {
 2981831                Protocol.ResponseInterceptor realRespIntr = curBehavior as Protocol.ResponseInterceptor;
 1832
 2981833                if (null != realRespIntr)
 1834                {
 01835                    allRespInterceptors.Add(realRespIntr);
 1836                }
 1837            }
 1838
 1839            // start with original response and daisy-chain through interceptors
 1381840            TResponse response = originalResponse;
 1841
 1842            // if there are any interceptors
 1381843            if (null != allRespInterceptors)
 1844            {
 1845                // call each response interceptor
 01846                foreach (Protocol.ResponseInterceptor curRespInter in allRespInterceptors)
 1847                {
 1848                    // start next interceptor
 01849                    Task<IAzureOperationResponse> fromIntercept = curRespInter.ResponseInterceptHandler(response, reques
 1850
 1851                    // let interceptor complete
 01852                    IAzureOperationResponse responseFromIntercept = await fromIntercept.ConfigureAwait(continueOnCapture
 1853
 1854                    // enforce that the returned object is the required type
 01855                    ValidateReturnObject(responseFromIntercept, typeof(TResponse));
 1856
 1857                    // promote the intercetor response to official response
 01858                    response = (TResponse)responseFromIntercept;
 1859                }
 1860            }
 1861
 1862            // return possibly intercepted response
 1381863            return response;
 1381864        }
 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
 2301873            IEnumerable<BatchClientBehavior> behaviors = bhMgr.MasterListOfBehaviors;
 1874
 2301875            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
 1631881            Task<TResponse> requestTask = request.ExecuteRequestAsync();
 1882
 1883            // wait for call to complete
 1631884            TResponse response = await requestTask.ConfigureAwait(continueOnCapturedContext: false);
 1885
 1886            // execute the response interceptors
 1381887            Task<TResponse> finalResponseTask = ExecuteResponseInterceptors(response, request, behaviors);
 1888
 1889            // wait for response interceptors
 1381890            TResponse finalResponse = await finalResponseTask.ConfigureAwait(continueOnCapturedContext: false);
 1891
 1892            // return final result to caller
 1381893            return finalResponse;
 1381894        }
 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
 1991904            if (!expectedType.GetTypeInfo().IsAssignableFrom(proxyObj.GetType().GetTypeInfo()))
 1905            {
 01906                Exception ex = UtilitiesInternal.IncorrectTypeReturned;
 1907
 01908                throw ex;
 1909            }
 1991910        }
 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        {
 1451927            Dispose(true);
 1451928            GC.SuppressFinalize(this);
 1451929        }
 1930
 1931        protected virtual void Dispose(bool disposing)
 1932        {
 1451933            if (this._disposed)
 1934            {
 01935                return;
 1936            }
 1937
 1451938            if (disposing && this._internalClient)
 1939            {
 1371940                this._client.Dispose();
 1941            }
 1942
 1451943            this._client = null;
 1451944            this._disposed = true;
 1451945        }
 1946
 1947#endregion // IDisposable
 1948    }
 1949}

Methods/Properties

CreateNodeFileFromHeadersType(...)
.ctor(...)
.ctor(...)
ListJobSchedules(...)
GetJobSchedule(...)
JobScheduleExists()
AddJobSchedule(...)
UpdateJobSchedule(...)
PatchJobSchedule(...)
EnableJobSchedule(...)
DisableJobSchedule(...)
TerminateJobSchedule(...)
DeleteJobSchedule(...)
AddJob(...)
ListJobsAll(...)
ListJobsBySchedule(...)
ListJobPreparationAndReleaseTaskStatus(...)
GetJob(...)
GetJobTaskCounts(...)
UpdateJob(...)
PatchJob(...)
EnableJob(...)
DisableJob(...)
TerminateJob(...)
DeleteJob(...)
ListTasks(...)
ListNodeFilesByTask(...)
GetTask(...)
ListSubtasks(...)
GetNodeFileByTask()
GetNodeFilePropertiesByTask()
AddTask(...)
TerminateTask(...)
DeleteTask(...)
ReactivateTask(...)
ListPools(...)
GetPool(...)
PoolExists()
AddPool(...)
UpdatePool(...)
PatchPool(...)
DeletePool(...)
ResizePool(...)
StopResizePool(...)
EnableAutoScale(...)
DisableAutoScale(...)
EvaluateAutoScale(...)
ListComputeNodes(...)
RemovePoolComputeNodes(...)
AddComputeNodeUser(...)
UpdateComputeNodeUser(...)
DeleteComputeNodeUser(...)
UploadBatchServiceLogs(...)
GetComputeNodeRDPFile()
GetRemoteLoginSettings(...)
RebootComputeNode(...)
ReimageComputeNode(...)
DeleteNodeFileByTask(...)
GetComputeNode(...)
EnableComputeNodeScheduling(...)
DisableComputeNodeScheduling(...)
UpdateTask(...)
DeleteNodeFileByNode(...)
GetNodeFileByNode()
GetNodeFilePropertiesByNode()
ListNodeFilesByNode(...)
GetAllJobLifetimeStats(...)
GetAllPoolLifetimeStats(...)
GetCertificate(...)
ListPoolUsageMetrics(...)
ListSupportedImages(...)
ListCertificates(...)
AddCertificate(...)
DeleteCertificate(...)
CancelDeleteCertificate(...)
AddTaskCollection(...)
GetApplicationSummary(...)
ListApplicationSummaries(...)
ListPoolNodeCounts(...)
CopyStreamAsync()
ExecuteRequestInterceptors(...)
ExecuteResponseInterceptors()
ProcessAndExecuteBatchRequest()
ValidateReturnObject(...)
Dispose()
Dispose(...)