| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Network.Models |
| | 12 | | { |
| | 13 | | public partial class PolicySettings : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (State != null) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("state"); |
| 0 | 21 | | writer.WriteStringValue(State.Value.ToString()); |
| | 22 | | } |
| 0 | 23 | | if (Mode != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("mode"); |
| 0 | 26 | | writer.WriteStringValue(Mode.Value.ToString()); |
| | 27 | | } |
| 0 | 28 | | if (RequestBodyCheck != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("requestBodyCheck"); |
| 0 | 31 | | writer.WriteBooleanValue(RequestBodyCheck.Value); |
| | 32 | | } |
| 0 | 33 | | if (MaxRequestBodySizeInKb != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("maxRequestBodySizeInKb"); |
| 0 | 36 | | writer.WriteNumberValue(MaxRequestBodySizeInKb.Value); |
| | 37 | | } |
| 0 | 38 | | if (FileUploadLimitInMb != null) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("fileUploadLimitInMb"); |
| 0 | 41 | | writer.WriteNumberValue(FileUploadLimitInMb.Value); |
| | 42 | | } |
| 0 | 43 | | writer.WriteEndObject(); |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal static PolicySettings DeserializePolicySettings(JsonElement element) |
| | 47 | | { |
| 0 | 48 | | WebApplicationFirewallEnabledState? state = default; |
| 0 | 49 | | WebApplicationFirewallMode? mode = default; |
| 0 | 50 | | bool? requestBodyCheck = default; |
| 0 | 51 | | int? maxRequestBodySizeInKb = default; |
| 0 | 52 | | int? fileUploadLimitInMb = default; |
| 0 | 53 | | foreach (var property in element.EnumerateObject()) |
| | 54 | | { |
| 0 | 55 | | if (property.NameEquals("state")) |
| | 56 | | { |
| 0 | 57 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 58 | | { |
| | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | state = new WebApplicationFirewallEnabledState(property.Value.GetString()); |
| 0 | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | if (property.NameEquals("mode")) |
| | 65 | | { |
| 0 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | mode = new WebApplicationFirewallMode(property.Value.GetString()); |
| 0 | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | if (property.NameEquals("requestBodyCheck")) |
| | 74 | | { |
| 0 | 75 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | requestBodyCheck = property.Value.GetBoolean(); |
| 0 | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | if (property.NameEquals("maxRequestBodySizeInKb")) |
| | 83 | | { |
| 0 | 84 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 85 | | { |
| | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | maxRequestBodySizeInKb = property.Value.GetInt32(); |
| 0 | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | if (property.NameEquals("fileUploadLimitInMb")) |
| | 92 | | { |
| 0 | 93 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 94 | | { |
| | 95 | | continue; |
| | 96 | | } |
| 0 | 97 | | fileUploadLimitInMb = property.Value.GetInt32(); |
| | 98 | | continue; |
| | 99 | | } |
| | 100 | | } |
| 0 | 101 | | return new PolicySettings(state, mode, requestBodyCheck, maxRequestBodySizeInKb, fileUploadLimitInMb); |
| | 102 | | } |
| | 103 | | } |
| | 104 | | } |