| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Network.Models |
| | 12 | | { |
| | 13 | | public partial class FirewallPolicyRuleCondition : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Name != null) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("name"); |
| 0 | 21 | | writer.WriteStringValue(Name); |
| | 22 | | } |
| 0 | 23 | | if (Description != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("description"); |
| 0 | 26 | | writer.WriteStringValue(Description); |
| | 27 | | } |
| 0 | 28 | | writer.WritePropertyName("ruleConditionType"); |
| 0 | 29 | | writer.WriteStringValue(RuleConditionType.ToString()); |
| 0 | 30 | | writer.WriteEndObject(); |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | internal static FirewallPolicyRuleCondition DeserializeFirewallPolicyRuleCondition(JsonElement element) |
| | 34 | | { |
| 0 | 35 | | if (element.TryGetProperty("ruleConditionType", out JsonElement discriminator)) |
| | 36 | | { |
| 0 | 37 | | switch (discriminator.GetString()) |
| | 38 | | { |
| 0 | 39 | | case "ApplicationRuleCondition": return ApplicationRuleCondition.DeserializeApplicationRuleCondition |
| 0 | 40 | | case "NatRuleCondition": return NatRuleCondition.DeserializeNatRuleCondition(element); |
| 0 | 41 | | case "NetworkRuleCondition": return NetworkRuleCondition.DeserializeNetworkRuleCondition(element); |
| | 42 | | } |
| | 43 | | } |
| 0 | 44 | | string name = default; |
| 0 | 45 | | string description = default; |
| 0 | 46 | | FirewallPolicyRuleConditionType ruleConditionType = default; |
| 0 | 47 | | foreach (var property in element.EnumerateObject()) |
| | 48 | | { |
| 0 | 49 | | if (property.NameEquals("name")) |
| | 50 | | { |
| 0 | 51 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 52 | | { |
| | 53 | | continue; |
| | 54 | | } |
| 0 | 55 | | name = property.Value.GetString(); |
| 0 | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | if (property.NameEquals("description")) |
| | 59 | | { |
| 0 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | description = property.Value.GetString(); |
| 0 | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | if (property.NameEquals("ruleConditionType")) |
| | 68 | | { |
| 0 | 69 | | ruleConditionType = new FirewallPolicyRuleConditionType(property.Value.GetString()); |
| | 70 | | continue; |
| | 71 | | } |
| | 72 | | } |
| 0 | 73 | | return new FirewallPolicyRuleCondition(name, description, ruleConditionType); |
| | 74 | | } |
| | 75 | | } |
| | 76 | | } |