< Summary

Class:Microsoft.Azure.Batch.CloudTask
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\CloudTask.cs
C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\CloudTask.cs
Covered lines:201
Uncovered lines:286
Coverable lines:487
Total lines:1106
Line coverage:41.2% (201 of 487)
Covered branches:4
Total branches:12
Branch coverage:33.3% (4 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_State()-100%100%
get_StateTransitionTime()-100%100%
get_Statistics()-100%100%
get_Url()-100%100%
get_UserIdentity()-100%100%
set_UserIdentity(...)-100%100%
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()-100%100%
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()-100%100%
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)-100%100%
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.TaskAddParameter>.GetTransportObject()-100%100%
.ctor(...)-100%100%
get_BindingState()-100%100%
StageFilesAsync()-95.65%40%
.ctor()-96.67%25%
StageFiles()-66.67%100%
.ctor(...)-99.09%0%
ListNodeFiles(...)-100%100%
ListSubtasks(...)-100%100%
CommitAsync()-100%0%
Commit(...)-100%100%
TerminateAsync(...)-40%100%
get_ParentJobId()-100%100%
Terminate(...)-100%100%
.ctor(...)-100%100%
DeleteAsync(...)-0%100%
get_CustomBehaviors()-0%100%
Delete(...)-66.67%100%
get_AffinityInformation()-100%100%
set_AffinityInformation(...)-100%100%
get_ApplicationPackageReferences()-100%100%
set_ApplicationPackageReferences(...)-100%100%
ReactivateAsync(...)-25%100%
get_AuthenticationTokenSettings()-100%100%
set_AuthenticationTokenSettings(...)-100%100%
get_CommandLine()-100%100%
set_CommandLine(...)-100%100%
get_ComputeNodeInformation()-100%100%
Reactivate(...)-0%100%
get_Constraints()-100%100%
set_Constraints(...)-100%100%
GetNodeFileAsync(...)-40%100%
get_ContainerSettings()-100%100%
set_ContainerSettings(...)-100%100%
get_CreationTime()-100%100%
GetNodeFile(...)-0%100%
get_DependsOn()-100%100%
set_DependsOn(...)-100%100%
get_DisplayName()-100%100%
set_DisplayName(...)-100%100%
CopyNodeFileContentToStreamAsync(...)-30%100%
get_EnvironmentSettings()-100%100%
set_EnvironmentSettings(...)-100%100%
get_ETag()-100%100%
get_ExecutionInformation()-100%100%
CopyNodeFileContentToStream(...)-0%100%
get_ExitConditions()-100%100%
set_ExitConditions(...)-100%100%
get_FilesToStage()-100%100%
set_FilesToStage(...)-100%100%
CopyNodeFileContentToStringAsync(...)-22.22%100%
get_Id()-100%100%
set_Id(...)-100%100%
get_LastModified()-100%100%
get_MultiInstanceSettings()-100%100%
set_MultiInstanceSettings(...)-100%100%
CopyNodeFileContentToString(...)-0%100%
get_OutputFiles()-100%100%
set_OutputFiles(...)-100%100%
RefreshAsync()-21.43%100%
get_PreviousState()-100%100%
get_PreviousStateTransitionTime()-100%100%
Refresh(...)-33.33%100%
get_ResourceFiles()-100%100%
set_ResourceFiles(...)-100%100%
.ctor()-0%100%
.ctor(...)-0%100%
get_ParentJobId()-0%100%
.ctor(...)-0%100%
get_CustomBehaviors()-0%100%
get_AffinityInformation()-0%100%
set_AffinityInformation(...)-0%100%
get_ApplicationPackageReferences()-0%100%
set_ApplicationPackageReferences(...)-0%100%
get_AuthenticationTokenSettings()-0%100%
set_AuthenticationTokenSettings(...)-0%100%
get_CommandLine()-0%100%
set_CommandLine(...)-0%100%
get_ComputeNodeInformation()-0%100%
get_Constraints()-0%100%
set_Constraints(...)-0%100%
get_ContainerSettings()-0%100%
set_ContainerSettings(...)-0%100%
get_CreationTime()-0%100%
get_DependsOn()-0%100%
set_DependsOn(...)-0%100%
get_DisplayName()-0%100%
set_DisplayName(...)-0%100%
get_EnvironmentSettings()-0%100%
set_EnvironmentSettings(...)-0%100%
get_ETag()-0%100%
get_ExecutionInformation()-0%100%
get_ExitConditions()-0%100%
set_ExitConditions(...)-0%100%
get_FilesToStage()-0%100%
set_FilesToStage(...)-0%100%
get_Id()-0%100%
set_Id(...)-0%100%
get_LastModified()-0%100%
get_MultiInstanceSettings()-0%100%
set_MultiInstanceSettings(...)-0%100%
get_OutputFiles()-0%100%
set_OutputFiles(...)-0%100%
get_PreviousState()-0%100%
get_PreviousStateTransitionTime()-0%100%
get_ResourceFiles()-0%100%
set_ResourceFiles(...)-0%100%
get_State()-0%100%
get_StateTransitionTime()-0%100%
get_Statistics()-0%100%
get_Url()-0%100%
get_UserIdentity()-0%100%
set_UserIdentity(...)-0%100%
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()-0%100%
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()-0%100%
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)-0%100%
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.TaskAddParameter>.GetTransportObject()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\CloudTask.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
 4using System.IO;
 5using System.Text;
 6
 7namespace Microsoft.Azure.Batch
 8{
 9    using System;
 10    using System.Collections.Concurrent;
 11    using System.Collections.Generic;
 12    using System.Threading;
 13    using System.Threading.Tasks;
 14    using Microsoft.Azure.Batch.Common;
 15    using Microsoft.Azure.Batch.FileStaging;
 16    using Microsoft.Rest.Azure;
 17    using Models = Microsoft.Azure.Batch.Protocol.Models;
 18
 19    /// <summary>
 20    /// An Azure Batch task.  A task is a piece of work that is associated with a job and runs on a compute node.
 21    /// </summary>
 22    public partial class CloudTask : IRefreshable
 23    {
 24#region // Constructors
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="CloudTask"/> class.
 28        /// </summary>
 29        /// <param name="id">The id of the task.</param>
 30        /// <param name="commandline">The command line of the task.</param>
 31        /// <remarks>The newly created CloudTask is initially not associated with any task in the Batch service.
 32        /// To associate it with a job and submit it to the Batch service, use <see cref="JobOperations.AddTaskAsync(str
 102633        public CloudTask(string id, string commandline)
 34        {
 102635            this.propertyContainer = new PropertyContainer();
 36
 37            // set initial conditions
 102638            this.Id = id;
 102639            this.CommandLine = commandline;
 40
 41            // set up custom behaviors
 102642            InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, null);
 102643        }
 44
 45#endregion // Constructors
 46
 47        internal BindingState BindingState
 48        {
 90849            get { return this.propertyContainer.BindingState; }
 50        }
 51
 52        /// <summary>
 53        /// Stages the files listed in the <see cref="FilesToStage"/> list.
 54        /// </summary>
 55        /// <param name="allFileStagingArtifacts">An optional collection to customize and receive information about the 
 56        /// For more information see <see cref="IFileStagingArtifact"/>.</param>
 57        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
 58        /// <remarks>The staging operation runs asynchronously.</remarks>
 59        public async System.Threading.Tasks.Task StageFilesAsync(ConcurrentDictionary<Type, IFileStagingArtifact> allFil
 60        {
 61            // stage all these files
 62            // TODO: align this copy with threadsafe implementation of the IList<>
 863            List<IFileStagingProvider> allFiles = this.FilesToStage == null ? new List<IFileStagingProvider>() : new Lis
 64
 65            //TODO: There is a threading issue doing this - expose a change tracking box directly and use a lock?
 866            if (this.FilesToStage != null && this.ResourceFiles == null)
 102667            {
 068                this.ResourceFiles = new List<ResourceFile>(); //We're about to have some resource files
 102669            }
 102670
 102671            // now we have all files, send off to file staging machine
 103472            System.Threading.Tasks.Task fileStagingTask = FileStagingUtils.StageFilesAsync(allFiles, allFileStagingArtif
 102673
 102674            // wait for file staging async task
 103475            await fileStagingTask.ConfigureAwait(continueOnCapturedContext: false);
 102676
 102677            // now update Task with its new ResourceFiles
 102678            foreach (IFileStagingProvider curFile in allFiles)
 102679            {
 102680                IEnumerable<ResourceFile> curStagedFiles = curFile.StagedFiles;
 102681
 102682                foreach (ResourceFile curStagedFile in curStagedFiles)
 102683                {
 102684                    this.ResourceFiles.Add(curStagedFile);
 102685                }
 102686            }
 103487        }
 102688
 102689        /// <summary>
 102690        /// Stages the files listed in the <see cref="FilesToStage"/> list.
 102691        /// </summary>
 102692        /// <returns>A collection of information about the file staging process.
 102693        /// For more information see <see cref="IFileStagingArtifact"/>.</returns>
 102694        /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="StageFilesAsync"/>.</re
 102695        public ConcurrentDictionary<Type, IFileStagingArtifact> StageFiles()
 102696        {
 097            ConcurrentDictionary<Type, IFileStagingArtifact> allFileStagingArtifacts = new ConcurrentDictionary<Type,IFi
 102198
 099            Task asyncTask = StageFilesAsync(allFileStagingArtifacts);
 1021100            asyncTask.WaitAndUnaggregateException();
 1530101
 1021102            return allFileStagingArtifacts;
 1021103        }
 1021104
 1021105        /// <summary>
 1021106        /// Enumerates the files in the <see cref="CloudTask"/>'s directory on its compute node.
 1021107        /// </summary>
 1021108        /// <param name="recursive">If true, performs a recursive list of all files of the task. If false, returns only 
 1532109        /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which 
 1021110        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021111        /// <returns>An <see cref="IPagedEnumerable{NodeFile}"/> that can be used to enumerate files asynchronously or s
 1021112        /// <remarks>This method returns immediately; the file data is retrieved from the Batch service only when the co
 1021113        /// Retrieval is non-atomic; file data is retrieved in pages during enumeration of the collection.</remarks>
 1021114        public IPagedEnumerable<NodeFile> ListNodeFiles(bool? recursive = null, DetailLevel detailLevel = null, IEnumera
 1021115        {
 1021116            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 1506117
 1021118            // craft the behavior manager for this call
 1021119            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 1021120
 1527121            IPagedEnumerable<NodeFile> enumerator = this.parentBatchClient.JobOperations.ListNodeFilesImpl(this.parentJo
 1021122
 1021123            return enumerator;
 1021124        }
 1516125
 1021126        /// <summary>
 1021127        /// Enumerates the subtasks of the multi-instance <see cref="CloudTask"/>.
 1021128        /// </summary>
 1021129        /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which 
 1021130        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021131        /// <returns>An <see cref="IPagedEnumerable{SubtaskInformation}"/> that can be used to enumerate files asynchron
 1021132        /// <remarks>This method returns immediately; the file data is retrieved from the Batch service only when the co
 1528133        /// Retrieval is non-atomic; file data is retrieved in pages during enumeration of the collection.</remarks>
 1021134        public IPagedEnumerable<SubtaskInformation> ListSubtasks(DetailLevel detailLevel = null, IEnumerable<BatchClient
 1021135        {
 1021136            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 1021137
 1021138            // craft the behavior manager for this call
 1021139            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 1021140
 1021141            IPagedEnumerable<SubtaskInformation> enumerator = this.parentBatchClient.JobOperations.ListSubtasksImpl(this
 1021142
 1021143            return enumerator;
 1021144        }
 1021145
 1021146        /// <summary>
 1021147        /// Commits all pending changes to this <see cref="CloudTask" /> to the Azure Batch service.
 1021148        /// </summary>
 1539149        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021150        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 1021151        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 1021152        /// <remarks>The commit operation runs asynchronously.</remarks>
 1525153        public async System.Threading.Tasks.Task CommitAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null
 1021154        {
 1021155            this.propertyContainer.IsReadOnly = true;
 1021156
 1021157            // craft the behavior manager for this call
 1021158            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 1021159
 1021160            if (BindingState.Unbound == this.propertyContainer.BindingState)
 1021161            {
 1021162                //TODO: Implement task submission via .Commit here
 1021163                UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 1021164            }
 1021165            else
 1021166            {
 1021167                Models.TaskConstraints protoTaskConstraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constrain
 1539168
 1021169                System.Threading.Tasks.Task<AzureOperationHeaderResponse<Models.TaskUpdateHeaders>> asyncTaskUpdate =
 1021170                    this.parentBatchClient.ProtocolLayer.UpdateTask(
 1021171                        this.parentJobId,
 1021172                        this.Id,
 1021173                        protoTaskConstraints,
 1021174                        bhMgr,
 1021175                        cancellationToken);
 1021176
 1021177                await asyncTaskUpdate.ConfigureAwait(continueOnCapturedContext: false);
 1021178            }
 1021179        }
 1021180
 1021181        /// <summary>
 1021182        /// Commits all pending changes to this <see cref="CloudTask" /> to the Azure Batch service.
 1021183        /// </summary>
 1021184        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021185        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 1021186        /// <remarks>
 1021187        /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="CommitAsync"/>.</para>
 1021188        /// </remarks>
 1021189        public void Commit(IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 1021190        {
 1021191            Task asyncTask = CommitAsync(additionalBehaviors);
 1021192            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 1021193        }
 1021194
 1021195        /// <summary>
 1498196        /// Terminates this <see cref="CloudTask"/>, marking it as completed.
 1021197        /// </summary>
 1021198        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021199        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 1021200        /// <returns>A <see cref="Task"/> object that represents the asynchronous operation.</returns>
 1021201        /// <remarks>The terminate operation runs asynchronously.</remarks>
 1021202        public System.Threading.Tasks.Task TerminateAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, C
 1021203        {
 1526204            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 1021205
 1021206            // create the behavior manager
 1021207            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 208
 0209            System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.TerminateTask(
 0210                this.parentJobId,
 0211                this.Id,
 0212                bhMgr,
 0213                cancellationToken);
 214
 0215            return asyncTask;
 216        }
 217
 218        /// <summary>
 6219        /// Terminates this <see cref="CloudTask"/>, marking it as completed.
 220        /// </summary>
 221        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 222        /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="TerminateAsync"/>.</rem
 223        public void Terminate(IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 224        {
 1021225            Task asyncTask = TerminateAsync(additionalBehaviors);
 1021226            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 1021227        }
 1021228
 1021229
 230        /// <summary>
 1021231        /// Deletes this <see cref="CloudTask"/>.
 1021232        /// </summary>
 1021233        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 1021234        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 1021235        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
 236        /// <remarks>The delete operation runs asynchronously.</remarks>
 237        public System.Threading.Tasks.Task DeleteAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, Canc
 238        {
 0239            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 240
 241            // create the behavior manager
 0242            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 243
 0244            System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.DeleteTask(
 0245                this.parentJobId,
 0246                this.Id,
 0247                bhMgr,
 0248                cancellationToken);
 0249
 0250            return asyncTask;
 251        }
 252
 253        /// <summary>
 254        /// Deletes this <see cref="CloudTask"/>.
 255        /// </summary>
 256        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 257        /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeleteAsync"/>.</remark
 258        public void Delete(IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 259        {
 2111260            Task asyncTask = DeleteAsync(additionalBehaviors);
 107261            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0262        }
 263
 264        /// <summary>
 265        /// Reactivates this <see cref="CloudTask"/>, allowing it to run again even if its retry count has been exhauste
 266        /// </summary>
 267        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 268        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 269        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
 2111270        /// <remarks>
 271        /// <para>
 272        /// Reactivation makes a task eligible to be retried again up to its maximum retry count.
 45273        /// </para>
 44274        /// <para>
 275        /// This operation will fail for tasks that are not completed or that previously completed successfully (with an
 276        /// Additionally, this will fail if the job is in the <see cref="JobState.Completed"/> or <see cref="JobState.Te
 277        /// </para>
 278        /// <para>
 279        /// The reactivate operation runs asynchronously.
 280        /// </para>
 281        /// </remarks>
 282        public System.Threading.Tasks.Task ReactivateAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, 
 283        {
 0284            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 285
 286            // create the behavior manager
 0287            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 288
 2111289            System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.ReactivateTask(
 93290                this.parentJobId,
 0291                this.Id,
 0292                bhMgr,
 0293                cancellationToken);
 294
 0295            return asyncTask;
 296        }
 297
 298        /// <summary>
 299        /// Reactivates this <see cref="CloudTask"/>, allowing it to run again even if its retry count has been exhauste
 300        /// </summary>
 301        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 302        /// <remarks>
 303        /// <para>
 304        /// Reactivation makes a task eligible to be retried again up to its maximum retry count.
 2111305        /// </para>
 2154306        /// <para>
 307        /// This operation will fail for tasks that are not completed or that previously completed successfully (with an
 308        /// Additionally, this will fail if the job is in the <see cref="JobState.Completed"/> or <see cref="JobState.Te
 309        /// </para>
 310        /// <para>
 311        /// This is a blocking operation. For a non-blocking equivalent, see <see cref="ReactivateAsync"/>.
 312        /// </para>
 313        /// </remarks>
 1001314        public void Reactivate(IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 315        {
 0316            Task asyncTask = ReactivateAsync(additionalBehaviors);
 0317            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0318        }
 319
 320        /// <summary>
 321        /// Gets the specified <see cref="NodeFile"/> from the <see cref="CloudTask"/>'s directory on its compute node.
 2113322        /// </summary>
 91323        /// <param name="filePath">The path of the file to retrieve.</param>
 324        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 325        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 326        /// <returns>A <see cref="NodeFile"/> representing the specified file.</returns>
 327        /// <remarks>The get file operation runs asynchronously.</remarks>
 328        public System.Threading.Tasks.Task<NodeFile> GetNodeFileAsync(
 329            string filePath,
 330            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 331            CancellationToken cancellationToken = default(CancellationToken))
 332        {
 0333            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 334
 335            //create the behavior manager
 0336            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 337
 338            //make the call
 0339            System.Threading.Tasks.Task<NodeFile> asyncTask = this.parentBatchClient.JobOperations.GetNodeFileAsyncImpl(
 2111340
 87341            return asyncTask;
 342        }
 343
 344
 345        /// <summary>
 346        /// Gets the specified <see cref="NodeFile"/> from the <see cref="CloudTask"/>'s directory on its compute node.
 347        /// </summary>
 348        /// <param name="filePath">The path of the file to retrieve.</param>
 1001349        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 350        /// <returns>A <see cref="NodeFile"/> representing the specified file.</returns>
 351        /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetNodeFileAsync"/>.</r
 352        public NodeFile GetNodeFile(string filePath, IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 353        {
 0354            Task<NodeFile> asyncTask = this.GetNodeFileAsync(filePath, additionalBehaviors);
 0355            NodeFile file = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 356
 0357            return file;
 358        }
 359
 360        /// <summary>
 361        /// Copies the contents of a file in the task's directory from the node to the given <see cref="Stream"/>.
 2112362        /// </summary>
 107363        /// <param name="filePath">The path of the file to retrieve.</param>
 364        /// <param name="stream">The stream to copy the file contents to.</param>
 365        /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file 
 366        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 367        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 368        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 369        public Task CopyNodeFileContentToStreamAsync(
 370            string filePath,
 2111371            Stream stream,
 101372            GetFileRequestByteRange byteRange = null,
 373            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 374            CancellationToken cancellationToken = default(CancellationToken))
 375        {
 376            // create the behavior manager
 0377            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 0378            Task asyncTask = this.parentBatchClient.JobOperations.CopyNodeFileContentToStreamAsyncImpl(
 0379                this.parentJobId,
 2111380                this.Id,
 0381                filePath,
 0382                stream,
 45383                byteRange,
 44384                bhMgr,
 0385                cancellationToken);
 386
 0387            return asyncTask;
 388        }
 389
 390        /// <summary>
 391        /// Copies the contents of a file in the task's directory from the node to the given <see cref="Stream"/>.
 1001392        /// </summary>
 393        /// <param name="filePath">The path of the file to retrieve.</param>
 394        /// <param name="stream">The stream to copy the file contents to.</param>
 395        /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file 
 396        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 397        /// <returns>A bound <see cref="NodeFile"/> object.</returns>
 398        public void CopyNodeFileContentToStream(
 399            string filePath,
 1001400            Stream stream,
 401            GetFileRequestByteRange byteRange = null,
 402            IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 403        {
 0404            Task asyncTask = this.CopyNodeFileContentToStreamAsync(filePath, stream, byteRange, additionalBehaviors);
 0405            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0406        }
 407
 2115408        /// <summary>
 102409        /// Reads the contents of a file in the task's directory on its compute node into a string.
 410        /// </summary>
 411        /// <param name="filePath">The path of the file to retrieve.</param>
 412        /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param>
 413        /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file 
 414        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 415        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 416        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</ret
 1821417        public Task<string> CopyNodeFileContentToStringAsync(
 418            string filePath,
 419            Encoding encoding = null,
 45420            GetFileRequestByteRange byteRange = null,
 44421            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 422            CancellationToken cancellationToken = default(CancellationToken))
 423        {
 424            // create the behavior manager
 0425            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 0426            return this.parentBatchClient.JobOperations.CopyNodeFileContentToStringAsyncImpl(
 0427                this.parentJobId,
 0428                this.Id,
 3034429                filePath,
 2127430                encoding,
 0431                byteRange,
 0432                bhMgr,
 0433                cancellationToken);
 434        }
 435
 436        /// <summary>
 437        /// Reads the contents of a file in the task's directory on its compute node into a string.
 1001438        /// </summary>
 439        /// <param name="filePath">The path of the file to retrieve.</param>
 440        /// <param name="encoding">The encoding to use. If no value or null is specified, UTF8 is used.</param>
 441        /// <param name="byteRange">A byte range defining what section of the file to copy. If omitted, the entire file 
 442        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the C
 443        /// <returns>A bound <see cref="NodeFile"/> object.</returns>
 444        public string CopyNodeFileContentToString(
 445            string filePath,
 2111446            Encoding encoding = null,
 65447            GetFileRequestByteRange byteRange = null,
 448            IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 449        {
 0450            Task<string> asyncTask = this.CopyNodeFileContentToStringAsync(filePath, encoding, byteRange, additionalBeha
 0451            return asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 452        }
 453
 454        #region IRefreshable
 455
 2111456        /// <summary>
 457        /// Refreshes the current <see cref="CloudTask"/>.
 458        /// </summary>
 57459        /// <param name="detailLevel">The detail level for the refresh.  If a detail level which omits the <see cref="Id
 56460        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 461        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 462        /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns>
 463        public async System.Threading.Tasks.Task RefreshAsync(
 464            DetailLevel detailLevel = null,
 465            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 466            CancellationToken cancellationToken = default(CancellationToken))
 467        {
 1468            UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState);
 469
 470            // create the behavior managaer
 0471            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel);
 1001472
 0473            System.Threading.Tasks.Task<AzureOperationResponse<Models.CloudTask, Models.TaskGetHeaders>> asyncTask =
 0474                this.parentBatchClient.ProtocolLayer.GetTask(
 0475                    this.parentJobId,
 0476                    this.Id,
 0477                    bhMgr,
 0478                    cancellationToken);
 479
 0480            AzureOperationResponse<Models.CloudTask, Models.TaskGetHeaders> response = await asyncTask.ConfigureAwait(co
 481
 482            // get task from response
 0483            Models.CloudTask newProtocolTask = response.Body;
 1001484
 485            // immediately available to all threads
 0486            this.propertyContainer = new PropertyContainer(newProtocolTask);
 0487        }
 488
 489        /// <summary>
 490        /// Refreshes the current <see cref="CloudTask"/>.
 491        /// </summary>
 492        /// <param name="detailLevel">The detail level for the refresh.  If a detail level which omits the <see cref="Id
 493        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 494        public void Refresh(
 495            DetailLevel detailLevel = null,
 496            IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 497        {
 2111498            Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors);
 0499            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0500        }
 48501
 47502        #endregion IRefreshable
 503    }
 504}

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Generated\CloudTask.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//
 4// Code generated by Microsoft (R) AutoRest Code Generator.
 5// Changes may cause incorrect behavior and will be lost if the code is
 6// regenerated.
 7
 8//
 9// This file was autogenerated by a tool.
 10// Do not modify it.
 11//
 12
 13namespace Microsoft.Azure.Batch
 14{
 15    using FileStaging;
 16    using Models = Microsoft.Azure.Batch.Protocol.Models;
 17    using System;
 18    using System.Collections.Generic;
 19    using System.Linq;
 20
 21    /// <summary>
 22    /// An Azure Batch task. A task is a piece of work that is associated with a job and runs on a compute node.
 23    /// </summary>
 24    /// <remarks>
 25    /// Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery operations
 26    /// include (but are not limited to) when an unhealthy compute node is rebooted or a compute node disappeared due to
 27    /// host failure. Retries due to recovery operations are independent of and are not counted against the <see cref="T
 28    /// />. Even if the <see cref="TaskConstraints.MaxTaskRetryCount" /> is 0, an internal retry due to a recovery opera
 29    /// may occur. Because of this, all tasks should be idempotent. This means tasks need to tolerate being interrupted 
 30    /// restarted without causing any corruption or duplicate data. The best practice for long running tasks is to use s
 31    /// form of checkpointing. The maximum lifetime of a task from addition to completion is 180 days. If a task has not
 32    /// completed within 180 days of being added it will be terminated by the Batch service and left in whatever state i
 33    /// was in at that time.
 34    /// </remarks>
 35    public partial class CloudTask : ITransportObjectProvider<Models.TaskAddParameter>, IInheritedBehaviors, IPropertyMe
 36    {
 37        private class PropertyContainer : PropertyCollection
 38        {
 39            public readonly PropertyAccessor<AffinityInformation> AffinityInformationProperty;
 40            public readonly PropertyAccessor<IList<ApplicationPackageReference>> ApplicationPackageReferencesProperty;
 41            public readonly PropertyAccessor<AuthenticationTokenSettings> AuthenticationTokenSettingsProperty;
 42            public readonly PropertyAccessor<string> CommandLineProperty;
 43            public readonly PropertyAccessor<ComputeNodeInformation> ComputeNodeInformationProperty;
 44            public readonly PropertyAccessor<TaskConstraints> ConstraintsProperty;
 45            public readonly PropertyAccessor<TaskContainerSettings> ContainerSettingsProperty;
 46            public readonly PropertyAccessor<DateTime?> CreationTimeProperty;
 47            public readonly PropertyAccessor<TaskDependencies> DependsOnProperty;
 48            public readonly PropertyAccessor<string> DisplayNameProperty;
 49            public readonly PropertyAccessor<IList<EnvironmentSetting>> EnvironmentSettingsProperty;
 50            public readonly PropertyAccessor<string> ETagProperty;
 51            public readonly PropertyAccessor<TaskExecutionInformation> ExecutionInformationProperty;
 52            public readonly PropertyAccessor<ExitConditions> ExitConditionsProperty;
 53            public readonly PropertyAccessor<IList<IFileStagingProvider>> FilesToStageProperty;
 54            public readonly PropertyAccessor<string> IdProperty;
 55            public readonly PropertyAccessor<DateTime?> LastModifiedProperty;
 56            public readonly PropertyAccessor<MultiInstanceSettings> MultiInstanceSettingsProperty;
 57            public readonly PropertyAccessor<IList<OutputFile>> OutputFilesProperty;
 58            public readonly PropertyAccessor<Common.TaskState?> PreviousStateProperty;
 59            public readonly PropertyAccessor<DateTime?> PreviousStateTransitionTimeProperty;
 60            public readonly PropertyAccessor<IList<ResourceFile>> ResourceFilesProperty;
 61            public readonly PropertyAccessor<Common.TaskState?> StateProperty;
 62            public readonly PropertyAccessor<DateTime?> StateTransitionTimeProperty;
 63            public readonly PropertyAccessor<TaskStatistics> StatisticsProperty;
 64            public readonly PropertyAccessor<string> UrlProperty;
 65            public readonly PropertyAccessor<UserIdentity> UserIdentityProperty;
 66
 067            public PropertyContainer() : base(BindingState.Unbound)
 68            {
 069                this.AffinityInformationProperty = this.CreatePropertyAccessor<AffinityInformation>(nameof(AffinityInfor
 070                this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor<IList<ApplicationPackageReferenc
 071                this.AuthenticationTokenSettingsProperty = this.CreatePropertyAccessor<AuthenticationTokenSettings>(name
 072                this.CommandLineProperty = this.CreatePropertyAccessor<string>(nameof(CommandLine), BindingAccess.Read |
 073                this.ComputeNodeInformationProperty = this.CreatePropertyAccessor<ComputeNodeInformation>(nameof(Compute
 074                this.ConstraintsProperty = this.CreatePropertyAccessor<TaskConstraints>(nameof(Constraints), BindingAcce
 075                this.ContainerSettingsProperty = this.CreatePropertyAccessor<TaskContainerSettings>(nameof(ContainerSett
 076                this.CreationTimeProperty = this.CreatePropertyAccessor<DateTime?>(nameof(CreationTime), BindingAccess.N
 077                this.DependsOnProperty = this.CreatePropertyAccessor<TaskDependencies>(nameof(DependsOn), BindingAccess.
 078                this.DisplayNameProperty = this.CreatePropertyAccessor<string>(nameof(DisplayName), BindingAccess.Read |
 079                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor<IList<EnvironmentSetting>>(nameof(Environ
 080                this.ETagProperty = this.CreatePropertyAccessor<string>(nameof(ETag), BindingAccess.None);
 081                this.ExecutionInformationProperty = this.CreatePropertyAccessor<TaskExecutionInformation>(nameof(Executi
 082                this.ExitConditionsProperty = this.CreatePropertyAccessor<ExitConditions>(nameof(ExitConditions), Bindin
 083                this.FilesToStageProperty = this.CreatePropertyAccessor<IList<IFileStagingProvider>>(nameof(FilesToStage
 084                this.IdProperty = this.CreatePropertyAccessor<string>(nameof(Id), BindingAccess.Read | BindingAccess.Wri
 085                this.LastModifiedProperty = this.CreatePropertyAccessor<DateTime?>(nameof(LastModified), BindingAccess.N
 086                this.MultiInstanceSettingsProperty = this.CreatePropertyAccessor<MultiInstanceSettings>(nameof(MultiInst
 087                this.OutputFilesProperty = this.CreatePropertyAccessor<IList<OutputFile>>(nameof(OutputFiles), BindingAc
 088                this.PreviousStateProperty = this.CreatePropertyAccessor<Common.TaskState?>(nameof(PreviousState), Bindi
 089                this.PreviousStateTransitionTimeProperty = this.CreatePropertyAccessor<DateTime?>(nameof(PreviousStateTr
 090                this.ResourceFilesProperty = this.CreatePropertyAccessor<IList<ResourceFile>>(nameof(ResourceFiles), Bin
 091                this.StateProperty = this.CreatePropertyAccessor<Common.TaskState?>(nameof(State), BindingAccess.None);
 092                this.StateTransitionTimeProperty = this.CreatePropertyAccessor<DateTime?>(nameof(StateTransitionTime), B
 093                this.StatisticsProperty = this.CreatePropertyAccessor<TaskStatistics>(nameof(Statistics), BindingAccess.
 094                this.UrlProperty = this.CreatePropertyAccessor<string>(nameof(Url), BindingAccess.None);
 095                this.UserIdentityProperty = this.CreatePropertyAccessor<UserIdentity>(nameof(UserIdentity), BindingAcces
 096            }
 97
 098            public PropertyContainer(Models.CloudTask protocolObject) : base(BindingState.Bound)
 99            {
 0100                this.AffinityInformationProperty = this.CreatePropertyAccessor(
 0101                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.AffinityInfo, o => new AffinityInformatio
 0102                    nameof(AffinityInformation),
 0103                    BindingAccess.Read);
 0104                this.ApplicationPackageReferencesProperty = this.CreatePropertyAccessor(
 0105                    ApplicationPackageReference.ConvertFromProtocolCollectionAndFreeze(protocolObject.ApplicationPackage
 0106                    nameof(ApplicationPackageReferences),
 0107                    BindingAccess.Read);
 0108                this.AuthenticationTokenSettingsProperty = this.CreatePropertyAccessor(
 0109                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.AuthenticationTokenSettings, o => new Aut
 0110                    nameof(AuthenticationTokenSettings),
 0111                    BindingAccess.Read);
 0112                this.CommandLineProperty = this.CreatePropertyAccessor(
 0113                    protocolObject.CommandLine,
 0114                    nameof(CommandLine),
 0115                    BindingAccess.Read);
 0116                this.ComputeNodeInformationProperty = this.CreatePropertyAccessor(
 0117                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.NodeInfo, o => new ComputeNodeInformation
 0118                    nameof(ComputeNodeInformation),
 0119                    BindingAccess.Read);
 0120                this.ConstraintsProperty = this.CreatePropertyAccessor(
 0121                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.Constraints, o => new TaskConstraints(o))
 0122                    nameof(Constraints),
 0123                    BindingAccess.Read | BindingAccess.Write);
 0124                this.ContainerSettingsProperty = this.CreatePropertyAccessor(
 0125                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ContainerSettings, o => new TaskContainer
 0126                    nameof(ContainerSettings),
 0127                    BindingAccess.Read);
 0128                this.CreationTimeProperty = this.CreatePropertyAccessor(
 0129                    protocolObject.CreationTime,
 0130                    nameof(CreationTime),
 0131                    BindingAccess.Read);
 0132                this.DependsOnProperty = this.CreatePropertyAccessor(
 0133                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.DependsOn, o => new TaskDependencies(o).F
 0134                    nameof(DependsOn),
 0135                    BindingAccess.Read);
 0136                this.DisplayNameProperty = this.CreatePropertyAccessor(
 0137                    protocolObject.DisplayName,
 0138                    nameof(DisplayName),
 0139                    BindingAccess.Read);
 0140                this.EnvironmentSettingsProperty = this.CreatePropertyAccessor(
 0141                    EnvironmentSetting.ConvertFromProtocolCollectionAndFreeze(protocolObject.EnvironmentSettings),
 0142                    nameof(EnvironmentSettings),
 0143                    BindingAccess.Read);
 0144                this.ETagProperty = this.CreatePropertyAccessor(
 0145                    protocolObject.ETag,
 0146                    nameof(ETag),
 0147                    BindingAccess.Read);
 0148                this.ExecutionInformationProperty = this.CreatePropertyAccessor(
 0149                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ExecutionInfo, o => new TaskExecutionInfo
 0150                    nameof(ExecutionInformation),
 0151                    BindingAccess.Read);
 0152                this.ExitConditionsProperty = this.CreatePropertyAccessor(
 0153                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ExitConditions, o => new ExitConditions(o
 0154                    nameof(ExitConditions),
 0155                    BindingAccess.Read);
 0156                this.FilesToStageProperty = this.CreatePropertyAccessor<IList<IFileStagingProvider>>(
 0157                    nameof(FilesToStage),
 0158                    BindingAccess.None);
 0159                this.IdProperty = this.CreatePropertyAccessor(
 0160                    protocolObject.Id,
 0161                    nameof(Id),
 0162                    BindingAccess.Read);
 0163                this.LastModifiedProperty = this.CreatePropertyAccessor(
 0164                    protocolObject.LastModified,
 0165                    nameof(LastModified),
 0166                    BindingAccess.Read);
 0167                this.MultiInstanceSettingsProperty = this.CreatePropertyAccessor(
 0168                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.MultiInstanceSettings, o => new MultiInst
 0169                    nameof(MultiInstanceSettings),
 0170                    BindingAccess.Read);
 0171                this.OutputFilesProperty = this.CreatePropertyAccessor(
 0172                    OutputFile.ConvertFromProtocolCollectionAndFreeze(protocolObject.OutputFiles),
 0173                    nameof(OutputFiles),
 0174                    BindingAccess.Read);
 0175                this.PreviousStateProperty = this.CreatePropertyAccessor(
 0176                    UtilitiesInternal.MapNullableEnum<Models.TaskState, Common.TaskState>(protocolObject.PreviousState),
 0177                    nameof(PreviousState),
 0178                    BindingAccess.Read);
 0179                this.PreviousStateTransitionTimeProperty = this.CreatePropertyAccessor(
 0180                    protocolObject.PreviousStateTransitionTime,
 0181                    nameof(PreviousStateTransitionTime),
 0182                    BindingAccess.Read);
 0183                this.ResourceFilesProperty = this.CreatePropertyAccessor(
 0184                    ResourceFile.ConvertFromProtocolCollectionAndFreeze(protocolObject.ResourceFiles),
 0185                    nameof(ResourceFiles),
 0186                    BindingAccess.Read);
 0187                this.StateProperty = this.CreatePropertyAccessor(
 0188                    UtilitiesInternal.MapNullableEnum<Models.TaskState, Common.TaskState>(protocolObject.State),
 0189                    nameof(State),
 0190                    BindingAccess.Read);
 0191                this.StateTransitionTimeProperty = this.CreatePropertyAccessor(
 0192                    protocolObject.StateTransitionTime,
 0193                    nameof(StateTransitionTime),
 0194                    BindingAccess.Read);
 0195                this.StatisticsProperty = this.CreatePropertyAccessor(
 0196                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.Stats, o => new TaskStatistics(o).Freeze(
 0197                    nameof(Statistics),
 0198                    BindingAccess.Read);
 0199                this.UrlProperty = this.CreatePropertyAccessor(
 0200                    protocolObject.Url,
 0201                    nameof(Url),
 0202                    BindingAccess.Read);
 0203                this.UserIdentityProperty = this.CreatePropertyAccessor(
 0204                    UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.UserIdentity, o => new UserIdentity(o).Fr
 0205                    nameof(UserIdentity),
 0206                    BindingAccess.Read);
 0207            }
 208        }
 209
 210        private PropertyContainer propertyContainer;
 211
 212        private readonly BatchClient parentBatchClient;
 213        private readonly string parentJobId;
 214
 215        internal string ParentJobId
 216        {
 217            get
 218            {
 0219                return this.parentJobId;
 220            }
 221        }
 222
 223        #region Constructors
 224
 0225        internal CloudTask(
 0226            BatchClient parentBatchClient,
 0227            string parentJobId,
 0228            Models.CloudTask protocolObject,
 0229            IEnumerable<BatchClientBehavior> baseBehaviors)
 230        {
 0231            this.parentJobId = parentJobId;
 0232            this.parentBatchClient = parentBatchClient;
 0233            InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, baseBehaviors);
 0234            this.propertyContainer = new PropertyContainer(protocolObject);
 0235        }
 236
 237        #endregion Constructors
 238
 239        #region IInheritedBehaviors
 240
 241        /// <summary>
 242        /// Gets or sets a list of behaviors that modify or customize requests to the Batch service
 243        /// made via this <see cref="CloudTask"/>.
 244        /// </summary>
 245        /// <remarks>
 246        /// <para>These behaviors are inherited by child objects.</para>
 247        /// <para>Modifications are applied in the order of the collection. The last write wins.</para>
 248        /// </remarks>
 0249        public IList<BatchClientBehavior> CustomBehaviors { get; set; }
 250
 251        #endregion IInheritedBehaviors
 252
 253        #region CloudTask
 254
 255        /// <summary>
 256        /// Gets or sets a locality hint that can be used by the Batch service to select a node on which to start the ta
 257        /// </summary>
 258        public AffinityInformation AffinityInformation
 259        {
 0260            get { return this.propertyContainer.AffinityInformationProperty.Value; }
 0261            set { this.propertyContainer.AffinityInformationProperty.Value = value; }
 262        }
 263
 264        /// <summary>
 265        /// Gets or sets a list of application packages that the Batch service will deploy to the compute node before ru
 266        /// the command line.
 267        /// </summary>
 268        public IList<ApplicationPackageReference> ApplicationPackageReferences
 269        {
 0270            get { return this.propertyContainer.ApplicationPackageReferencesProperty.Value; }
 271            set
 272            {
 0273                this.propertyContainer.ApplicationPackageReferencesProperty.Value = ConcurrentChangeTrackedModifiableLis
 0274            }
 275        }
 276
 277        /// <summary>
 278        /// Gets or sets the settings for an authentication token that the task can use to perform Batch service operati
 279        /// </summary>
 280        /// <remarks>
 281        /// If this property is set, the Batch service provides the task with an authentication token which can be used 
 282        /// authenticate Batch service operations without requiring an account access key. The token is provided via the
 283        /// AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the task can carry out using the tok
 284        /// depend on the settings. For example, a task can request job permissions in order to add other tasks to the j
 285        /// or check the status of the job or of other tasks.
 286        /// </remarks>
 287        public AuthenticationTokenSettings AuthenticationTokenSettings
 288        {
 0289            get { return this.propertyContainer.AuthenticationTokenSettingsProperty.Value; }
 0290            set { this.propertyContainer.AuthenticationTokenSettingsProperty.Value = value; }
 291        }
 292
 293        /// <summary>
 294        /// Gets or sets the command line of the task.
 295        /// </summary>
 296        /// <remarks>
 297        /// The command line does not run under a shell, and therefore cannot take advantage of shell features such as e
 298        /// variable expansion. If you want to take advantage of such features, you should invoke the shell in the comma
 299        /// line, for example using \"cmd /c MyCommand\" in Windows or \"/bin/sh -c MyCommand\" in Linux. If the command
 300        /// line refers to file paths, it should use a relative path (relative to the task working directory), or use th
 301        /// Batch provided environment variables (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-enviro
 302        /// </remarks>
 303        public string CommandLine
 304        {
 0305            get { return this.propertyContainer.CommandLineProperty.Value; }
 0306            set { this.propertyContainer.CommandLineProperty.Value = value; }
 307        }
 308
 309        /// <summary>
 310        /// Gets information about the compute node on which the task ran.
 311        /// </summary>
 312        public ComputeNodeInformation ComputeNodeInformation
 313        {
 0314            get { return this.propertyContainer.ComputeNodeInformationProperty.Value; }
 315        }
 316
 317        /// <summary>
 318        /// Gets or sets the execution constraints that apply to this task.
 319        /// </summary>
 320        public TaskConstraints Constraints
 321        {
 0322            get { return this.propertyContainer.ConstraintsProperty.Value; }
 0323            set { this.propertyContainer.ConstraintsProperty.Value = value; }
 324        }
 325
 326        /// <summary>
 327        /// Gets or sets the settings for the container under which the task runs.
 328        /// </summary>
 329        /// <remarks>
 330        /// If the pool that will run this task has <see cref="VirtualMachineConfiguration.ContainerConfiguration"/> set
 331        /// this must be set as well. If the pool that will run this task doesn't have <see cref="VirtualMachineConfigur
 332        /// set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_
 333        /// (the root of Azure Batch directories on the node) are mapped into the container, all task environment variab
 334        /// are mapped into the container, and the task command line is executed in the container. Files produced in the
 335        /// container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file
 336        /// APIs will not be able to access them.
 337        /// </remarks>
 338        public TaskContainerSettings ContainerSettings
 339        {
 0340            get { return this.propertyContainer.ContainerSettingsProperty.Value; }
 0341            set { this.propertyContainer.ContainerSettingsProperty.Value = value; }
 342        }
 343
 344        /// <summary>
 345        /// Gets the creation time of the task.
 346        /// </summary>
 347        public DateTime? CreationTime
 348        {
 0349            get { return this.propertyContainer.CreationTimeProperty.Value; }
 350        }
 351
 352        /// <summary>
 353        /// Gets or sets any other tasks that this <see cref="CloudTask"/> depends on. The task will not be scheduled un
 354        /// all depended-on tasks have completed successfully.
 355        /// </summary>
 356        /// <remarks>
 357        /// The job must set <see cref="CloudJob.UsesTaskDependencies"/> to true in order to use task dependencies. If U
 358        /// is false (the default), adding a task with dependencies will fail with an error.
 359        /// </remarks>
 360        public TaskDependencies DependsOn
 361        {
 0362            get { return this.propertyContainer.DependsOnProperty.Value; }
 0363            set { this.propertyContainer.DependsOnProperty.Value = value; }
 364        }
 365
 366        /// <summary>
 367        /// Gets or sets the display name of the task.
 368        /// </summary>
 369        public string DisplayName
 370        {
 0371            get { return this.propertyContainer.DisplayNameProperty.Value; }
 0372            set { this.propertyContainer.DisplayNameProperty.Value = value; }
 373        }
 374
 375        /// <summary>
 376        /// Gets or sets a list of environment variable settings for the task.
 377        /// </summary>
 378        public IList<EnvironmentSetting> EnvironmentSettings
 379        {
 0380            get { return this.propertyContainer.EnvironmentSettingsProperty.Value; }
 381            set
 382            {
 0383                this.propertyContainer.EnvironmentSettingsProperty.Value = ConcurrentChangeTrackedModifiableList<Environ
 0384            }
 385        }
 386
 387        /// <summary>
 388        /// Gets the ETag for the task.
 389        /// </summary>
 390        public string ETag
 391        {
 0392            get { return this.propertyContainer.ETagProperty.Value; }
 393        }
 394
 395        /// <summary>
 396        /// Gets the execution information for the task.
 397        /// </summary>
 398        public TaskExecutionInformation ExecutionInformation
 399        {
 0400            get { return this.propertyContainer.ExecutionInformationProperty.Value; }
 401        }
 402
 403        /// <summary>
 404        /// Gets or sets how the Batch service should respond when the task completes.
 405        /// </summary>
 406        public ExitConditions ExitConditions
 407        {
 0408            get { return this.propertyContainer.ExitConditionsProperty.Value; }
 0409            set { this.propertyContainer.ExitConditionsProperty.Value = value; }
 410        }
 411
 412        /// <summary>
 413        /// Gets or sets a list of files to be staged for the task.
 414        /// </summary>
 415        public IList<IFileStagingProvider> FilesToStage
 416        {
 0417            get { return this.propertyContainer.FilesToStageProperty.Value; }
 418            set
 419            {
 0420                this.propertyContainer.FilesToStageProperty.Value = ConcurrentChangeTrackedList<IFileStagingProvider>.Tr
 0421            }
 422        }
 423
 424        /// <summary>
 425        /// Gets or sets the id of the task.
 426        /// </summary>
 427        public string Id
 428        {
 0429            get { return this.propertyContainer.IdProperty.Value; }
 0430            set { this.propertyContainer.IdProperty.Value = value; }
 431        }
 432
 433        /// <summary>
 434        /// Gets the last modified time of the task.
 435        /// </summary>
 436        public DateTime? LastModified
 437        {
 0438            get { return this.propertyContainer.LastModifiedProperty.Value; }
 439        }
 440
 441        /// <summary>
 442        /// Gets or sets information about how to run the multi-instance task.
 443        /// </summary>
 444        public MultiInstanceSettings MultiInstanceSettings
 445        {
 0446            get { return this.propertyContainer.MultiInstanceSettingsProperty.Value; }
 0447            set { this.propertyContainer.MultiInstanceSettingsProperty.Value = value; }
 448        }
 449
 450        /// <summary>
 451        /// Gets or sets a list of files that the Batch service will upload from the compute node after running the comm
 452        /// line.
 453        /// </summary>
 454        public IList<OutputFile> OutputFiles
 455        {
 0456            get { return this.propertyContainer.OutputFilesProperty.Value; }
 457            set
 458            {
 0459                this.propertyContainer.OutputFilesProperty.Value = ConcurrentChangeTrackedModifiableList<OutputFile>.Tra
 0460            }
 461        }
 462
 463        /// <summary>
 464        /// Gets the previous state of the task.
 465        /// </summary>
 466        /// <remarks>
 467        /// If the task is in its initial <see cref="Common.TaskState.Active"/> state, the PreviousState property is not
 468        /// defined.
 469        /// </remarks>
 470        public Common.TaskState? PreviousState
 471        {
 0472            get { return this.propertyContainer.PreviousStateProperty.Value; }
 473        }
 474
 475        /// <summary>
 476        /// Gets the time at which the task entered its previous state.
 477        /// </summary>
 478        /// <remarks>
 479        /// If the task is in its initial <see cref="Common.TaskState.Active"/> state, the PreviousStateTransitionTime p
 480        /// is not defined.
 481        /// </remarks>
 482        public DateTime? PreviousStateTransitionTime
 483        {
 0484            get { return this.propertyContainer.PreviousStateTransitionTimeProperty.Value; }
 485        }
 486
 487        /// <summary>
 488        /// Gets or sets a list of files that the Batch service will download to the compute node before running the com
 489        /// line.
 490        /// </summary>
 491        /// <remarks>
 492        /// There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail
 493        /// and the response error code will be RequestEntityTooLarge. If this occurs, the collection of resource files 
 494        /// be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.
 495        /// </remarks>
 496        public IList<ResourceFile> ResourceFiles
 497        {
 0498            get { return this.propertyContainer.ResourceFilesProperty.Value; }
 499            set
 500            {
 0501                this.propertyContainer.ResourceFilesProperty.Value = ConcurrentChangeTrackedModifiableList<ResourceFile>
 0502            }
 503        }
 504
 505        /// <summary>
 506        /// Gets the current state of the task.
 507        /// </summary>
 508        public Common.TaskState? State
 509        {
 0510            get { return this.propertyContainer.StateProperty.Value; }
 511        }
 512
 513        /// <summary>
 514        /// Gets the time at which the task entered its current state.
 515        /// </summary>
 516        public DateTime? StateTransitionTime
 517        {
 0518            get { return this.propertyContainer.StateTransitionTimeProperty.Value; }
 519        }
 520
 521        /// <summary>
 522        /// Gets resource usage statistics for the task.
 523        /// </summary>
 524        /// <remarks>
 525        /// This property is populated only if the <see cref="CloudTask"/> was retrieved with an <see cref="ODATADetailL
 526        /// including the 'stats' attribute; otherwise it is null.
 527        /// </remarks>
 528        public TaskStatistics Statistics
 529        {
 0530            get { return this.propertyContainer.StatisticsProperty.Value; }
 531        }
 532
 533        /// <summary>
 534        /// Gets the URL of the task.
 535        /// </summary>
 536        public string Url
 537        {
 0538            get { return this.propertyContainer.UrlProperty.Value; }
 539        }
 540
 541        /// <summary>
 542        /// Gets or sets the user identity under which the task runs.
 543        /// </summary>
 544        /// <remarks>
 545        /// If omitted, the task runs as a non-administrative user unique to the task.
 546        /// </remarks>
 547        public UserIdentity UserIdentity
 548        {
 0549            get { return this.propertyContainer.UserIdentityProperty.Value; }
 0550            set { this.propertyContainer.UserIdentityProperty.Value = value; }
 551        }
 552
 553        #endregion // CloudTask
 554
 555        #region IPropertyMetadata
 556
 557        bool IModifiable.HasBeenModified
 558        {
 0559            get { return this.propertyContainer.HasBeenModified; }
 560        }
 561
 562        bool IReadOnly.IsReadOnly
 563        {
 0564            get { return this.propertyContainer.IsReadOnly; }
 0565            set { this.propertyContainer.IsReadOnly = value; }
 566        }
 567
 568        #endregion //IPropertyMetadata
 569
 570        #region Internal/private methods
 571        /// <summary>
 572        /// Return a protocol object of the requested type.
 573        /// </summary>
 574        /// <returns>The protocol object of the requested type.</returns>
 575        Models.TaskAddParameter ITransportObjectProvider<Models.TaskAddParameter>.GetTransportObject()
 576        {
 0577            Models.TaskAddParameter result = new Models.TaskAddParameter()
 0578            {
 0579                AffinityInfo = UtilitiesInternal.CreateObjectWithNullCheck(this.AffinityInformation, (o) => o.GetTranspo
 0580                ApplicationPackageReferences = UtilitiesInternal.ConvertToProtocolCollection(this.ApplicationPackageRefe
 0581                AuthenticationTokenSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.AuthenticationTokenSettin
 0582                CommandLine = this.CommandLine,
 0583                Constraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, (o) => o.GetTransportObject(
 0584                ContainerSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.ContainerSettings, (o) => o.GetTran
 0585                DependsOn = UtilitiesInternal.CreateObjectWithNullCheck(this.DependsOn, (o) => o.GetTransportObject()),
 0586                DisplayName = this.DisplayName,
 0587                EnvironmentSettings = UtilitiesInternal.ConvertToProtocolCollection(this.EnvironmentSettings),
 0588                ExitConditions = UtilitiesInternal.CreateObjectWithNullCheck(this.ExitConditions, (o) => o.GetTransportO
 0589                Id = this.Id,
 0590                MultiInstanceSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.MultiInstanceSettings, (o) => o
 0591                OutputFiles = UtilitiesInternal.ConvertToProtocolCollection(this.OutputFiles),
 0592                ResourceFiles = UtilitiesInternal.ConvertToProtocolCollection(this.ResourceFiles),
 0593                UserIdentity = UtilitiesInternal.CreateObjectWithNullCheck(this.UserIdentity, (o) => o.GetTransportObjec
 0594            };
 595
 0596            return result;
 597        }
 598
 599
 600        #endregion // Internal/private methods
 601    }
 602}

Methods/Properties

.ctor(...)
get_BindingState()
StageFilesAsync()
.ctor()
StageFiles()
.ctor(...)
ListNodeFiles(...)
ListSubtasks(...)
CommitAsync()
Commit(...)
TerminateAsync(...)
get_ParentJobId()
Terminate(...)
.ctor(...)
DeleteAsync(...)
get_CustomBehaviors()
Delete(...)
get_AffinityInformation()
set_AffinityInformation(...)
get_ApplicationPackageReferences()
set_ApplicationPackageReferences(...)
ReactivateAsync(...)
get_AuthenticationTokenSettings()
set_AuthenticationTokenSettings(...)
get_CommandLine()
set_CommandLine(...)
get_ComputeNodeInformation()
Reactivate(...)
get_Constraints()
set_Constraints(...)
GetNodeFileAsync(...)
get_ContainerSettings()
set_ContainerSettings(...)
get_CreationTime()
GetNodeFile(...)
get_DependsOn()
set_DependsOn(...)
get_DisplayName()
set_DisplayName(...)
CopyNodeFileContentToStreamAsync(...)
get_EnvironmentSettings()
set_EnvironmentSettings(...)
get_ETag()
get_ExecutionInformation()
CopyNodeFileContentToStream(...)
get_ExitConditions()
set_ExitConditions(...)
get_FilesToStage()
set_FilesToStage(...)
CopyNodeFileContentToStringAsync(...)
get_Id()
set_Id(...)
get_LastModified()
get_MultiInstanceSettings()
set_MultiInstanceSettings(...)
CopyNodeFileContentToString(...)
get_OutputFiles()
set_OutputFiles(...)
RefreshAsync()
get_PreviousState()
get_PreviousStateTransitionTime()
Refresh(...)
get_ResourceFiles()
set_ResourceFiles(...)
.ctor()
.ctor(...)
get_ParentJobId()
.ctor(...)
get_CustomBehaviors()
get_AffinityInformation()
set_AffinityInformation(...)
get_ApplicationPackageReferences()
set_ApplicationPackageReferences(...)
get_AuthenticationTokenSettings()
set_AuthenticationTokenSettings(...)
get_CommandLine()
set_CommandLine(...)
get_ComputeNodeInformation()
get_Constraints()
set_Constraints(...)
get_ContainerSettings()
set_ContainerSettings(...)
get_CreationTime()
get_DependsOn()
set_DependsOn(...)
get_DisplayName()
set_DisplayName(...)
get_EnvironmentSettings()
set_EnvironmentSettings(...)
get_ETag()
get_ExecutionInformation()
get_ExitConditions()
set_ExitConditions(...)
get_FilesToStage()
set_FilesToStage(...)
get_Id()
set_Id(...)
get_LastModified()
get_MultiInstanceSettings()
set_MultiInstanceSettings(...)
get_OutputFiles()
set_OutputFiles(...)
get_PreviousState()
get_PreviousStateTransitionTime()
get_ResourceFiles()
set_ResourceFiles(...)
get_State()
get_StateTransitionTime()
get_Statistics()
get_Url()
get_UserIdentity()
set_UserIdentity(...)
Microsoft.Azure.Batch.IModifiable.get_HasBeenModified()
Microsoft.Azure.Batch.IReadOnly.get_IsReadOnly()
Microsoft.Azure.Batch.IReadOnly.set_IsReadOnly(...)
Microsoft.Azure.Batch.ITransportObjectProvider<Microsoft.Azure.Batch.Protocol.Models.TaskAddParameter>.GetTransportObject()