| | | 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.EventHubs.Models |
| | | 12 | | { |
| | | 13 | | public partial class CaptureDescription : IUtf8JsonSerializable |
| | | 14 | | { |
| | | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | | 16 | | { |
| | 8 | 17 | | writer.WriteStartObject(); |
| | 8 | 18 | | if (Enabled != null) |
| | | 19 | | { |
| | 8 | 20 | | writer.WritePropertyName("enabled"); |
| | 8 | 21 | | writer.WriteBooleanValue(Enabled.Value); |
| | | 22 | | } |
| | 8 | 23 | | if (Encoding != null) |
| | | 24 | | { |
| | 8 | 25 | | writer.WritePropertyName("encoding"); |
| | 8 | 26 | | writer.WriteStringValue(Encoding.Value.ToSerialString()); |
| | | 27 | | } |
| | 8 | 28 | | if (IntervalInSeconds != null) |
| | | 29 | | { |
| | 8 | 30 | | writer.WritePropertyName("intervalInSeconds"); |
| | 8 | 31 | | writer.WriteNumberValue(IntervalInSeconds.Value); |
| | | 32 | | } |
| | 8 | 33 | | if (SizeLimitInBytes != null) |
| | | 34 | | { |
| | 8 | 35 | | writer.WritePropertyName("sizeLimitInBytes"); |
| | 8 | 36 | | writer.WriteNumberValue(SizeLimitInBytes.Value); |
| | | 37 | | } |
| | 8 | 38 | | if (Destination != null) |
| | | 39 | | { |
| | 8 | 40 | | writer.WritePropertyName("destination"); |
| | 8 | 41 | | writer.WriteObjectValue(Destination); |
| | | 42 | | } |
| | 8 | 43 | | if (SkipEmptyArchives != null) |
| | | 44 | | { |
| | 8 | 45 | | writer.WritePropertyName("skipEmptyArchives"); |
| | 8 | 46 | | writer.WriteBooleanValue(SkipEmptyArchives.Value); |
| | | 47 | | } |
| | 8 | 48 | | writer.WriteEndObject(); |
| | 8 | 49 | | } |
| | | 50 | | |
| | | 51 | | internal static CaptureDescription DeserializeCaptureDescription(JsonElement element) |
| | | 52 | | { |
| | 20 | 53 | | bool? enabled = default; |
| | 20 | 54 | | EncodingCaptureDescription? encoding = default; |
| | 20 | 55 | | int? intervalInSeconds = default; |
| | 20 | 56 | | int? sizeLimitInBytes = default; |
| | 20 | 57 | | Destination destination = default; |
| | 20 | 58 | | bool? skipEmptyArchives = default; |
| | 280 | 59 | | foreach (var property in element.EnumerateObject()) |
| | | 60 | | { |
| | 120 | 61 | | if (property.NameEquals("enabled")) |
| | | 62 | | { |
| | 20 | 63 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 64 | | { |
| | | 65 | | continue; |
| | | 66 | | } |
| | 20 | 67 | | enabled = property.Value.GetBoolean(); |
| | 20 | 68 | | continue; |
| | | 69 | | } |
| | 100 | 70 | | if (property.NameEquals("encoding")) |
| | | 71 | | { |
| | 20 | 72 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 73 | | { |
| | | 74 | | continue; |
| | | 75 | | } |
| | 20 | 76 | | encoding = property.Value.GetString().ToEncodingCaptureDescription(); |
| | 20 | 77 | | continue; |
| | | 78 | | } |
| | 80 | 79 | | if (property.NameEquals("intervalInSeconds")) |
| | | 80 | | { |
| | 20 | 81 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 82 | | { |
| | | 83 | | continue; |
| | | 84 | | } |
| | 20 | 85 | | intervalInSeconds = property.Value.GetInt32(); |
| | 20 | 86 | | continue; |
| | | 87 | | } |
| | 60 | 88 | | if (property.NameEquals("sizeLimitInBytes")) |
| | | 89 | | { |
| | 20 | 90 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 91 | | { |
| | | 92 | | continue; |
| | | 93 | | } |
| | 20 | 94 | | sizeLimitInBytes = property.Value.GetInt32(); |
| | 20 | 95 | | continue; |
| | | 96 | | } |
| | 40 | 97 | | if (property.NameEquals("destination")) |
| | | 98 | | { |
| | 20 | 99 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 100 | | { |
| | | 101 | | continue; |
| | | 102 | | } |
| | 20 | 103 | | destination = Destination.DeserializeDestination(property.Value); |
| | 20 | 104 | | continue; |
| | | 105 | | } |
| | 20 | 106 | | if (property.NameEquals("skipEmptyArchives")) |
| | | 107 | | { |
| | 20 | 108 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 109 | | { |
| | | 110 | | continue; |
| | | 111 | | } |
| | 20 | 112 | | skipEmptyArchives = property.Value.GetBoolean(); |
| | | 113 | | continue; |
| | | 114 | | } |
| | | 115 | | } |
| | 20 | 116 | | return new CaptureDescription(enabled, encoding, intervalInSeconds, sizeLimitInBytes, destination, skipEmpty |
| | | 117 | | } |
| | | 118 | | } |
| | | 119 | | } |