| | 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 NetworkSecurityGroup : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 56 | 18 | | writer.WriteStartObject(); |
| 56 | 19 | | if (Etag != null) |
| | 20 | | { |
| 8 | 21 | | writer.WritePropertyName("etag"); |
| 8 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 56 | 24 | | if (Id != null) |
| | 25 | | { |
| 8 | 26 | | writer.WritePropertyName("id"); |
| 8 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 56 | 29 | | if (Name != null) |
| | 30 | | { |
| 8 | 31 | | writer.WritePropertyName("name"); |
| 8 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 56 | 34 | | if (Type != null) |
| | 35 | | { |
| 8 | 36 | | writer.WritePropertyName("type"); |
| 8 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 56 | 39 | | if (Location != null) |
| | 40 | | { |
| 56 | 41 | | writer.WritePropertyName("location"); |
| 56 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 56 | 44 | | if (Tags != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("tags"); |
| 0 | 47 | | writer.WriteStartObject(); |
| 0 | 48 | | foreach (var item in Tags) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName(item.Key); |
| 0 | 51 | | writer.WriteStringValue(item.Value); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndObject(); |
| | 54 | | } |
| 56 | 55 | | writer.WritePropertyName("properties"); |
| 56 | 56 | | writer.WriteStartObject(); |
| 56 | 57 | | if (SecurityRules != null) |
| | 58 | | { |
| 40 | 59 | | writer.WritePropertyName("securityRules"); |
| 40 | 60 | | writer.WriteStartArray(); |
| 176 | 61 | | foreach (var item in SecurityRules) |
| | 62 | | { |
| 48 | 63 | | writer.WriteObjectValue(item); |
| | 64 | | } |
| 40 | 65 | | writer.WriteEndArray(); |
| | 66 | | } |
| 56 | 67 | | if (DefaultSecurityRules != null) |
| | 68 | | { |
| 8 | 69 | | writer.WritePropertyName("defaultSecurityRules"); |
| 8 | 70 | | writer.WriteStartArray(); |
| 112 | 71 | | foreach (var item in DefaultSecurityRules) |
| | 72 | | { |
| 48 | 73 | | writer.WriteObjectValue(item); |
| | 74 | | } |
| 8 | 75 | | writer.WriteEndArray(); |
| | 76 | | } |
| 56 | 77 | | if (NetworkInterfaces != null) |
| | 78 | | { |
| 0 | 79 | | writer.WritePropertyName("networkInterfaces"); |
| 0 | 80 | | writer.WriteStartArray(); |
| 0 | 81 | | foreach (var item in NetworkInterfaces) |
| | 82 | | { |
| 0 | 83 | | writer.WriteObjectValue(item); |
| | 84 | | } |
| 0 | 85 | | writer.WriteEndArray(); |
| | 86 | | } |
| 56 | 87 | | if (Subnets != null) |
| | 88 | | { |
| 0 | 89 | | writer.WritePropertyName("subnets"); |
| 0 | 90 | | writer.WriteStartArray(); |
| 0 | 91 | | foreach (var item in Subnets) |
| | 92 | | { |
| 0 | 93 | | writer.WriteObjectValue(item); |
| | 94 | | } |
| 0 | 95 | | writer.WriteEndArray(); |
| | 96 | | } |
| 56 | 97 | | if (FlowLogs != null) |
| | 98 | | { |
| 0 | 99 | | writer.WritePropertyName("flowLogs"); |
| 0 | 100 | | writer.WriteStartArray(); |
| 0 | 101 | | foreach (var item in FlowLogs) |
| | 102 | | { |
| 0 | 103 | | writer.WriteObjectValue(item); |
| | 104 | | } |
| 0 | 105 | | writer.WriteEndArray(); |
| | 106 | | } |
| 56 | 107 | | if (ResourceGuid != null) |
| | 108 | | { |
| 8 | 109 | | writer.WritePropertyName("resourceGuid"); |
| 8 | 110 | | writer.WriteStringValue(ResourceGuid); |
| | 111 | | } |
| 56 | 112 | | if (ProvisioningState != null) |
| | 113 | | { |
| 8 | 114 | | writer.WritePropertyName("provisioningState"); |
| 8 | 115 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 116 | | } |
| 56 | 117 | | writer.WriteEndObject(); |
| 56 | 118 | | writer.WriteEndObject(); |
| 56 | 119 | | } |
| | 120 | |
|
| | 121 | | internal static NetworkSecurityGroup DeserializeNetworkSecurityGroup(JsonElement element) |
| | 122 | | { |
| 272 | 123 | | string etag = default; |
| 272 | 124 | | string id = default; |
| 272 | 125 | | string name = default; |
| 272 | 126 | | string type = default; |
| 272 | 127 | | string location = default; |
| 272 | 128 | | IDictionary<string, string> tags = default; |
| 272 | 129 | | IList<SecurityRule> securityRules = default; |
| 272 | 130 | | IList<SecurityRule> defaultSecurityRules = default; |
| 272 | 131 | | IList<NetworkInterface> networkInterfaces = default; |
| 272 | 132 | | IList<Subnet> subnets = default; |
| 272 | 133 | | IList<FlowLog> flowLogs = default; |
| 272 | 134 | | string resourceGuid = default; |
| 272 | 135 | | ProvisioningState? provisioningState = default; |
| 3304 | 136 | | foreach (var property in element.EnumerateObject()) |
| | 137 | | { |
| 1380 | 138 | | if (property.NameEquals("etag")) |
| | 139 | | { |
| 220 | 140 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 141 | | { |
| | 142 | | continue; |
| | 143 | | } |
| 220 | 144 | | etag = property.Value.GetString(); |
| 220 | 145 | | continue; |
| | 146 | | } |
| 1160 | 147 | | if (property.NameEquals("id")) |
| | 148 | | { |
| 272 | 149 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 150 | | { |
| | 151 | | continue; |
| | 152 | | } |
| 272 | 153 | | id = property.Value.GetString(); |
| 272 | 154 | | continue; |
| | 155 | | } |
| 888 | 156 | | if (property.NameEquals("name")) |
| | 157 | | { |
| 220 | 158 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 159 | | { |
| | 160 | | continue; |
| | 161 | | } |
| 220 | 162 | | name = property.Value.GetString(); |
| 220 | 163 | | continue; |
| | 164 | | } |
| 668 | 165 | | if (property.NameEquals("type")) |
| | 166 | | { |
| 220 | 167 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 168 | | { |
| | 169 | | continue; |
| | 170 | | } |
| 220 | 171 | | type = property.Value.GetString(); |
| 220 | 172 | | continue; |
| | 173 | | } |
| 448 | 174 | | if (property.NameEquals("location")) |
| | 175 | | { |
| 220 | 176 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 177 | | { |
| | 178 | | continue; |
| | 179 | | } |
| 220 | 180 | | location = property.Value.GetString(); |
| 220 | 181 | | continue; |
| | 182 | | } |
| 228 | 183 | | if (property.NameEquals("tags")) |
| | 184 | | { |
| 8 | 185 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| | 187 | | continue; |
| | 188 | | } |
| 8 | 189 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 64 | 190 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 191 | | { |
| 24 | 192 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 193 | | { |
| 0 | 194 | | dictionary.Add(property0.Name, null); |
| | 195 | | } |
| | 196 | | else |
| | 197 | | { |
| 24 | 198 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 199 | | } |
| | 200 | | } |
| 8 | 201 | | tags = dictionary; |
| 8 | 202 | | continue; |
| | 203 | | } |
| 220 | 204 | | if (property.NameEquals("properties")) |
| | 205 | | { |
| 2256 | 206 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 207 | | { |
| 908 | 208 | | if (property0.NameEquals("securityRules")) |
| | 209 | | { |
| 220 | 210 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 211 | | { |
| | 212 | | continue; |
| | 213 | | } |
| 220 | 214 | | List<SecurityRule> array = new List<SecurityRule>(); |
| 3272 | 215 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 216 | | { |
| 1416 | 217 | | if (item.ValueKind == JsonValueKind.Null) |
| | 218 | | { |
| 0 | 219 | | array.Add(null); |
| | 220 | | } |
| | 221 | | else |
| | 222 | | { |
| 1416 | 223 | | array.Add(SecurityRule.DeserializeSecurityRule(item)); |
| | 224 | | } |
| | 225 | | } |
| 220 | 226 | | securityRules = array; |
| 220 | 227 | | continue; |
| | 228 | | } |
| 688 | 229 | | if (property0.NameEquals("defaultSecurityRules")) |
| | 230 | | { |
| 220 | 231 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 232 | | { |
| | 233 | | continue; |
| | 234 | | } |
| 220 | 235 | | List<SecurityRule> array = new List<SecurityRule>(); |
| 3080 | 236 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 237 | | { |
| 1320 | 238 | | if (item.ValueKind == JsonValueKind.Null) |
| | 239 | | { |
| 0 | 240 | | array.Add(null); |
| | 241 | | } |
| | 242 | | else |
| | 243 | | { |
| 1320 | 244 | | array.Add(SecurityRule.DeserializeSecurityRule(item)); |
| | 245 | | } |
| | 246 | | } |
| 220 | 247 | | defaultSecurityRules = array; |
| 220 | 248 | | continue; |
| | 249 | | } |
| 468 | 250 | | if (property0.NameEquals("networkInterfaces")) |
| | 251 | | { |
| 12 | 252 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 253 | | { |
| | 254 | | continue; |
| | 255 | | } |
| 12 | 256 | | List<NetworkInterface> array = new List<NetworkInterface>(); |
| 48 | 257 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 258 | | { |
| 12 | 259 | | if (item.ValueKind == JsonValueKind.Null) |
| | 260 | | { |
| 0 | 261 | | array.Add(null); |
| | 262 | | } |
| | 263 | | else |
| | 264 | | { |
| 12 | 265 | | array.Add(NetworkInterface.DeserializeNetworkInterface(item)); |
| | 266 | | } |
| | 267 | | } |
| 12 | 268 | | networkInterfaces = array; |
| 12 | 269 | | continue; |
| | 270 | | } |
| 456 | 271 | | if (property0.NameEquals("subnets")) |
| | 272 | | { |
| 16 | 273 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 274 | | { |
| | 275 | | continue; |
| | 276 | | } |
| 16 | 277 | | List<Subnet> array = new List<Subnet>(); |
| 80 | 278 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 279 | | { |
| 24 | 280 | | if (item.ValueKind == JsonValueKind.Null) |
| | 281 | | { |
| 0 | 282 | | array.Add(null); |
| | 283 | | } |
| | 284 | | else |
| | 285 | | { |
| 24 | 286 | | array.Add(Subnet.DeserializeSubnet(item)); |
| | 287 | | } |
| | 288 | | } |
| 16 | 289 | | subnets = array; |
| 16 | 290 | | continue; |
| | 291 | | } |
| 440 | 292 | | if (property0.NameEquals("flowLogs")) |
| | 293 | | { |
| 0 | 294 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 295 | | { |
| | 296 | | continue; |
| | 297 | | } |
| 0 | 298 | | List<FlowLog> array = new List<FlowLog>(); |
| 0 | 299 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 300 | | { |
| 0 | 301 | | if (item.ValueKind == JsonValueKind.Null) |
| | 302 | | { |
| 0 | 303 | | array.Add(null); |
| | 304 | | } |
| | 305 | | else |
| | 306 | | { |
| 0 | 307 | | array.Add(FlowLog.DeserializeFlowLog(item)); |
| | 308 | | } |
| | 309 | | } |
| 0 | 310 | | flowLogs = array; |
| 0 | 311 | | continue; |
| | 312 | | } |
| 440 | 313 | | if (property0.NameEquals("resourceGuid")) |
| | 314 | | { |
| 220 | 315 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 316 | | { |
| | 317 | | continue; |
| | 318 | | } |
| 220 | 319 | | resourceGuid = property0.Value.GetString(); |
| 220 | 320 | | continue; |
| | 321 | | } |
| 220 | 322 | | if (property0.NameEquals("provisioningState")) |
| | 323 | | { |
| 220 | 324 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 325 | | { |
| | 326 | | continue; |
| | 327 | | } |
| 220 | 328 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| | 329 | | continue; |
| | 330 | | } |
| | 331 | | } |
| | 332 | | continue; |
| | 333 | | } |
| | 334 | | } |
| 272 | 335 | | return new NetworkSecurityGroup(id, name, type, location, tags, etag, securityRules, defaultSecurityRules, n |
| | 336 | | } |
| | 337 | | } |
| | 338 | | } |