| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Network.Models |
| | 13 | | { |
| | 14 | | public partial class EffectiveNetworkSecurityRule |
| | 15 | | { |
| | 16 | | internal static EffectiveNetworkSecurityRule DeserializeEffectiveNetworkSecurityRule(JsonElement element) |
| | 17 | | { |
| 0 | 18 | | string name = default; |
| 0 | 19 | | EffectiveSecurityRuleProtocol? protocol = default; |
| 0 | 20 | | string sourcePortRange = default; |
| 0 | 21 | | string destinationPortRange = default; |
| 0 | 22 | | IReadOnlyList<string> sourcePortRanges = default; |
| 0 | 23 | | IReadOnlyList<string> destinationPortRanges = default; |
| 0 | 24 | | string sourceAddressPrefix = default; |
| 0 | 25 | | string destinationAddressPrefix = default; |
| 0 | 26 | | IReadOnlyList<string> sourceAddressPrefixes = default; |
| 0 | 27 | | IReadOnlyList<string> destinationAddressPrefixes = default; |
| 0 | 28 | | IReadOnlyList<string> expandedSourceAddressPrefix = default; |
| 0 | 29 | | IReadOnlyList<string> expandedDestinationAddressPrefix = default; |
| 0 | 30 | | SecurityRuleAccess? access = default; |
| 0 | 31 | | int? priority = default; |
| 0 | 32 | | SecurityRuleDirection? direction = default; |
| 0 | 33 | | foreach (var property in element.EnumerateObject()) |
| | 34 | | { |
| 0 | 35 | | if (property.NameEquals("name")) |
| | 36 | | { |
| 0 | 37 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 38 | | { |
| | 39 | | continue; |
| | 40 | | } |
| 0 | 41 | | name = property.Value.GetString(); |
| 0 | 42 | | continue; |
| | 43 | | } |
| 0 | 44 | | if (property.NameEquals("protocol")) |
| | 45 | | { |
| 0 | 46 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 47 | | { |
| | 48 | | continue; |
| | 49 | | } |
| 0 | 50 | | protocol = new EffectiveSecurityRuleProtocol(property.Value.GetString()); |
| 0 | 51 | | continue; |
| | 52 | | } |
| 0 | 53 | | if (property.NameEquals("sourcePortRange")) |
| | 54 | | { |
| 0 | 55 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 56 | | { |
| | 57 | | continue; |
| | 58 | | } |
| 0 | 59 | | sourcePortRange = property.Value.GetString(); |
| 0 | 60 | | continue; |
| | 61 | | } |
| 0 | 62 | | if (property.NameEquals("destinationPortRange")) |
| | 63 | | { |
| 0 | 64 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| | 66 | | continue; |
| | 67 | | } |
| 0 | 68 | | destinationPortRange = property.Value.GetString(); |
| 0 | 69 | | continue; |
| | 70 | | } |
| 0 | 71 | | if (property.NameEquals("sourcePortRanges")) |
| | 72 | | { |
| 0 | 73 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 74 | | { |
| | 75 | | continue; |
| | 76 | | } |
| 0 | 77 | | List<string> array = new List<string>(); |
| 0 | 78 | | foreach (var item in property.Value.EnumerateArray()) |
| | 79 | | { |
| 0 | 80 | | if (item.ValueKind == JsonValueKind.Null) |
| | 81 | | { |
| 0 | 82 | | array.Add(null); |
| | 83 | | } |
| | 84 | | else |
| | 85 | | { |
| 0 | 86 | | array.Add(item.GetString()); |
| | 87 | | } |
| | 88 | | } |
| 0 | 89 | | sourcePortRanges = array; |
| 0 | 90 | | continue; |
| | 91 | | } |
| 0 | 92 | | if (property.NameEquals("destinationPortRanges")) |
| | 93 | | { |
| 0 | 94 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 95 | | { |
| | 96 | | continue; |
| | 97 | | } |
| 0 | 98 | | List<string> array = new List<string>(); |
| 0 | 99 | | foreach (var item in property.Value.EnumerateArray()) |
| | 100 | | { |
| 0 | 101 | | if (item.ValueKind == JsonValueKind.Null) |
| | 102 | | { |
| 0 | 103 | | array.Add(null); |
| | 104 | | } |
| | 105 | | else |
| | 106 | | { |
| 0 | 107 | | array.Add(item.GetString()); |
| | 108 | | } |
| | 109 | | } |
| 0 | 110 | | destinationPortRanges = array; |
| 0 | 111 | | continue; |
| | 112 | | } |
| 0 | 113 | | if (property.NameEquals("sourceAddressPrefix")) |
| | 114 | | { |
| 0 | 115 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 116 | | { |
| | 117 | | continue; |
| | 118 | | } |
| 0 | 119 | | sourceAddressPrefix = property.Value.GetString(); |
| 0 | 120 | | continue; |
| | 121 | | } |
| 0 | 122 | | if (property.NameEquals("destinationAddressPrefix")) |
| | 123 | | { |
| 0 | 124 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 125 | | { |
| | 126 | | continue; |
| | 127 | | } |
| 0 | 128 | | destinationAddressPrefix = property.Value.GetString(); |
| 0 | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | if (property.NameEquals("sourceAddressPrefixes")) |
| | 132 | | { |
| 0 | 133 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 134 | | { |
| | 135 | | continue; |
| | 136 | | } |
| 0 | 137 | | List<string> array = new List<string>(); |
| 0 | 138 | | foreach (var item in property.Value.EnumerateArray()) |
| | 139 | | { |
| 0 | 140 | | if (item.ValueKind == JsonValueKind.Null) |
| | 141 | | { |
| 0 | 142 | | array.Add(null); |
| | 143 | | } |
| | 144 | | else |
| | 145 | | { |
| 0 | 146 | | array.Add(item.GetString()); |
| | 147 | | } |
| | 148 | | } |
| 0 | 149 | | sourceAddressPrefixes = array; |
| 0 | 150 | | continue; |
| | 151 | | } |
| 0 | 152 | | if (property.NameEquals("destinationAddressPrefixes")) |
| | 153 | | { |
| 0 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 0 | 158 | | List<string> array = new List<string>(); |
| 0 | 159 | | foreach (var item in property.Value.EnumerateArray()) |
| | 160 | | { |
| 0 | 161 | | if (item.ValueKind == JsonValueKind.Null) |
| | 162 | | { |
| 0 | 163 | | array.Add(null); |
| | 164 | | } |
| | 165 | | else |
| | 166 | | { |
| 0 | 167 | | array.Add(item.GetString()); |
| | 168 | | } |
| | 169 | | } |
| 0 | 170 | | destinationAddressPrefixes = array; |
| 0 | 171 | | continue; |
| | 172 | | } |
| 0 | 173 | | if (property.NameEquals("expandedSourceAddressPrefix")) |
| | 174 | | { |
| 0 | 175 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 176 | | { |
| | 177 | | continue; |
| | 178 | | } |
| 0 | 179 | | List<string> array = new List<string>(); |
| 0 | 180 | | foreach (var item in property.Value.EnumerateArray()) |
| | 181 | | { |
| 0 | 182 | | if (item.ValueKind == JsonValueKind.Null) |
| | 183 | | { |
| 0 | 184 | | array.Add(null); |
| | 185 | | } |
| | 186 | | else |
| | 187 | | { |
| 0 | 188 | | array.Add(item.GetString()); |
| | 189 | | } |
| | 190 | | } |
| 0 | 191 | | expandedSourceAddressPrefix = array; |
| 0 | 192 | | continue; |
| | 193 | | } |
| 0 | 194 | | if (property.NameEquals("expandedDestinationAddressPrefix")) |
| | 195 | | { |
| 0 | 196 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 197 | | { |
| | 198 | | continue; |
| | 199 | | } |
| 0 | 200 | | List<string> array = new List<string>(); |
| 0 | 201 | | foreach (var item in property.Value.EnumerateArray()) |
| | 202 | | { |
| 0 | 203 | | if (item.ValueKind == JsonValueKind.Null) |
| | 204 | | { |
| 0 | 205 | | array.Add(null); |
| | 206 | | } |
| | 207 | | else |
| | 208 | | { |
| 0 | 209 | | array.Add(item.GetString()); |
| | 210 | | } |
| | 211 | | } |
| 0 | 212 | | expandedDestinationAddressPrefix = array; |
| 0 | 213 | | continue; |
| | 214 | | } |
| 0 | 215 | | if (property.NameEquals("access")) |
| | 216 | | { |
| 0 | 217 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 218 | | { |
| | 219 | | continue; |
| | 220 | | } |
| 0 | 221 | | access = new SecurityRuleAccess(property.Value.GetString()); |
| 0 | 222 | | continue; |
| | 223 | | } |
| 0 | 224 | | if (property.NameEquals("priority")) |
| | 225 | | { |
| 0 | 226 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 227 | | { |
| | 228 | | continue; |
| | 229 | | } |
| 0 | 230 | | priority = property.Value.GetInt32(); |
| 0 | 231 | | continue; |
| | 232 | | } |
| 0 | 233 | | if (property.NameEquals("direction")) |
| | 234 | | { |
| 0 | 235 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 236 | | { |
| | 237 | | continue; |
| | 238 | | } |
| 0 | 239 | | direction = new SecurityRuleDirection(property.Value.GetString()); |
| | 240 | | continue; |
| | 241 | | } |
| | 242 | | } |
| 0 | 243 | | return new EffectiveNetworkSecurityRule(name, protocol, sourcePortRange, destinationPortRange, sourcePortRan |
| | 244 | | } |
| | 245 | | } |
| | 246 | | } |