| | 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 WebApplicationFirewallCustomRule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Name != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("name"); |
| 0 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 0 | 24 | | if (Etag != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("etag"); |
| 0 | 27 | | writer.WriteStringValue(Etag); |
| | 28 | | } |
| 0 | 29 | | writer.WritePropertyName("priority"); |
| 0 | 30 | | writer.WriteNumberValue(Priority); |
| 0 | 31 | | writer.WritePropertyName("ruleType"); |
| 0 | 32 | | writer.WriteStringValue(RuleType.ToString()); |
| 0 | 33 | | writer.WritePropertyName("matchConditions"); |
| 0 | 34 | | writer.WriteStartArray(); |
| 0 | 35 | | foreach (var item in MatchConditions) |
| | 36 | | { |
| 0 | 37 | | writer.WriteObjectValue(item); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndArray(); |
| 0 | 40 | | writer.WritePropertyName("action"); |
| 0 | 41 | | writer.WriteStringValue(Action.ToString()); |
| 0 | 42 | | writer.WriteEndObject(); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | internal static WebApplicationFirewallCustomRule DeserializeWebApplicationFirewallCustomRule(JsonElement element |
| | 46 | | { |
| 0 | 47 | | string name = default; |
| 0 | 48 | | string etag = default; |
| 0 | 49 | | int priority = default; |
| 0 | 50 | | WebApplicationFirewallRuleType ruleType = default; |
| 0 | 51 | | IList<MatchCondition> matchConditions = default; |
| 0 | 52 | | WebApplicationFirewallAction action = default; |
| 0 | 53 | | foreach (var property in element.EnumerateObject()) |
| | 54 | | { |
| 0 | 55 | | if (property.NameEquals("name")) |
| | 56 | | { |
| 0 | 57 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 58 | | { |
| | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | name = property.Value.GetString(); |
| 0 | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | if (property.NameEquals("etag")) |
| | 65 | | { |
| 0 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | etag = property.Value.GetString(); |
| 0 | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | if (property.NameEquals("priority")) |
| | 74 | | { |
| 0 | 75 | | priority = property.Value.GetInt32(); |
| 0 | 76 | | continue; |
| | 77 | | } |
| 0 | 78 | | if (property.NameEquals("ruleType")) |
| | 79 | | { |
| 0 | 80 | | ruleType = new WebApplicationFirewallRuleType(property.Value.GetString()); |
| 0 | 81 | | continue; |
| | 82 | | } |
| 0 | 83 | | if (property.NameEquals("matchConditions")) |
| | 84 | | { |
| 0 | 85 | | List<MatchCondition> array = new List<MatchCondition>(); |
| 0 | 86 | | foreach (var item in property.Value.EnumerateArray()) |
| | 87 | | { |
| 0 | 88 | | if (item.ValueKind == JsonValueKind.Null) |
| | 89 | | { |
| 0 | 90 | | array.Add(null); |
| | 91 | | } |
| | 92 | | else |
| | 93 | | { |
| 0 | 94 | | array.Add(MatchCondition.DeserializeMatchCondition(item)); |
| | 95 | | } |
| | 96 | | } |
| 0 | 97 | | matchConditions = array; |
| 0 | 98 | | continue; |
| | 99 | | } |
| 0 | 100 | | if (property.NameEquals("action")) |
| | 101 | | { |
| 0 | 102 | | action = new WebApplicationFirewallAction(property.Value.GetString()); |
| | 103 | | continue; |
| | 104 | | } |
| | 105 | | } |
| 0 | 106 | | return new WebApplicationFirewallCustomRule(name, etag, priority, ruleType, matchConditions, action); |
| | 107 | | } |
| | 108 | | } |
| | 109 | | } |