| | 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 ApplicationGatewayRewriteRule : 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 (RuleSequence != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("ruleSequence"); |
| 0 | 27 | | writer.WriteNumberValue(RuleSequence.Value); |
| | 28 | | } |
| 0 | 29 | | if (Conditions != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("conditions"); |
| 0 | 32 | | writer.WriteStartArray(); |
| 0 | 33 | | foreach (var item in Conditions) |
| | 34 | | { |
| 0 | 35 | | writer.WriteObjectValue(item); |
| | 36 | | } |
| 0 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 0 | 39 | | if (ActionSet != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("actionSet"); |
| 0 | 42 | | writer.WriteObjectValue(ActionSet); |
| | 43 | | } |
| 0 | 44 | | writer.WriteEndObject(); |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | internal static ApplicationGatewayRewriteRule DeserializeApplicationGatewayRewriteRule(JsonElement element) |
| | 48 | | { |
| 0 | 49 | | string name = default; |
| 0 | 50 | | int? ruleSequence = default; |
| 0 | 51 | | IList<ApplicationGatewayRewriteRuleCondition> conditions = default; |
| 0 | 52 | | ApplicationGatewayRewriteRuleActionSet actionSet = 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("ruleSequence")) |
| | 65 | | { |
| 0 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | ruleSequence = property.Value.GetInt32(); |
| 0 | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | if (property.NameEquals("conditions")) |
| | 74 | | { |
| 0 | 75 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | List<ApplicationGatewayRewriteRuleCondition> array = new List<ApplicationGatewayRewriteRuleCondition |
| 0 | 80 | | foreach (var item in property.Value.EnumerateArray()) |
| | 81 | | { |
| 0 | 82 | | if (item.ValueKind == JsonValueKind.Null) |
| | 83 | | { |
| 0 | 84 | | array.Add(null); |
| | 85 | | } |
| | 86 | | else |
| | 87 | | { |
| 0 | 88 | | array.Add(ApplicationGatewayRewriteRuleCondition.DeserializeApplicationGatewayRewriteRuleCon |
| | 89 | | } |
| | 90 | | } |
| 0 | 91 | | conditions = array; |
| 0 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | if (property.NameEquals("actionSet")) |
| | 95 | | { |
| 0 | 96 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| | 98 | | continue; |
| | 99 | | } |
| 0 | 100 | | actionSet = ApplicationGatewayRewriteRuleActionSet.DeserializeApplicationGatewayRewriteRuleActionSet |
| | 101 | | continue; |
| | 102 | | } |
| | 103 | | } |
| 0 | 104 | | return new ApplicationGatewayRewriteRule(name, ruleSequence, conditions, actionSet); |
| | 105 | | } |
| | 106 | | } |
| | 107 | | } |