| | 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 GeoReplicationStats : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Status != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("status"); |
| 0 | 22 | | writer.WriteStringValue(Status.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (LastSyncTime != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("lastSyncTime"); |
| 0 | 27 | | writer.WriteStringValue(LastSyncTime.Value, "O"); |
| | 28 | | } |
| 0 | 29 | | if (CanFailover != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("canFailover"); |
| 0 | 32 | | writer.WriteBooleanValue(CanFailover.Value); |
| | 33 | | } |
| 0 | 34 | | writer.WriteEndObject(); |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | internal static GeoReplicationStats DeserializeGeoReplicationStats(JsonElement element) |
| | 38 | | { |
| 4 | 39 | | GeoReplicationStatus? status = default; |
| 4 | 40 | | DateTimeOffset? lastSyncTime = default; |
| 4 | 41 | | bool? canFailover = default; |
| 32 | 42 | | foreach (var property in element.EnumerateObject()) |
| | 43 | | { |
| 12 | 44 | | if (property.NameEquals("status")) |
| | 45 | | { |
| 4 | 46 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 47 | | { |
| | 48 | | continue; |
| | 49 | | } |
| 4 | 50 | | status = new GeoReplicationStatus(property.Value.GetString()); |
| 4 | 51 | | continue; |
| | 52 | | } |
| 8 | 53 | | if (property.NameEquals("lastSyncTime")) |
| | 54 | | { |
| 4 | 55 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 56 | | { |
| | 57 | | continue; |
| | 58 | | } |
| 4 | 59 | | lastSyncTime = property.Value.GetDateTimeOffset("O"); |
| 4 | 60 | | continue; |
| | 61 | | } |
| 4 | 62 | | if (property.NameEquals("canFailover")) |
| | 63 | | { |
| 4 | 64 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| | 66 | | continue; |
| | 67 | | } |
| 4 | 68 | | canFailover = property.Value.GetBoolean(); |
| | 69 | | continue; |
| | 70 | | } |
| | 71 | | } |
| 4 | 72 | | return new GeoReplicationStats(status, lastSyncTime, canFailover); |
| | 73 | | } |
| | 74 | | } |
| | 75 | | } |