| | 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 | |
|
| 214 | 13 | | namespace Microsoft.Azure.Batch |
| | 14 | | { |
| 214 | 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 Job Preparation task to run before any tasks of the job on any given compute node. |
| | 22 | | /// </summary> |
| | 23 | | /// <remarks> |
| | 24 | | /// Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery operations |
| | 25 | | /// include (but are not limited to) when an unhealthy compute node is rebooted or a compute node disappeared due to |
| | 26 | | /// host failure. Retries due to recovery operations are independent of and are not counted against the <see cref="T |
| | 27 | | /// />. Even if the <see cref="TaskConstraints.MaxTaskRetryCount" /> is 0, an internal retry due to a recovery opera |
| | 28 | | /// may occur. Because of this, all tasks should be idempotent. This means tasks need to tolerate being interrupted |
| | 29 | | /// restarted without causing any corruption or duplicate data. The best practice for long running tasks is to use s |
| | 30 | | /// form of checkpointing. |
| | 31 | | /// </remarks> |
| | 32 | | public partial class JobPreparationTask : ITransportObjectProvider<Models.JobPreparationTask>, IPropertyMetadata |
| | 33 | | { |
| | 34 | | private class PropertyContainer : PropertyCollection |
| | 35 | | { |
| | 36 | | public readonly PropertyAccessor<string> CommandLineProperty; |
| | 37 | | public readonly PropertyAccessor<TaskConstraints> ConstraintsProperty; |
| | 38 | | public readonly PropertyAccessor<TaskContainerSettings> ContainerSettingsProperty; |
| | 39 | | public readonly PropertyAccessor<IList<EnvironmentSetting>> EnvironmentSettingsProperty; |
| | 40 | | public readonly PropertyAccessor<string> IdProperty; |
| | 41 | | public readonly PropertyAccessor<bool?> RerunOnComputeNodeRebootAfterSuccessProperty; |
| | 42 | | public readonly PropertyAccessor<IList<ResourceFile>> ResourceFilesProperty; |
| | 43 | | public readonly PropertyAccessor<UserIdentity> UserIdentityProperty; |
| | 44 | | public readonly PropertyAccessor<bool?> WaitForSuccessProperty; |
| | 45 | |
|
| 214 | 46 | | public PropertyContainer() : base(BindingState.Unbound) |
| | 47 | | { |
| 214 | 48 | | this.CommandLineProperty = this.CreatePropertyAccessor<string>(nameof(CommandLine), BindingAccess.Read | |
| 214 | 49 | | this.ConstraintsProperty = this.CreatePropertyAccessor<TaskConstraints>(nameof(Constraints), BindingAcce |
| 214 | 50 | | this.ContainerSettingsProperty = this.CreatePropertyAccessor<TaskContainerSettings>(nameof(ContainerSett |
| 214 | 51 | | this.EnvironmentSettingsProperty = this.CreatePropertyAccessor<IList<EnvironmentSetting>>(nameof(Environ |
| 214 | 52 | | this.IdProperty = this.CreatePropertyAccessor<string>(nameof(Id), BindingAccess.Read | BindingAccess.Wri |
| 214 | 53 | | this.RerunOnComputeNodeRebootAfterSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(RerunOnCom |
| 214 | 54 | | this.ResourceFilesProperty = this.CreatePropertyAccessor<IList<ResourceFile>>(nameof(ResourceFiles), Bin |
| 214 | 55 | | this.UserIdentityProperty = this.CreatePropertyAccessor<UserIdentity>(nameof(UserIdentity), BindingAcces |
| 214 | 56 | | this.WaitForSuccessProperty = this.CreatePropertyAccessor<bool?>(nameof(WaitForSuccess), BindingAccess.R |
| 214 | 57 | | } |
| | 58 | |
|
| 763 | 59 | | public PropertyContainer(Models.JobPreparationTask protocolObject) : base(BindingState.Bound) |
| | 60 | | { |
| 763 | 61 | | this.CommandLineProperty = this.CreatePropertyAccessor( |
| 763 | 62 | | protocolObject.CommandLine, |
| 763 | 63 | | nameof(CommandLine), |
| 763 | 64 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 65 | | this.ConstraintsProperty = this.CreatePropertyAccessor( |
| 1134 | 66 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.Constraints, o => new TaskConstraints(o)) |
| 763 | 67 | | nameof(Constraints), |
| 763 | 68 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 69 | | this.ContainerSettingsProperty = this.CreatePropertyAccessor( |
| 1137 | 70 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.ContainerSettings, o => new TaskContainer |
| 763 | 71 | | nameof(ContainerSettings), |
| 763 | 72 | | BindingAccess.Read); |
| 763 | 73 | | this.EnvironmentSettingsProperty = this.CreatePropertyAccessor( |
| 763 | 74 | | EnvironmentSetting.ConvertFromProtocolCollection(protocolObject.EnvironmentSettings), |
| 763 | 75 | | nameof(EnvironmentSettings), |
| 763 | 76 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 77 | | this.IdProperty = this.CreatePropertyAccessor( |
| 763 | 78 | | protocolObject.Id, |
| 763 | 79 | | nameof(Id), |
| 763 | 80 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 81 | | this.RerunOnComputeNodeRebootAfterSuccessProperty = this.CreatePropertyAccessor( |
| 763 | 82 | | protocolObject.RerunOnNodeRebootAfterSuccess, |
| 763 | 83 | | nameof(RerunOnComputeNodeRebootAfterSuccess), |
| 763 | 84 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 85 | | this.ResourceFilesProperty = this.CreatePropertyAccessor( |
| 763 | 86 | | ResourceFile.ConvertFromProtocolCollection(protocolObject.ResourceFiles), |
| 763 | 87 | | nameof(ResourceFiles), |
| 763 | 88 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 89 | | this.UserIdentityProperty = this.CreatePropertyAccessor( |
| 1155 | 90 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.UserIdentity, o => new UserIdentity(o).Fr |
| 763 | 91 | | nameof(UserIdentity), |
| 763 | 92 | | BindingAccess.Read); |
| 763 | 93 | | this.WaitForSuccessProperty = this.CreatePropertyAccessor( |
| 763 | 94 | | protocolObject.WaitForSuccess, |
| 763 | 95 | | nameof(WaitForSuccess), |
| 763 | 96 | | BindingAccess.Read | BindingAccess.Write); |
| 763 | 97 | | } |
| | 98 | | } |
| | 99 | |
|
| | 100 | | private readonly PropertyContainer propertyContainer; |
| | 101 | |
|
| | 102 | | #region Constructors |
| | 103 | |
|
| | 104 | | /// <summary> |
| | 105 | | /// Initializes a new instance of the <see cref="JobPreparationTask"/> class. |
| | 106 | | /// </summary> |
| | 107 | | /// <param name='commandLine'>The command line of the task.</param> |
| 214 | 108 | | public JobPreparationTask( |
| 214 | 109 | | string commandLine) |
| | 110 | | { |
| 214 | 111 | | this.propertyContainer = new PropertyContainer(); |
| 214 | 112 | | this.CommandLine = commandLine; |
| 214 | 113 | | } |
| | 114 | |
|
| 763 | 115 | | internal JobPreparationTask(Models.JobPreparationTask protocolObject) |
| | 116 | | { |
| 763 | 117 | | this.propertyContainer = new PropertyContainer(protocolObject); |
| 763 | 118 | | } |
| | 119 | |
|
| | 120 | | #endregion Constructors |
| | 121 | |
|
| | 122 | | #region JobPreparationTask |
| | 123 | |
|
| | 124 | | /// <summary> |
| | 125 | | /// Gets or sets the command line of the task. |
| | 126 | | /// </summary> |
| | 127 | | /// <remarks> |
| | 128 | | /// The command line does not run under a shell, and therefore cannot take advantage of shell features such as e |
| | 129 | | /// variable expansion. If you want to take advantage of such features, you should invoke the shell in the comma |
| | 130 | | /// line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command lin |
| | 131 | | /// refers to file paths, it should use a relative path (relative to the task working directory), or use the Bat |
| | 132 | | /// provided environment variables (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment- |
| | 133 | | /// </remarks> |
| | 134 | | public string CommandLine |
| | 135 | | { |
| 1189 | 136 | | get { return this.propertyContainer.CommandLineProperty.Value; } |
| 637 | 137 | | set { this.propertyContainer.CommandLineProperty.Value = value; } |
| | 138 | | } |
| | 139 | |
|
| | 140 | | /// <summary> |
| | 141 | | /// Gets or sets the execution constraints provided by the user for this Job Preparation task. |
| | 142 | | /// </summary> |
| | 143 | | public TaskConstraints Constraints |
| | 144 | | { |
| 1189 | 145 | | get { return this.propertyContainer.ConstraintsProperty.Value; } |
| 219 | 146 | | set { this.propertyContainer.ConstraintsProperty.Value = value; } |
| | 147 | | } |
| | 148 | |
|
| | 149 | | /// <summary> |
| | 150 | | /// Gets or sets the settings for the container under which the task runs. |
| | 151 | | /// </summary> |
| | 152 | | /// <remarks> |
| | 153 | | /// When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batc |
| | 154 | | /// directories on the node) are mapped into the container, all task environment variables are mapped into the c |
| | 155 | | /// and the task command line is executed in the container. |
| | 156 | | /// </remarks> |
| | 157 | | public TaskContainerSettings ContainerSettings |
| | 158 | | { |
| 1189 | 159 | | get { return this.propertyContainer.ContainerSettingsProperty.Value; } |
| 213 | 160 | | set { this.propertyContainer.ContainerSettingsProperty.Value = value; } |
| | 161 | | } |
| | 162 | |
|
| | 163 | | /// <summary> |
| | 164 | | /// Gets or sets the collection of EnvironmentSetting instances. |
| | 165 | | /// </summary> |
| | 166 | | public IList<EnvironmentSetting> EnvironmentSettings |
| | 167 | | { |
| 1189 | 168 | | get { return this.propertyContainer.EnvironmentSettingsProperty.Value; } |
| | 169 | | set |
| | 170 | | { |
| 107 | 171 | | this.propertyContainer.EnvironmentSettingsProperty.Value = ConcurrentChangeTrackedModifiableList<Environ |
| 106 | 172 | | } |
| | 173 | | } |
| | 174 | |
|
| | 175 | | /// <summary> |
| | 176 | | /// Gets or sets the id of the task. |
| | 177 | | /// </summary> |
| | 178 | | public string Id |
| | 179 | | { |
| 1190 | 180 | | get { return this.propertyContainer.IdProperty.Value; } |
| 211 | 181 | | set { this.propertyContainer.IdProperty.Value = value; } |
| | 182 | | } |
| | 183 | |
|
| | 184 | | /// <summary> |
| | 185 | | /// Gets or sets whether the Batch service should rerun the Job Preparation task after a compute node reboots. |
| | 186 | | /// </summary> |
| | 187 | | /// <remarks> |
| | 188 | | /// The Job Preparation task is always rerun if a compute node is reimaged, or if the Job Preparation task did n |
| | 189 | | /// complete (e.g. because the reboot occurred while the task was running). Therefore, you should always write a |
| | 190 | | /// Job Preparation task to be idempotent and to behave correctly if run multiple times. If this property is not |
| | 191 | | /// specified, a default value of true is assigned by the Batch service. |
| | 192 | | /// </remarks> |
| | 193 | | public bool? RerunOnComputeNodeRebootAfterSuccess |
| | 194 | | { |
| 1189 | 195 | | get { return this.propertyContainer.RerunOnComputeNodeRebootAfterSuccessProperty.Value; } |
| 221 | 196 | | set { this.propertyContainer.RerunOnComputeNodeRebootAfterSuccessProperty.Value = value; } |
| | 197 | | } |
| | 198 | |
|
| | 199 | | /// <summary> |
| | 200 | | /// Gets or sets a list of files that the Batch service will download to the compute node before running the com |
| | 201 | | /// line. |
| | 202 | | /// </summary> |
| | 203 | | /// <remarks> |
| | 204 | | /// There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail |
| | 205 | | /// and the response error code will be RequestEntityTooLarge. If this occurs, the collection of resource files |
| | 206 | | /// be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. |
| | 207 | | /// </remarks> |
| | 208 | | public IList<ResourceFile> ResourceFiles |
| | 209 | | { |
| 1189 | 210 | | get { return this.propertyContainer.ResourceFilesProperty.Value; } |
| | 211 | | set |
| | 212 | | { |
| 97 | 213 | | this.propertyContainer.ResourceFilesProperty.Value = ConcurrentChangeTrackedModifiableList<ResourceFile> |
| 96 | 214 | | } |
| | 215 | | } |
| | 216 | |
|
| | 217 | | /// <summary> |
| | 218 | | /// Gets or sets the user identity under which the task runs. |
| | 219 | | /// </summary> |
| | 220 | | /// <remarks> |
| | 221 | | /// If omitted, the task runs as a non-administrative user unique to the task. |
| | 222 | | /// </remarks> |
| | 223 | | public UserIdentity UserIdentity |
| | 224 | | { |
| 1189 | 225 | | get { return this.propertyContainer.UserIdentityProperty.Value; } |
| 205 | 226 | | set { this.propertyContainer.UserIdentityProperty.Value = value; } |
| | 227 | | } |
| | 228 | |
|
| | 229 | | /// <summary> |
| | 230 | | /// Gets or sets whether the Batch service should wait for the successful completion of the Job Preparation task |
| | 231 | | /// before scheduling any tasks on the compute node. |
| | 232 | | /// </summary> |
| | 233 | | /// <remarks> |
| | 234 | | /// A Job Preparation task execution is considered successful if its ExitCode is 0. If this property is not spec |
| | 235 | | /// a default value of true is assigned by the Batch service. |
| | 236 | | /// </remarks> |
| | 237 | | public bool? WaitForSuccess |
| | 238 | | { |
| 1189 | 239 | | get { return this.propertyContainer.WaitForSuccessProperty.Value; } |
| 203 | 240 | | set { this.propertyContainer.WaitForSuccessProperty.Value = value; } |
| | 241 | | } |
| | 242 | |
|
| | 243 | | #endregion // JobPreparationTask |
| | 244 | |
|
| | 245 | | #region IPropertyMetadata |
| | 246 | |
|
| | 247 | | bool IModifiable.HasBeenModified |
| | 248 | | { |
| 0 | 249 | | get { return this.propertyContainer.HasBeenModified; } |
| | 250 | | } |
| | 251 | |
|
| | 252 | | bool IReadOnly.IsReadOnly |
| | 253 | | { |
| 0 | 254 | | get { return this.propertyContainer.IsReadOnly; } |
| 1042 | 255 | | set { this.propertyContainer.IsReadOnly = value; } |
| | 256 | | } |
| | 257 | |
|
| | 258 | | #endregion //IPropertyMetadata |
| | 259 | |
|
| | 260 | | #region Internal/private methods |
| | 261 | | /// <summary> |
| | 262 | | /// Return a protocol object of the requested type. |
| | 263 | | /// </summary> |
| | 264 | | /// <returns>The protocol object of the requested type.</returns> |
| | 265 | | Models.JobPreparationTask ITransportObjectProvider<Models.JobPreparationTask>.GetTransportObject() |
| | 266 | | { |
| 213 | 267 | | Models.JobPreparationTask result = new Models.JobPreparationTask() |
| 213 | 268 | | { |
| 213 | 269 | | CommandLine = this.CommandLine, |
| 322 | 270 | | Constraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, (o) => o.GetTransportObject( |
| 319 | 271 | | ContainerSettings = UtilitiesInternal.CreateObjectWithNullCheck(this.ContainerSettings, (o) => o.GetTran |
| 213 | 272 | | EnvironmentSettings = UtilitiesInternal.ConvertToProtocolCollection(this.EnvironmentSettings), |
| 213 | 273 | | Id = this.Id, |
| 213 | 274 | | RerunOnNodeRebootAfterSuccess = this.RerunOnComputeNodeRebootAfterSuccess, |
| 213 | 275 | | ResourceFiles = UtilitiesInternal.ConvertToProtocolCollection(this.ResourceFiles), |
| 315 | 276 | | UserIdentity = UtilitiesInternal.CreateObjectWithNullCheck(this.UserIdentity, (o) => o.GetTransportObjec |
| 213 | 277 | | WaitForSuccess = this.WaitForSuccess, |
| 213 | 278 | | }; |
| | 279 | |
|
| 213 | 280 | | return result; |
| | 281 | | } |
| | 282 | |
|
| | 283 | |
|
| | 284 | | #endregion // Internal/private methods |
| | 285 | | } |
| | 286 | | } |