| | 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 | |
|
| 246 | 13 | | namespace Microsoft.Azure.Batch |
| | 14 | | { |
| 246 | 15 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | 16 | | using System; |
| | 17 | | using System.Collections.Generic; |
| | 18 | | using System.Linq; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// A task which is run when a compute node joins a pool in the Azure Batch service, or when the compute node is reb |
| | 22 | | /// or reimaged. |
| | 23 | | /// </summary> |
| | 24 | | /// <remarks> |
| | 25 | | /// <para>Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery oper |
| | 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.</para><para>The best practice for long running tasks |
| | 31 | | /// is to use some form of checkpointing. Special care should be taken to avoid start tasks which create breakaway p |
| | 32 | | /// or install/launch services from the start task working directory, as this will block Batch from being able to re |
| | 33 | | /// the start task.</para> |
| | 34 | | /// </remarks> |
| | 35 | | public partial class StartTask : ITransportObjectProvider<Models.StartTask>, IPropertyMetadata |
| | 36 | | { |
| | 37 | | private class PropertyContainer : PropertyCollection |
| | 38 | | { |
| | 39 | | public readonly PropertyAccessor<string> CommandLineProperty; |
| | 40 | | public readonly PropertyAccessor<TaskContainerSettings> ContainerSettingsProperty; |
| | 41 | | public readonly PropertyAccessor<IList<EnvironmentSetting>> EnvironmentSettingsProperty; |
| | 42 | | public readonly PropertyAccessor<int?> MaxTaskRetryCountProperty; |
| | 43 | | public readonly PropertyAccessor<IList<ResourceFile>> ResourceFilesProperty; |
| | 44 | | public readonly PropertyAccessor<UserIdentity> UserIdentityProperty; |
| | 45 | | public readonly PropertyAccessor<bool?> WaitForSuccessProperty; |
| | 46 | |
|
| 247 | 47 | | public PropertyContainer() : base(BindingState.Unbound) |
| | 48 | | { |
| 247 | 49 | | this.CommandLineProperty = this.CreatePropertyAccessor<string>(nameof(CommandLine), BindingAccess.Read | |
| 247 | 50 | | this.ContainerSettingsProperty = this.CreatePropertyAccessor<TaskContainerSettings>(nameof(ContainerSett |
| 247 | 51 | | this.EnvironmentSettingsProperty = this.CreatePropertyAccessor<IList<EnvironmentSetting>>(nameof(Environ |
| 247 | 52 | | this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor<int?>(nameof(MaxTaskRetryCount), BindingAcc |
| 247 | 53 | | this.ResourceFilesProperty = this.CreatePropertyAccessor<IList<ResourceFile>>(nameof(ResourceFiles), Bin |
| 247 | 54 | | this.UserIdentityProperty = this.CreatePropertyAccessor<UserIdentity>(nameof(UserIdentity), BindingAcces |
| 247 | 55 | | this.WaitForSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(WaitForSuccess), BindingAccess.R |
| 247 | 56 | | } |
| | 57 | |
|
| 1085 | 58 | | public PropertyContainer(Models.StartTask protocolObject) : base(BindingState.Bound) |
| | 59 | | { |
| 1085 | 60 | | this.CommandLineProperty = this.CreatePropertyAccessor( |
| 1085 | 61 | | protocolObject.CommandLine, |
| 1085 | 62 | | nameof(CommandLine), |
| 1085 | 63 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 64 | | this.ContainerSettingsProperty = this.CreatePropertyAccessor( |
| 1615 | 65 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ContainerSettings, o => new TaskContainer |
| 1085 | 66 | | nameof(ContainerSettings), |
| 1085 | 67 | | BindingAccess.Read); |
| 1085 | 68 | | this.EnvironmentSettingsProperty = this.CreatePropertyAccessor( |
| 1085 | 69 | | EnvironmentSetting.ConvertFromProtocolCollection(protocolObject.EnvironmentSettings), |
| 1085 | 70 | | nameof(EnvironmentSettings), |
| 1085 | 71 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 72 | | this.MaxTaskRetryCountProperty = this.CreatePropertyAccessor( |
| 1085 | 73 | | protocolObject.MaxTaskRetryCount, |
| 1085 | 74 | | nameof(MaxTaskRetryCount), |
| 1085 | 75 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 76 | | this.ResourceFilesProperty = this.CreatePropertyAccessor( |
| 1085 | 77 | | ResourceFile.ConvertFromProtocolCollection(protocolObject.ResourceFiles), |
| 1085 | 78 | | nameof(ResourceFiles), |
| 1085 | 79 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 80 | | this.UserIdentityProperty = this.CreatePropertyAccessor( |
| 1625 | 81 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.UserIdentity, o => new UserIdentity(o)), |
| 1085 | 82 | | nameof(UserIdentity), |
| 1085 | 83 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 84 | | this.WaitForSuccessProperty = this.CreatePropertyAccessor( |
| 1085 | 85 | | protocolObject.WaitForSuccess, |
| 1085 | 86 | | nameof(WaitForSuccess), |
| 1085 | 87 | | BindingAccess.Read | BindingAccess.Write); |
| 1085 | 88 | | } |
| | 89 | | } |
| | 90 | |
|
| | 91 | | private readonly PropertyContainer propertyContainer; |
| | 92 | |
|
| | 93 | | #region Constructors |
| | 94 | |
|
| | 95 | | /// <summary> |
| | 96 | | /// Initializes a new instance of the <see cref="StartTask"/> class. |
| | 97 | | /// </summary> |
| | 98 | | /// <param name='commandLine'>The command line of the task.</param> |
| 247 | 99 | | public StartTask( |
| 247 | 100 | | string commandLine) |
| | 101 | | { |
| 247 | 102 | | this.propertyContainer = new PropertyContainer(); |
| 247 | 103 | | this.CommandLine = commandLine; |
| 247 | 104 | | } |
| | 105 | |
|
| 1085 | 106 | | internal StartTask(Models.StartTask protocolObject) |
| | 107 | | { |
| 1085 | 108 | | this.propertyContainer = new PropertyContainer(protocolObject); |
| 1085 | 109 | | } |
| | 110 | |
|
| | 111 | | #endregion Constructors |
| | 112 | |
|
| | 113 | | #region StartTask |
| | 114 | |
|
| | 115 | | /// <summary> |
| | 116 | | /// Gets or sets the command line of the task. |
| | 117 | | /// </summary> |
| | 118 | | /// <remarks> |
| | 119 | | /// The command line does not run under a shell, and therefore cannot take advantage of shell features such as e |
| | 120 | | /// variable expansion. If you want to take advantage of such features, you should invoke the shell in the comma |
| | 121 | | /// line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command lin |
| | 122 | | /// refers to file paths, it should use a relative path (relative to the task working directory), or use the Bat |
| | 123 | | /// provided environment variables (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment- |
| | 124 | | /// </remarks> |
| | 125 | | public string CommandLine |
| | 126 | | { |
| 1575 | 127 | | get { return this.propertyContainer.CommandLineProperty.Value; } |
| 745 | 128 | | set { this.propertyContainer.CommandLineProperty.Value = value; } |
| | 129 | | } |
| | 130 | |
|
| | 131 | | /// <summary> |
| | 132 | | /// Gets or sets the settings for the container under which the task runs. |
| | 133 | | /// </summary> |
| | 134 | | /// <remarks> |
| | 135 | | /// When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batc |
| | 136 | | /// directories on the node) are mapped into the container, all task environment variables are mapped into the c |
| | 137 | | /// and the task command line is executed in the container. Files produced in the container outside of AZ_BATCH_ |
| | 138 | | /// might not be reflected to the host disk, meaning that Batch file APIs will not be able to access them. |
| | 139 | | /// </remarks> |
| | 140 | | public TaskContainerSettings ContainerSettings |
| | 141 | | { |
| 1572 | 142 | | get { return this.propertyContainer.ContainerSettingsProperty.Value; } |
| 257 | 143 | | set { this.propertyContainer.ContainerSettingsProperty.Value = value; } |
| | 144 | | } |
| | 145 | |
|
| | 146 | | /// <summary> |
| | 147 | | /// Gets or sets a set of environment settings for the start task. |
| | 148 | | /// </summary> |
| | 149 | | public IList<EnvironmentSetting> EnvironmentSettings |
| | 150 | | { |
| 1574 | 151 | | get { return this.propertyContainer.EnvironmentSettingsProperty.Value; } |
| | 152 | | set |
| | 153 | | { |
| 118 | 154 | | this.propertyContainer.EnvironmentSettingsProperty.Value = ConcurrentChangeTrackedModifiableList<Environ |
| 117 | 155 | | } |
| | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> |
| | 159 | | /// Gets or sets the maximum number of retries for the task. |
| | 160 | | /// </summary> |
| | 161 | | public int? MaxTaskRetryCount |
| | 162 | | { |
| 1573 | 163 | | get { return this.propertyContainer.MaxTaskRetryCountProperty.Value; } |
| 257 | 164 | | set { this.propertyContainer.MaxTaskRetryCountProperty.Value = value; } |
| | 165 | | } |
| | 166 | |
|
| | 167 | | /// <summary> |
| | 168 | | /// Gets or sets a list of files that the Batch service will download to the compute node before running the com |
| | 169 | | /// line. |
| | 170 | | /// </summary> |
| | 171 | | /// <remarks> |
| | 172 | | /// There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail |
| | 173 | | /// and the response error code will be RequestEntityTooLarge. If this occurs, the collection of resource files |
| | 174 | | /// be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. |
| | 175 | | /// </remarks> |
| | 176 | | public IList<ResourceFile> ResourceFiles |
| | 177 | | { |
| 1572 | 178 | | get { return this.propertyContainer.ResourceFilesProperty.Value; } |
| | 179 | | set |
| | 180 | | { |
| 121 | 181 | | this.propertyContainer.ResourceFilesProperty.Value = ConcurrentChangeTrackedModifiableList<ResourceFile> |
| 120 | 182 | | } |
| | 183 | | } |
| | 184 | |
|
| | 185 | | /// <summary> |
| | 186 | | /// Gets or sets the user identity under which the task runs. |
| | 187 | | /// </summary> |
| | 188 | | /// <remarks> |
| | 189 | | /// If omitted, the task runs as a non-administrative user unique to the task. |
| | 190 | | /// </remarks> |
| | 191 | | public UserIdentity UserIdentity |
| | 192 | | { |
| 1573 | 193 | | get { return this.propertyContainer.UserIdentityProperty.Value; } |
| 247 | 194 | | set { this.propertyContainer.UserIdentityProperty.Value = value; } |
| | 195 | | } |
| | 196 | |
|
| | 197 | | /// <summary> |
| | 198 | | /// Gets or sets a value indicating whether the Batch service should wait for the start task to complete before |
| | 199 | | /// any tasks on the compute node. |
| | 200 | | /// </summary> |
| | 201 | | /// <remarks> |
| | 202 | | /// If this is not specified, the default is true. |
| | 203 | | /// </remarks> |
| | 204 | | public bool? WaitForSuccess |
| | 205 | | { |
| 1573 | 206 | | get { return this.propertyContainer.WaitForSuccessProperty.Value; } |
| 271 | 207 | | set { this.propertyContainer.WaitForSuccessProperty.Value = value; } |
| | 208 | | } |
| | 209 | |
|
| | 210 | | #endregion // StartTask |
| | 211 | |
|
| | 212 | | #region IPropertyMetadata |
| | 213 | |
|
| | 214 | | bool IModifiable.HasBeenModified |
| | 215 | | { |
| 4 | 216 | | get { return this.propertyContainer.HasBeenModified; } |
| | 217 | | } |
| | 218 | |
|
| | 219 | | bool IReadOnly.IsReadOnly |
| | 220 | | { |
| 0 | 221 | | get { return this.propertyContainer.IsReadOnly; } |
| 1026 | 222 | | set { this.propertyContainer.IsReadOnly = value; } |
| | 223 | | } |
| | 224 | |
|
| | 225 | | #endregion //IPropertyMetadata |
| | 226 | |
|
| | 227 | | #region Internal/private methods |
| | 228 | | /// <summary> |
| | 229 | | /// Return a protocol object of the requested type. |
| | 230 | | /// </summary> |
| | 231 | | /// <returns>The protocol object of the requested type.</returns> |
| | 232 | | Models.StartTask ITransportObjectProvider<Models.StartTask>.GetTransportObject() |
| | 233 | | { |
| 247 | 234 | | Models.StartTask result = new Models.StartTask() |
| 247 | 235 | | { |
| 247 | 236 | | CommandLine = this.CommandLine, |
| 375 | 237 | | ContainerSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.ContainerSettings, (o) => o.GetTran |
| 247 | 238 | | EnvironmentSettings = UtilitiesInternal.ConvertToProtocolCollection(this.EnvironmentSettings), |
| 247 | 239 | | MaxTaskRetryCount = this.MaxTaskRetryCount, |
| 247 | 240 | | ResourceFiles = UtilitiesInternal.ConvertToProtocolCollection(this.ResourceFiles), |
| 370 | 241 | | UserIdentity = UtilitiesInternal.CreateObjectWithNullCheck(this.UserIdentity, (o) => o.GetTransportObjec |
| 247 | 242 | | WaitForSuccess = this.WaitForSuccess, |
| 247 | 243 | | }; |
| | 244 | |
|
| 247 | 245 | | return result; |
| | 246 | | } |
| | 247 | |
|
| | 248 | |
|
| | 249 | | #endregion // Internal/private methods |
| | 250 | | } |
| | 251 | | } |