| | 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; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Storage.Models |
| | 13 | | { |
| | 14 | | public partial class RestorePolicyProperties : 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 | | if (Days != null) |
| | 22 | | { |
| 0 | 23 | | writer.WritePropertyName("days"); |
| 0 | 24 | | writer.WriteNumberValue(Days.Value); |
| | 25 | | } |
| 0 | 26 | | if (LastEnabledTime != null) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName("lastEnabledTime"); |
| 0 | 29 | | writer.WriteStringValue(LastEnabledTime.Value, "O"); |
| | 30 | | } |
| 0 | 31 | | writer.WriteEndObject(); |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | internal static RestorePolicyProperties DeserializeRestorePolicyProperties(JsonElement element) |
| | 35 | | { |
| 0 | 36 | | bool enabled = default; |
| 0 | 37 | | int? days = default; |
| 0 | 38 | | DateTimeOffset? lastEnabledTime = default; |
| 0 | 39 | | foreach (var property in element.EnumerateObject()) |
| | 40 | | { |
| 0 | 41 | | if (property.NameEquals("enabled")) |
| | 42 | | { |
| 0 | 43 | | enabled = property.Value.GetBoolean(); |
| 0 | 44 | | continue; |
| | 45 | | } |
| 0 | 46 | | if (property.NameEquals("days")) |
| | 47 | | { |
| 0 | 48 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 49 | | { |
| | 50 | | continue; |
| | 51 | | } |
| 0 | 52 | | days = property.Value.GetInt32(); |
| 0 | 53 | | continue; |
| | 54 | | } |
| 0 | 55 | | if (property.NameEquals("lastEnabledTime")) |
| | 56 | | { |
| 0 | 57 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 58 | | { |
| | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | lastEnabledTime = property.Value.GetDateTimeOffset("O"); |
| | 62 | | continue; |
| | 63 | | } |
| | 64 | | } |
| 0 | 65 | | return new RestorePolicyProperties(enabled, days, lastEnabledTime); |
| | 66 | | } |
| | 67 | | } |
| | 68 | | } |