| | 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 ProtocolCustomSettingsFormat : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Protocol != null) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("protocol"); |
| 0 | 21 | | writer.WriteStringValue(Protocol.Value.ToString()); |
| | 22 | | } |
| 0 | 23 | | if (TriggerRateOverride != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("triggerRateOverride"); |
| 0 | 26 | | writer.WriteStringValue(TriggerRateOverride); |
| | 27 | | } |
| 0 | 28 | | if (SourceRateOverride != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("sourceRateOverride"); |
| 0 | 31 | | writer.WriteStringValue(SourceRateOverride); |
| | 32 | | } |
| 0 | 33 | | if (TriggerSensitivityOverride != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("triggerSensitivityOverride"); |
| 0 | 36 | | writer.WriteStringValue(TriggerSensitivityOverride.Value.ToString()); |
| | 37 | | } |
| 0 | 38 | | writer.WriteEndObject(); |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | internal static ProtocolCustomSettingsFormat DeserializeProtocolCustomSettingsFormat(JsonElement element) |
| | 42 | | { |
| 0 | 43 | | DdosCustomPolicyProtocol? protocol = default; |
| 0 | 44 | | string triggerRateOverride = default; |
| 0 | 45 | | string sourceRateOverride = default; |
| 0 | 46 | | DdosCustomPolicyTriggerSensitivityOverride? triggerSensitivityOverride = default; |
| 0 | 47 | | foreach (var property in element.EnumerateObject()) |
| | 48 | | { |
| 0 | 49 | | if (property.NameEquals("protocol")) |
| | 50 | | { |
| 0 | 51 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 52 | | { |
| | 53 | | continue; |
| | 54 | | } |
| 0 | 55 | | protocol = new DdosCustomPolicyProtocol(property.Value.GetString()); |
| 0 | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | if (property.NameEquals("triggerRateOverride")) |
| | 59 | | { |
| 0 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | triggerRateOverride = property.Value.GetString(); |
| 0 | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | if (property.NameEquals("sourceRateOverride")) |
| | 68 | | { |
| 0 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | sourceRateOverride = property.Value.GetString(); |
| 0 | 74 | | continue; |
| | 75 | | } |
| 0 | 76 | | if (property.NameEquals("triggerSensitivityOverride")) |
| | 77 | | { |
| 0 | 78 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | triggerSensitivityOverride = new DdosCustomPolicyTriggerSensitivityOverride(property.Value.GetString |
| | 83 | | continue; |
| | 84 | | } |
| | 85 | | } |
| 0 | 86 | | return new ProtocolCustomSettingsFormat(protocol, triggerRateOverride, sourceRateOverride, triggerSensitivit |
| | 87 | | } |
| | 88 | | } |
| | 89 | | } |