| | 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 WebApplicationFirewallPolicy : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Etag != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("etag"); |
| 0 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 0 | 24 | | if (Id != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("id"); |
| 0 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 0 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 0 | 34 | | if (Type != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("type"); |
| 0 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 0 | 39 | | if (Location != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("location"); |
| 0 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 0 | 44 | | if (Tags != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("tags"); |
| 0 | 47 | | writer.WriteStartObject(); |
| 0 | 48 | | foreach (var item in Tags) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName(item.Key); |
| 0 | 51 | | writer.WriteStringValue(item.Value); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndObject(); |
| | 54 | | } |
| 0 | 55 | | writer.WritePropertyName("properties"); |
| 0 | 56 | | writer.WriteStartObject(); |
| 0 | 57 | | if (PolicySettings != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("policySettings"); |
| 0 | 60 | | writer.WriteObjectValue(PolicySettings); |
| | 61 | | } |
| 0 | 62 | | if (CustomRules != null) |
| | 63 | | { |
| 0 | 64 | | writer.WritePropertyName("customRules"); |
| 0 | 65 | | writer.WriteStartArray(); |
| 0 | 66 | | foreach (var item in CustomRules) |
| | 67 | | { |
| 0 | 68 | | writer.WriteObjectValue(item); |
| | 69 | | } |
| 0 | 70 | | writer.WriteEndArray(); |
| | 71 | | } |
| 0 | 72 | | if (ApplicationGateways != null) |
| | 73 | | { |
| 0 | 74 | | writer.WritePropertyName("applicationGateways"); |
| 0 | 75 | | writer.WriteStartArray(); |
| 0 | 76 | | foreach (var item in ApplicationGateways) |
| | 77 | | { |
| 0 | 78 | | writer.WriteObjectValue(item); |
| | 79 | | } |
| 0 | 80 | | writer.WriteEndArray(); |
| | 81 | | } |
| 0 | 82 | | if (ProvisioningState != null) |
| | 83 | | { |
| 0 | 84 | | writer.WritePropertyName("provisioningState"); |
| 0 | 85 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 86 | | } |
| 0 | 87 | | if (ResourceState != null) |
| | 88 | | { |
| 0 | 89 | | writer.WritePropertyName("resourceState"); |
| 0 | 90 | | writer.WriteStringValue(ResourceState.Value.ToString()); |
| | 91 | | } |
| 0 | 92 | | if (ManagedRules != null) |
| | 93 | | { |
| 0 | 94 | | writer.WritePropertyName("managedRules"); |
| 0 | 95 | | writer.WriteObjectValue(ManagedRules); |
| | 96 | | } |
| 0 | 97 | | if (HttpListeners != null) |
| | 98 | | { |
| 0 | 99 | | writer.WritePropertyName("httpListeners"); |
| 0 | 100 | | writer.WriteStartArray(); |
| 0 | 101 | | foreach (var item in HttpListeners) |
| | 102 | | { |
| 0 | 103 | | writer.WriteObjectValue(item); |
| | 104 | | } |
| 0 | 105 | | writer.WriteEndArray(); |
| | 106 | | } |
| 0 | 107 | | if (PathBasedRules != null) |
| | 108 | | { |
| 0 | 109 | | writer.WritePropertyName("pathBasedRules"); |
| 0 | 110 | | writer.WriteStartArray(); |
| 0 | 111 | | foreach (var item in PathBasedRules) |
| | 112 | | { |
| 0 | 113 | | writer.WriteObjectValue(item); |
| | 114 | | } |
| 0 | 115 | | writer.WriteEndArray(); |
| | 116 | | } |
| 0 | 117 | | writer.WriteEndObject(); |
| 0 | 118 | | writer.WriteEndObject(); |
| 0 | 119 | | } |
| | 120 | |
|
| | 121 | | internal static WebApplicationFirewallPolicy DeserializeWebApplicationFirewallPolicy(JsonElement element) |
| | 122 | | { |
| 0 | 123 | | string etag = default; |
| 0 | 124 | | string id = default; |
| 0 | 125 | | string name = default; |
| 0 | 126 | | string type = default; |
| 0 | 127 | | string location = default; |
| 0 | 128 | | IDictionary<string, string> tags = default; |
| 0 | 129 | | PolicySettings policySettings = default; |
| 0 | 130 | | IList<WebApplicationFirewallCustomRule> customRules = default; |
| 0 | 131 | | IList<ApplicationGateway> applicationGateways = default; |
| 0 | 132 | | ProvisioningState? provisioningState = default; |
| 0 | 133 | | WebApplicationFirewallPolicyResourceState? resourceState = default; |
| 0 | 134 | | ManagedRulesDefinition managedRules = default; |
| 0 | 135 | | IList<SubResource> httpListeners = default; |
| 0 | 136 | | IList<SubResource> pathBasedRules = default; |
| 0 | 137 | | foreach (var property in element.EnumerateObject()) |
| | 138 | | { |
| 0 | 139 | | if (property.NameEquals("etag")) |
| | 140 | | { |
| 0 | 141 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 142 | | { |
| | 143 | | continue; |
| | 144 | | } |
| 0 | 145 | | etag = property.Value.GetString(); |
| 0 | 146 | | continue; |
| | 147 | | } |
| 0 | 148 | | if (property.NameEquals("id")) |
| | 149 | | { |
| 0 | 150 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 151 | | { |
| | 152 | | continue; |
| | 153 | | } |
| 0 | 154 | | id = property.Value.GetString(); |
| 0 | 155 | | continue; |
| | 156 | | } |
| 0 | 157 | | if (property.NameEquals("name")) |
| | 158 | | { |
| 0 | 159 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 160 | | { |
| | 161 | | continue; |
| | 162 | | } |
| 0 | 163 | | name = property.Value.GetString(); |
| 0 | 164 | | continue; |
| | 165 | | } |
| 0 | 166 | | if (property.NameEquals("type")) |
| | 167 | | { |
| 0 | 168 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 169 | | { |
| | 170 | | continue; |
| | 171 | | } |
| 0 | 172 | | type = property.Value.GetString(); |
| 0 | 173 | | continue; |
| | 174 | | } |
| 0 | 175 | | if (property.NameEquals("location")) |
| | 176 | | { |
| 0 | 177 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 178 | | { |
| | 179 | | continue; |
| | 180 | | } |
| 0 | 181 | | location = property.Value.GetString(); |
| 0 | 182 | | continue; |
| | 183 | | } |
| 0 | 184 | | if (property.NameEquals("tags")) |
| | 185 | | { |
| 0 | 186 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 187 | | { |
| | 188 | | continue; |
| | 189 | | } |
| 0 | 190 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 191 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 192 | | { |
| 0 | 193 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 194 | | { |
| 0 | 195 | | dictionary.Add(property0.Name, null); |
| | 196 | | } |
| | 197 | | else |
| | 198 | | { |
| 0 | 199 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 200 | | } |
| | 201 | | } |
| 0 | 202 | | tags = dictionary; |
| 0 | 203 | | continue; |
| | 204 | | } |
| 0 | 205 | | if (property.NameEquals("properties")) |
| | 206 | | { |
| 0 | 207 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 208 | | { |
| 0 | 209 | | if (property0.NameEquals("policySettings")) |
| | 210 | | { |
| 0 | 211 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 212 | | { |
| | 213 | | continue; |
| | 214 | | } |
| 0 | 215 | | policySettings = PolicySettings.DeserializePolicySettings(property0.Value); |
| 0 | 216 | | continue; |
| | 217 | | } |
| 0 | 218 | | if (property0.NameEquals("customRules")) |
| | 219 | | { |
| 0 | 220 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 221 | | { |
| | 222 | | continue; |
| | 223 | | } |
| 0 | 224 | | List<WebApplicationFirewallCustomRule> array = new List<WebApplicationFirewallCustomRule>(); |
| 0 | 225 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 226 | | { |
| 0 | 227 | | if (item.ValueKind == JsonValueKind.Null) |
| | 228 | | { |
| 0 | 229 | | array.Add(null); |
| | 230 | | } |
| | 231 | | else |
| | 232 | | { |
| 0 | 233 | | array.Add(WebApplicationFirewallCustomRule.DeserializeWebApplicationFirewallCustomRu |
| | 234 | | } |
| | 235 | | } |
| 0 | 236 | | customRules = array; |
| 0 | 237 | | continue; |
| | 238 | | } |
| 0 | 239 | | if (property0.NameEquals("applicationGateways")) |
| | 240 | | { |
| 0 | 241 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 242 | | { |
| | 243 | | continue; |
| | 244 | | } |
| 0 | 245 | | List<ApplicationGateway> array = new List<ApplicationGateway>(); |
| 0 | 246 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 247 | | { |
| 0 | 248 | | if (item.ValueKind == JsonValueKind.Null) |
| | 249 | | { |
| 0 | 250 | | array.Add(null); |
| | 251 | | } |
| | 252 | | else |
| | 253 | | { |
| 0 | 254 | | array.Add(ApplicationGateway.DeserializeApplicationGateway(item)); |
| | 255 | | } |
| | 256 | | } |
| 0 | 257 | | applicationGateways = array; |
| 0 | 258 | | continue; |
| | 259 | | } |
| 0 | 260 | | if (property0.NameEquals("provisioningState")) |
| | 261 | | { |
| 0 | 262 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 263 | | { |
| | 264 | | continue; |
| | 265 | | } |
| 0 | 266 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 0 | 267 | | continue; |
| | 268 | | } |
| 0 | 269 | | if (property0.NameEquals("resourceState")) |
| | 270 | | { |
| 0 | 271 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 272 | | { |
| | 273 | | continue; |
| | 274 | | } |
| 0 | 275 | | resourceState = new WebApplicationFirewallPolicyResourceState(property0.Value.GetString()); |
| 0 | 276 | | continue; |
| | 277 | | } |
| 0 | 278 | | if (property0.NameEquals("managedRules")) |
| | 279 | | { |
| 0 | 280 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 281 | | { |
| | 282 | | continue; |
| | 283 | | } |
| 0 | 284 | | managedRules = ManagedRulesDefinition.DeserializeManagedRulesDefinition(property0.Value); |
| 0 | 285 | | continue; |
| | 286 | | } |
| 0 | 287 | | if (property0.NameEquals("httpListeners")) |
| | 288 | | { |
| 0 | 289 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 290 | | { |
| | 291 | | continue; |
| | 292 | | } |
| 0 | 293 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 294 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 295 | | { |
| 0 | 296 | | if (item.ValueKind == JsonValueKind.Null) |
| | 297 | | { |
| 0 | 298 | | array.Add(null); |
| | 299 | | } |
| | 300 | | else |
| | 301 | | { |
| 0 | 302 | | array.Add(SubResource.DeserializeSubResource(item)); |
| | 303 | | } |
| | 304 | | } |
| 0 | 305 | | httpListeners = array; |
| 0 | 306 | | continue; |
| | 307 | | } |
| 0 | 308 | | if (property0.NameEquals("pathBasedRules")) |
| | 309 | | { |
| 0 | 310 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 311 | | { |
| | 312 | | continue; |
| | 313 | | } |
| 0 | 314 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 315 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 316 | | { |
| 0 | 317 | | if (item.ValueKind == JsonValueKind.Null) |
| | 318 | | { |
| 0 | 319 | | array.Add(null); |
| | 320 | | } |
| | 321 | | else |
| | 322 | | { |
| 0 | 323 | | array.Add(SubResource.DeserializeSubResource(item)); |
| | 324 | | } |
| | 325 | | } |
| 0 | 326 | | pathBasedRules = array; |
| | 327 | | continue; |
| | 328 | | } |
| | 329 | | } |
| | 330 | | continue; |
| | 331 | | } |
| | 332 | | } |
| 0 | 333 | | return new WebApplicationFirewallPolicy(id, name, type, location, tags, etag, policySettings, customRules, a |
| | 334 | | } |
| | 335 | | } |
| | 336 | | } |