| | 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 ApplicationGatewayWebApplicationFirewallConfiguration : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | writer.WritePropertyName("enabled"); |
| 0 | 20 | | writer.WriteBooleanValue(Enabled); |
| 0 | 21 | | writer.WritePropertyName("firewallMode"); |
| 0 | 22 | | writer.WriteStringValue(FirewallMode.ToString()); |
| 0 | 23 | | writer.WritePropertyName("ruleSetType"); |
| 0 | 24 | | writer.WriteStringValue(RuleSetType); |
| 0 | 25 | | writer.WritePropertyName("ruleSetVersion"); |
| 0 | 26 | | writer.WriteStringValue(RuleSetVersion); |
| 0 | 27 | | if (DisabledRuleGroups != null) |
| | 28 | | { |
| 0 | 29 | | writer.WritePropertyName("disabledRuleGroups"); |
| 0 | 30 | | writer.WriteStartArray(); |
| 0 | 31 | | foreach (var item in DisabledRuleGroups) |
| | 32 | | { |
| 0 | 33 | | writer.WriteObjectValue(item); |
| | 34 | | } |
| 0 | 35 | | writer.WriteEndArray(); |
| | 36 | | } |
| 0 | 37 | | if (RequestBodyCheck != null) |
| | 38 | | { |
| 0 | 39 | | writer.WritePropertyName("requestBodyCheck"); |
| 0 | 40 | | writer.WriteBooleanValue(RequestBodyCheck.Value); |
| | 41 | | } |
| 0 | 42 | | if (MaxRequestBodySize != null) |
| | 43 | | { |
| 0 | 44 | | writer.WritePropertyName("maxRequestBodySize"); |
| 0 | 45 | | writer.WriteNumberValue(MaxRequestBodySize.Value); |
| | 46 | | } |
| 0 | 47 | | if (MaxRequestBodySizeInKb != null) |
| | 48 | | { |
| 0 | 49 | | writer.WritePropertyName("maxRequestBodySizeInKb"); |
| 0 | 50 | | writer.WriteNumberValue(MaxRequestBodySizeInKb.Value); |
| | 51 | | } |
| 0 | 52 | | if (FileUploadLimitInMb != null) |
| | 53 | | { |
| 0 | 54 | | writer.WritePropertyName("fileUploadLimitInMb"); |
| 0 | 55 | | writer.WriteNumberValue(FileUploadLimitInMb.Value); |
| | 56 | | } |
| 0 | 57 | | if (Exclusions != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("exclusions"); |
| 0 | 60 | | writer.WriteStartArray(); |
| 0 | 61 | | foreach (var item in Exclusions) |
| | 62 | | { |
| 0 | 63 | | writer.WriteObjectValue(item); |
| | 64 | | } |
| 0 | 65 | | writer.WriteEndArray(); |
| | 66 | | } |
| 0 | 67 | | writer.WriteEndObject(); |
| 0 | 68 | | } |
| | 69 | |
|
| | 70 | | internal static ApplicationGatewayWebApplicationFirewallConfiguration DeserializeApplicationGatewayWebApplicatio |
| | 71 | | { |
| 0 | 72 | | bool enabled = default; |
| 0 | 73 | | ApplicationGatewayFirewallMode firewallMode = default; |
| 0 | 74 | | string ruleSetType = default; |
| 0 | 75 | | string ruleSetVersion = default; |
| 0 | 76 | | IList<ApplicationGatewayFirewallDisabledRuleGroup> disabledRuleGroups = default; |
| 0 | 77 | | bool? requestBodyCheck = default; |
| 0 | 78 | | int? maxRequestBodySize = default; |
| 0 | 79 | | int? maxRequestBodySizeInKb = default; |
| 0 | 80 | | int? fileUploadLimitInMb = default; |
| 0 | 81 | | IList<ApplicationGatewayFirewallExclusion> exclusions = default; |
| 0 | 82 | | foreach (var property in element.EnumerateObject()) |
| | 83 | | { |
| 0 | 84 | | if (property.NameEquals("enabled")) |
| | 85 | | { |
| 0 | 86 | | enabled = property.Value.GetBoolean(); |
| 0 | 87 | | continue; |
| | 88 | | } |
| 0 | 89 | | if (property.NameEquals("firewallMode")) |
| | 90 | | { |
| 0 | 91 | | firewallMode = new ApplicationGatewayFirewallMode(property.Value.GetString()); |
| 0 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | if (property.NameEquals("ruleSetType")) |
| | 95 | | { |
| 0 | 96 | | ruleSetType = property.Value.GetString(); |
| 0 | 97 | | continue; |
| | 98 | | } |
| 0 | 99 | | if (property.NameEquals("ruleSetVersion")) |
| | 100 | | { |
| 0 | 101 | | ruleSetVersion = property.Value.GetString(); |
| 0 | 102 | | continue; |
| | 103 | | } |
| 0 | 104 | | if (property.NameEquals("disabledRuleGroups")) |
| | 105 | | { |
| 0 | 106 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| | 108 | | continue; |
| | 109 | | } |
| 0 | 110 | | List<ApplicationGatewayFirewallDisabledRuleGroup> array = new List<ApplicationGatewayFirewallDisable |
| 0 | 111 | | foreach (var item in property.Value.EnumerateArray()) |
| | 112 | | { |
| 0 | 113 | | if (item.ValueKind == JsonValueKind.Null) |
| | 114 | | { |
| 0 | 115 | | array.Add(null); |
| | 116 | | } |
| | 117 | | else |
| | 118 | | { |
| 0 | 119 | | array.Add(ApplicationGatewayFirewallDisabledRuleGroup.DeserializeApplicationGatewayFirewallD |
| | 120 | | } |
| | 121 | | } |
| 0 | 122 | | disabledRuleGroups = array; |
| 0 | 123 | | continue; |
| | 124 | | } |
| 0 | 125 | | if (property.NameEquals("requestBodyCheck")) |
| | 126 | | { |
| 0 | 127 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | requestBodyCheck = property.Value.GetBoolean(); |
| 0 | 132 | | continue; |
| | 133 | | } |
| 0 | 134 | | if (property.NameEquals("maxRequestBodySize")) |
| | 135 | | { |
| 0 | 136 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 137 | | { |
| | 138 | | continue; |
| | 139 | | } |
| 0 | 140 | | maxRequestBodySize = property.Value.GetInt32(); |
| 0 | 141 | | continue; |
| | 142 | | } |
| 0 | 143 | | if (property.NameEquals("maxRequestBodySizeInKb")) |
| | 144 | | { |
| 0 | 145 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | maxRequestBodySizeInKb = property.Value.GetInt32(); |
| 0 | 150 | | continue; |
| | 151 | | } |
| 0 | 152 | | if (property.NameEquals("fileUploadLimitInMb")) |
| | 153 | | { |
| 0 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 0 | 158 | | fileUploadLimitInMb = property.Value.GetInt32(); |
| 0 | 159 | | continue; |
| | 160 | | } |
| 0 | 161 | | if (property.NameEquals("exclusions")) |
| | 162 | | { |
| 0 | 163 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 0 | 167 | | List<ApplicationGatewayFirewallExclusion> array = new List<ApplicationGatewayFirewallExclusion>(); |
| 0 | 168 | | foreach (var item in property.Value.EnumerateArray()) |
| | 169 | | { |
| 0 | 170 | | if (item.ValueKind == JsonValueKind.Null) |
| | 171 | | { |
| 0 | 172 | | array.Add(null); |
| | 173 | | } |
| | 174 | | else |
| | 175 | | { |
| 0 | 176 | | array.Add(ApplicationGatewayFirewallExclusion.DeserializeApplicationGatewayFirewallExclusion |
| | 177 | | } |
| | 178 | | } |
| 0 | 179 | | exclusions = array; |
| | 180 | | continue; |
| | 181 | | } |
| | 182 | | } |
| 0 | 183 | | return new ApplicationGatewayWebApplicationFirewallConfiguration(enabled, firewallMode, ruleSetType, ruleSet |
| | 184 | | } |
| | 185 | | } |
| | 186 | | } |