| | 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 | |
|
| | 13 | | namespace Microsoft.Azure.Batch |
| | 14 | | { |
| | 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 user account to create on an Azure Batch node. Tasks may be configured to execute in the security context of t |
| | 22 | | /// user account. |
| | 23 | | /// </summary> |
| | 24 | | public partial class UserAccount : ITransportObjectProvider<Models.UserAccount>, IPropertyMetadata |
| | 25 | | { |
| | 26 | | private class PropertyContainer : PropertyCollection |
| | 27 | | { |
| | 28 | | public readonly PropertyAccessor<Common.ElevationLevel?> ElevationLevelProperty; |
| | 29 | | public readonly PropertyAccessor<LinuxUserConfiguration> LinuxUserConfigurationProperty; |
| | 30 | | public readonly PropertyAccessor<string> NameProperty; |
| | 31 | | public readonly PropertyAccessor<string> PasswordProperty; |
| | 32 | | public readonly PropertyAccessor<WindowsUserConfiguration> WindowsUserConfigurationProperty; |
| | 33 | |
|
| 826 | 34 | | public PropertyContainer() : base(BindingState.Unbound) |
| | 35 | | { |
| 826 | 36 | | this.ElevationLevelProperty = this.CreatePropertyAccessor<Common.ElevationLevel?>(nameof(ElevationLevel) |
| 826 | 37 | | this.LinuxUserConfigurationProperty = this.CreatePropertyAccessor<LinuxUserConfiguration>(nameof(LinuxUs |
| 826 | 38 | | this.NameProperty = this.CreatePropertyAccessor<string>(nameof(Name), BindingAccess.Read | BindingAccess |
| 826 | 39 | | this.PasswordProperty = this.CreatePropertyAccessor<string>(nameof(Password), BindingAccess.Read | Bindi |
| 826 | 40 | | this.WindowsUserConfigurationProperty = this.CreatePropertyAccessor<WindowsUserConfiguration>(nameof(Win |
| 826 | 41 | | } |
| | 42 | |
|
| 2760 | 43 | | public PropertyContainer(Models.UserAccount protocolObject) : base(BindingState.Bound) |
| | 44 | | { |
| 2760 | 45 | | this.ElevationLevelProperty = this.CreatePropertyAccessor( |
| 2760 | 46 | | UtilitiesInternal.MapNullableEnum<Models.ElevationLevel, Common.ElevationLevel>(protocolObject.Eleva |
| 2760 | 47 | | nameof(ElevationLevel), |
| 2760 | 48 | | BindingAccess.Read); |
| 2760 | 49 | | this.LinuxUserConfigurationProperty = this.CreatePropertyAccessor( |
| 4173 | 50 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.LinuxUserConfiguration, o => new LinuxUse |
| 2760 | 51 | | nameof(LinuxUserConfiguration), |
| 2760 | 52 | | BindingAccess.Read); |
| 2760 | 53 | | this.NameProperty = this.CreatePropertyAccessor( |
| 2760 | 54 | | protocolObject.Name, |
| 2760 | 55 | | nameof(Name), |
| 2760 | 56 | | BindingAccess.Read); |
| 2760 | 57 | | this.PasswordProperty = this.CreatePropertyAccessor( |
| 2760 | 58 | | protocolObject.Password, |
| 2760 | 59 | | nameof(Password), |
| 2760 | 60 | | BindingAccess.Read); |
| 2760 | 61 | | this.WindowsUserConfigurationProperty = this.CreatePropertyAccessor( |
| 4170 | 62 | | UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.WindowsUserConfiguration, o => new Window |
| 2760 | 63 | | nameof(WindowsUserConfiguration), |
| 2760 | 64 | | BindingAccess.Read); |
| 2760 | 65 | | } |
| | 66 | | } |
| | 67 | |
|
| | 68 | | private readonly PropertyContainer propertyContainer; |
| | 69 | |
|
| | 70 | | #region Constructors |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Initializes a new instance of the <see cref="UserAccount"/> class. |
| | 74 | | /// </summary> |
| | 75 | | /// <param name='name'>The name of the user account.</param> |
| | 76 | | /// <param name='password'>The password for the user account.</param> |
| | 77 | | /// <param name='elevationLevel'>The elevation level of the user account.</param> |
| | 78 | | /// <param name='linuxUserConfiguration'>Additional properties used to create a user account on a Linux node.</p |
| | 79 | | /// <param name='windowsUserConfiguration'>The Windows-specific user configuration for the user account.</param> |
| 826 | 80 | | public UserAccount( |
| 826 | 81 | | string name, |
| 826 | 82 | | string password, |
| 826 | 83 | | Common.ElevationLevel? elevationLevel = default(Common.ElevationLevel?), |
| 826 | 84 | | LinuxUserConfiguration linuxUserConfiguration = default(LinuxUserConfiguration), |
| 826 | 85 | | WindowsUserConfiguration windowsUserConfiguration = default(WindowsUserConfiguration)) |
| | 86 | | { |
| 826 | 87 | | this.propertyContainer = new PropertyContainer(); |
| 826 | 88 | | this.Name = name; |
| 826 | 89 | | this.Password = password; |
| 826 | 90 | | this.ElevationLevel = elevationLevel; |
| 826 | 91 | | this.LinuxUserConfiguration = linuxUserConfiguration; |
| 826 | 92 | | this.WindowsUserConfiguration = windowsUserConfiguration; |
| 826 | 93 | | } |
| | 94 | |
|
| 2760 | 95 | | internal UserAccount(Models.UserAccount protocolObject) |
| | 96 | | { |
| 2760 | 97 | | this.propertyContainer = new PropertyContainer(protocolObject); |
| 2760 | 98 | | } |
| | 99 | |
|
| | 100 | | #endregion Constructors |
| | 101 | |
|
| | 102 | | #region UserAccount |
| | 103 | |
|
| | 104 | | /// <summary> |
| | 105 | | /// Gets or sets the elevation level of the user account. |
| | 106 | | /// </summary> |
| | 107 | | /// <remarks> |
| | 108 | | /// If omitted, the default is <see cref="Common.ElevationLevel.NonAdmin"/> |
| | 109 | | /// </remarks> |
| | 110 | | public Common.ElevationLevel? ElevationLevel |
| | 111 | | { |
| 4411 | 112 | | get { return this.propertyContainer.ElevationLevelProperty.Value; } |
| 2455 | 113 | | set { this.propertyContainer.ElevationLevelProperty.Value = value; } |
| | 114 | | } |
| | 115 | |
|
| | 116 | | /// <summary> |
| | 117 | | /// Gets or sets additional properties used to create a user account on a Linux node. |
| | 118 | | /// </summary> |
| | 119 | | /// <remarks> |
| | 120 | | /// This property is ignored if specified on a Windows pool. If not specified, the user is created with the defa |
| | 121 | | /// options. |
| | 122 | | /// </remarks> |
| | 123 | | public LinuxUserConfiguration LinuxUserConfiguration |
| | 124 | | { |
| 4411 | 125 | | get { return this.propertyContainer.LinuxUserConfigurationProperty.Value; } |
| 2491 | 126 | | set { this.propertyContainer.LinuxUserConfigurationProperty.Value = value; } |
| | 127 | | } |
| | 128 | |
|
| | 129 | | /// <summary> |
| | 130 | | /// Gets or sets the name of the user account. |
| | 131 | | /// </summary> |
| | 132 | | public string Name |
| | 133 | | { |
| 4411 | 134 | | get { return this.propertyContainer.NameProperty.Value; } |
| 2517 | 135 | | set { this.propertyContainer.NameProperty.Value = value; } |
| | 136 | | } |
| | 137 | |
|
| | 138 | | /// <summary> |
| | 139 | | /// Gets or sets the password for the user account. |
| | 140 | | /// </summary> |
| | 141 | | public string Password |
| | 142 | | { |
| 4411 | 143 | | get { return this.propertyContainer.PasswordProperty.Value; } |
| 2457 | 144 | | set { this.propertyContainer.PasswordProperty.Value = value; } |
| | 145 | | } |
| | 146 | |
|
| | 147 | | /// <summary> |
| | 148 | | /// Gets or sets the Windows-specific user configuration for the user account. |
| | 149 | | /// </summary> |
| | 150 | | /// <remarks> |
| | 151 | | /// This property can only be specified if the user is on a Windows pool. If not specified and on a Windows pool |
| | 152 | | /// the user is created with the default options. |
| | 153 | | /// </remarks> |
| | 154 | | public WindowsUserConfiguration WindowsUserConfiguration |
| | 155 | | { |
| 4411 | 156 | | get { return this.propertyContainer.WindowsUserConfigurationProperty.Value; } |
| 2465 | 157 | | set { this.propertyContainer.WindowsUserConfigurationProperty.Value = value; } |
| | 158 | | } |
| | 159 | |
|
| | 160 | | #endregion // UserAccount |
| | 161 | |
|
| | 162 | | #region IPropertyMetadata |
| | 163 | |
|
| | 164 | | bool IModifiable.HasBeenModified |
| | 165 | | { |
| 0 | 166 | | get { return this.propertyContainer.HasBeenModified; } |
| | 167 | | } |
| | 168 | |
|
| | 169 | | bool IReadOnly.IsReadOnly |
| | 170 | | { |
| 0 | 171 | | get { return this.propertyContainer.IsReadOnly; } |
| 16248 | 172 | | set { this.propertyContainer.IsReadOnly = value; } |
| | 173 | | } |
| | 174 | |
|
| | 175 | | #endregion //IPropertyMetadata |
| | 176 | |
|
| | 177 | | #region Internal/private methods |
| | 178 | | /// <summary> |
| | 179 | | /// Return a protocol object of the requested type. |
| | 180 | | /// </summary> |
| | 181 | | /// <returns>The protocol object of the requested type.</returns> |
| | 182 | | Models.UserAccount ITransportObjectProvider<Models.UserAccount>.GetTransportObject() |
| | 183 | | { |
| 825 | 184 | | Models.UserAccount result = new Models.UserAccount() |
| 825 | 185 | | { |
| 825 | 186 | | ElevationLevel = UtilitiesInternal.MapNullableEnum<Common.ElevationLevel, Models.ElevationLevel>(this.El |
| 1650 | 187 | | LinuxUserConfiguration = UtilitiesInternal.CreateObjectWithNullCheck(this.LinuxUserConfiguration, (o) => |
| 825 | 188 | | Name = this.Name, |
| 825 | 189 | | Password = this.Password, |
| 1650 | 190 | | WindowsUserConfiguration = UtilitiesInternal.CreateObjectWithNullCheck(this.WindowsUserConfiguration, (o |
| 825 | 191 | | }; |
| | 192 | |
|
| 825 | 193 | | return result; |
| | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> |
| | 197 | | /// Converts a collection of protocol layer objects to object layer collection objects. |
| | 198 | | /// </summary> |
| | 199 | | internal static IList<UserAccount> ConvertFromProtocolCollection(IEnumerable<Models.UserAccount> protoCollection |
| | 200 | | { |
| 198 | 201 | | ConcurrentChangeTrackedModifiableList<UserAccount> converted = UtilitiesInternal.CollectionToThreadSafeColle |
| 198 | 202 | | items: protoCollection, |
| 639 | 203 | | objectCreationFunc: o => new UserAccount(o)); |
| | 204 | |
|
| 198 | 205 | | return converted; |
| | 206 | | } |
| | 207 | |
|
| | 208 | | /// <summary> |
| | 209 | | /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state. |
| | 210 | | /// </summary> |
| | 211 | | internal static IList<UserAccount> ConvertFromProtocolCollectionAndFreeze(IEnumerable<Models.UserAccount> protoC |
| | 212 | | { |
| 1026 | 213 | | ConcurrentChangeTrackedModifiableList<UserAccount> converted = UtilitiesInternal.CollectionToThreadSafeColle |
| 1026 | 214 | | items: protoCollection, |
| 3345 | 215 | | objectCreationFunc: o => new UserAccount(o).Freeze()); |
| | 216 | |
|
| 1535 | 217 | | converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze()); |
| | 218 | |
|
| 1026 | 219 | | return converted; |
| | 220 | | } |
| | 221 | |
|
| | 222 | | /// <summary> |
| | 223 | | /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked |
| | 224 | | /// and returned as a readonly collection. |
| | 225 | | /// </summary> |
| | 226 | | internal static IReadOnlyList<UserAccount> ConvertFromProtocolCollectionReadOnly(IEnumerable<Models.UserAccount> |
| | 227 | | { |
| 0 | 228 | | IReadOnlyList<UserAccount> converted = |
| 0 | 229 | | UtilitiesInternal.CreateObjectWithNullCheck( |
| 0 | 230 | | UtilitiesInternal.CollectionToNonThreadSafeCollection( |
| 0 | 231 | | items: protoCollection, |
| 0 | 232 | | objectCreationFunc: o => new UserAccount(o).Freeze()), o => o.AsReadOnly()); |
| | 233 | |
|
| 0 | 234 | | return converted; |
| | 235 | | } |
| | 236 | |
|
| | 237 | | #endregion // Internal/private methods |
| | 238 | | } |
| | 239 | | } |