| | 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 MatchCondition : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("matchVariables"); |
| 0 | 20 | | writer.WriteStartArray(); |
| 0 | 21 | | foreach (var item in MatchVariables) |
| | 22 | | { |
| 0 | 23 | | writer.WriteObjectValue(item); |
| | 24 | | } |
| 0 | 25 | | writer.WriteEndArray(); |
| 0 | 26 | | writer.WritePropertyName("operator"); |
| 0 | 27 | | writer.WriteStringValue(Operator.ToString()); |
| 0 | 28 | | if (NegationConditon != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("negationConditon"); |
| 0 | 31 | | writer.WriteBooleanValue(NegationConditon.Value); |
| | 32 | | } |
| 0 | 33 | | writer.WritePropertyName("matchValues"); |
| 0 | 34 | | writer.WriteStartArray(); |
| 0 | 35 | | foreach (var item in MatchValues) |
| | 36 | | { |
| 0 | 37 | | writer.WriteStringValue(item); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndArray(); |
| 0 | 40 | | if (Transforms != null) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("transforms"); |
| 0 | 43 | | writer.WriteStartArray(); |
| 0 | 44 | | foreach (var item in Transforms) |
| | 45 | | { |
| 0 | 46 | | writer.WriteStringValue(item.ToString()); |
| | 47 | | } |
| 0 | 48 | | writer.WriteEndArray(); |
| | 49 | | } |
| 0 | 50 | | writer.WriteEndObject(); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | internal static MatchCondition DeserializeMatchCondition(JsonElement element) |
| | 54 | | { |
| 0 | 55 | | IList<MatchVariable> matchVariables = default; |
| 0 | 56 | | WebApplicationFirewallOperator @operator = default; |
| 0 | 57 | | bool? negationConditon = default; |
| 0 | 58 | | IList<string> matchValues = default; |
| 0 | 59 | | IList<WebApplicationFirewallTransform> transforms = default; |
| 0 | 60 | | foreach (var property in element.EnumerateObject()) |
| | 61 | | { |
| 0 | 62 | | if (property.NameEquals("matchVariables")) |
| | 63 | | { |
| 0 | 64 | | List<MatchVariable> array = new List<MatchVariable>(); |
| 0 | 65 | | foreach (var item in property.Value.EnumerateArray()) |
| | 66 | | { |
| 0 | 67 | | if (item.ValueKind == JsonValueKind.Null) |
| | 68 | | { |
| 0 | 69 | | array.Add(null); |
| | 70 | | } |
| | 71 | | else |
| | 72 | | { |
| 0 | 73 | | array.Add(MatchVariable.DeserializeMatchVariable(item)); |
| | 74 | | } |
| | 75 | | } |
| 0 | 76 | | matchVariables = array; |
| 0 | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | if (property.NameEquals("operator")) |
| | 80 | | { |
| 0 | 81 | | @operator = new WebApplicationFirewallOperator(property.Value.GetString()); |
| 0 | 82 | | continue; |
| | 83 | | } |
| 0 | 84 | | if (property.NameEquals("negationConditon")) |
| | 85 | | { |
| 0 | 86 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 87 | | { |
| | 88 | | continue; |
| | 89 | | } |
| 0 | 90 | | negationConditon = property.Value.GetBoolean(); |
| 0 | 91 | | continue; |
| | 92 | | } |
| 0 | 93 | | if (property.NameEquals("matchValues")) |
| | 94 | | { |
| 0 | 95 | | List<string> array = new List<string>(); |
| 0 | 96 | | foreach (var item in property.Value.EnumerateArray()) |
| | 97 | | { |
| 0 | 98 | | if (item.ValueKind == JsonValueKind.Null) |
| | 99 | | { |
| 0 | 100 | | array.Add(null); |
| | 101 | | } |
| | 102 | | else |
| | 103 | | { |
| 0 | 104 | | array.Add(item.GetString()); |
| | 105 | | } |
| | 106 | | } |
| 0 | 107 | | matchValues = array; |
| 0 | 108 | | continue; |
| | 109 | | } |
| 0 | 110 | | if (property.NameEquals("transforms")) |
| | 111 | | { |
| 0 | 112 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 113 | | { |
| | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | List<WebApplicationFirewallTransform> array = new List<WebApplicationFirewallTransform>(); |
| 0 | 117 | | foreach (var item in property.Value.EnumerateArray()) |
| | 118 | | { |
| 0 | 119 | | array.Add(new WebApplicationFirewallTransform(item.GetString())); |
| | 120 | | } |
| 0 | 121 | | transforms = array; |
| | 122 | | continue; |
| | 123 | | } |
| | 124 | | } |
| 0 | 125 | | return new MatchCondition(matchVariables, @operator, negationConditon, matchValues, transforms); |
| | 126 | | } |
| | 127 | | } |
| | 128 | | } |