| | 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 network security group rule to apply to an inbound endpoint. |
| | 22 | | /// </summary> |
| | 23 | | public partial class NetworkSecurityGroupRule : ITransportObjectProvider<Models.NetworkSecurityGroupRule>, IProperty |
| | 24 | | { |
| | 25 | | #region Constructors |
| | 26 | | /// <summary> |
| | 27 | | /// Initializes a new instance of the <see cref="NetworkSecurityGroupRule"/> class. |
| | 28 | | /// </summary> |
| | 29 | | /// <param name='priority'>The priority for this rule.</param> |
| | 30 | | /// <param name='access'>The action that should be taken for a specified IP address, subnet range or tag.</param |
| | 31 | | /// <param name='sourceAddressPrefix'>The source address prefix or tag to match for the rule.</param> |
| | 32 | | /// <param name='sourcePortRanges'>The source port ranges to match for the rule.</param> |
| 4993 | 33 | | public NetworkSecurityGroupRule( |
| 4993 | 34 | | int priority, |
| 4993 | 35 | | Common.NetworkSecurityGroupRuleAccess access, |
| 4993 | 36 | | string sourceAddressPrefix, |
| 4993 | 37 | | IReadOnlyList<string> sourcePortRanges = default(IReadOnlyList<string>)) |
| | 38 | | { |
| 4993 | 39 | | this.Priority = priority; |
| 4993 | 40 | | this.Access = access; |
| 4993 | 41 | | this.SourceAddressPrefix = sourceAddressPrefix; |
| 4993 | 42 | | this.SourcePortRanges = sourcePortRanges; |
| 4993 | 43 | | } |
| | 44 | |
|
| 1329 | 45 | | internal NetworkSecurityGroupRule(Models.NetworkSecurityGroupRule protocolObject) |
| | 46 | | { |
| 1329 | 47 | | this.Access = UtilitiesInternal.MapEnum<Models.NetworkSecurityGroupRuleAccess, Common.NetworkSecurityGroupRu |
| 1329 | 48 | | this.Priority = protocolObject.Priority; |
| 1329 | 49 | | this.SourceAddressPrefix = protocolObject.SourceAddressPrefix; |
| 2011 | 50 | | this.SourcePortRanges = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.SourcePortRanges, o => o. |
| 1329 | 51 | | } |
| | 52 | |
|
| | 53 | | #endregion Constructors |
| | 54 | |
|
| | 55 | | #region NetworkSecurityGroupRule |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// Gets the action that should be taken for a specified IP address, subnet range or tag. |
| | 59 | | /// </summary> |
| 11312 | 60 | | public Common.NetworkSecurityGroupRuleAccess Access { get; } |
| | 61 | |
|
| | 62 | | /// <summary> |
| | 63 | | /// Gets the priority for this rule. |
| | 64 | | /// </summary> |
| | 65 | | /// <remarks> |
| | 66 | | /// Priorities within a pool must be unique and are evaluated in order of priority. The lower the number the hig |
| | 67 | | /// the priority. For example, rules could be specified with order numbers of 150, 250, and 350. The rule with t |
| | 68 | | /// order number of 150 takes precedence over the rule that has an order of 250. Allowed priorities are 150 to 4 |
| | 69 | | /// </remarks> |
| 11312 | 70 | | public int Priority { get; } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Gets the source address prefix or tag to match for the rule. |
| | 74 | | /// </summary> |
| | 75 | | /// <remarks> |
| | 76 | | /// Valid values are a single IP address (i.e. 10.10.10.10), IP subnet (i.e. 192.168.1.0/24), default tag, or * |
| | 77 | | /// all addresses). |
| | 78 | | /// </remarks> |
| 11312 | 79 | | public string SourceAddressPrefix { get; } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Gets the source port ranges to match for the rule. |
| | 83 | | /// </summary> |
| | 84 | | /// <remarks> |
| | 85 | | /// Valid values are '*' (for all ports 0 - 65535), a specific port (i.e. 22), or a port range (i.e. 100-200). T |
| | 86 | | /// ports must be in the range of 0 to 65535. Each entry in this collection must not overlap any other entry (ei |
| | 87 | | /// a range or an individual port). If any other values are provided the request fails with HTTP status code 400 |
| | 88 | | /// The default value is '*' |
| | 89 | | /// </remarks> |
| 11312 | 90 | | public IReadOnlyList<string> SourcePortRanges { get; } |
| | 91 | |
|
| | 92 | | #endregion // NetworkSecurityGroupRule |
| | 93 | |
|
| | 94 | | #region IPropertyMetadata |
| | 95 | |
|
| | 96 | | bool IModifiable.HasBeenModified |
| | 97 | | { |
| | 98 | | //This class is compile time readonly so it cannot have been modified |
| 0 | 99 | | get { return false; } |
| | 100 | | } |
| | 101 | |
|
| | 102 | | bool IReadOnly.IsReadOnly |
| | 103 | | { |
| 0 | 104 | | get { return true; } |
| | 105 | | set |
| | 106 | | { |
| | 107 | | // This class is compile time readonly already |
| 1330 | 108 | | } |
| | 109 | | } |
| | 110 | |
|
| | 111 | | #endregion // IPropertyMetadata |
| | 112 | |
|
| | 113 | | #region Internal/private methods |
| | 114 | |
|
| | 115 | | /// <summary> |
| | 116 | | /// Return a protocol object of the requested type. |
| | 117 | | /// </summary> |
| | 118 | | /// <returns>The protocol object of the requested type.</returns> |
| | 119 | | Models.NetworkSecurityGroupRule ITransportObjectProvider<Models.NetworkSecurityGroupRule>.GetTransportObject() |
| | 120 | | { |
| 4991 | 121 | | Models.NetworkSecurityGroupRule result = new Models.NetworkSecurityGroupRule() |
| 4991 | 122 | | { |
| 4991 | 123 | | Access = UtilitiesInternal.MapEnum<Common.NetworkSecurityGroupRuleAccess, Models.NetworkSecurityGroupRul |
| 4991 | 124 | | Priority = this.Priority, |
| 4991 | 125 | | SourceAddressPrefix = this.SourceAddressPrefix, |
| 9982 | 126 | | SourcePortRanges = UtilitiesInternal.CreateObjectWithNullCheck(this.SourcePortRanges, o => o.ToList()), |
| 4991 | 127 | | }; |
| | 128 | |
|
| 4991 | 129 | | return result; |
| | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> |
| | 133 | | /// Converts a collection of protocol layer objects to object layer collection objects. |
| | 134 | | /// </summary> |
| | 135 | | internal static IList<NetworkSecurityGroupRule> ConvertFromProtocolCollection(IEnumerable<Models.NetworkSecurity |
| | 136 | | { |
| 0 | 137 | | ConcurrentChangeTrackedModifiableList<NetworkSecurityGroupRule> converted = UtilitiesInternal.CollectionToTh |
| 0 | 138 | | items: protoCollection, |
| 0 | 139 | | objectCreationFunc: o => new NetworkSecurityGroupRule(o)); |
| | 140 | |
|
| 0 | 141 | | return converted; |
| | 142 | | } |
| | 143 | |
|
| | 144 | | /// <summary> |
| | 145 | | /// Converts a collection of protocol layer objects to object layer collection objects, in a frozen state. |
| | 146 | | /// </summary> |
| | 147 | | internal static IList<NetworkSecurityGroupRule> ConvertFromProtocolCollectionAndFreeze(IEnumerable<Models.Networ |
| | 148 | | { |
| 0 | 149 | | ConcurrentChangeTrackedModifiableList<NetworkSecurityGroupRule> converted = UtilitiesInternal.CollectionToTh |
| 0 | 150 | | items: protoCollection, |
| 0 | 151 | | objectCreationFunc: o => new NetworkSecurityGroupRule(o).Freeze()); |
| | 152 | |
|
| 0 | 153 | | converted = UtilitiesInternal.CreateObjectWithNullCheck(converted, o => o.Freeze()); |
| | 154 | |
|
| 0 | 155 | | return converted; |
| | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> |
| | 159 | | /// Converts a collection of protocol layer objects to object layer collection objects, with each object marked |
| | 160 | | /// and returned as a readonly collection. |
| | 161 | | /// </summary> |
| | 162 | | internal static IReadOnlyList<NetworkSecurityGroupRule> ConvertFromProtocolCollectionReadOnly(IEnumerable<Models |
| | 163 | | { |
| 647 | 164 | | IReadOnlyList<NetworkSecurityGroupRule> converted = |
| 647 | 165 | | UtilitiesInternal.CreateObjectWithNullCheck( |
| 647 | 166 | | UtilitiesInternal.CollectionToNonThreadSafeCollection( |
| 647 | 167 | | items: protoCollection, |
| 2287 | 168 | | objectCreationFunc: o => new NetworkSecurityGroupRule(o).Freeze()), o => o.AsReadOnly()); |
| | 169 | |
|
| 647 | 170 | | return converted; |
| | 171 | | } |
| | 172 | |
|
| | 173 | | #endregion // Internal/private methods |
| | 174 | | } |
| | 175 | | } |