| | 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.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Compute.Models |
| | 13 | | { |
| | 14 | | public partial class ReplicationStatus : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (AggregatedState != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("aggregatedState"); |
| 0 | 22 | | writer.WriteStringValue(AggregatedState.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (Summary != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("summary"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in Summary) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 0 | 34 | | writer.WriteEndObject(); |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | internal static ReplicationStatus DeserializeReplicationStatus(JsonElement element) |
| | 38 | | { |
| 12 | 39 | | AggregatedReplicationState? aggregatedState = default; |
| 12 | 40 | | IList<RegionalReplicationStatus> summary = default; |
| 72 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 24 | 43 | | if (property.NameEquals("aggregatedState")) |
| | 44 | | { |
| 12 | 45 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 46 | | { |
| | 47 | | continue; |
| | 48 | | } |
| 12 | 49 | | aggregatedState = new AggregatedReplicationState(property.Value.GetString()); |
| 12 | 50 | | continue; |
| | 51 | | } |
| 12 | 52 | | if (property.NameEquals("summary")) |
| | 53 | | { |
| 12 | 54 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 55 | | { |
| | 56 | | continue; |
| | 57 | | } |
| 12 | 58 | | List<RegionalReplicationStatus> array = new List<RegionalReplicationStatus>(); |
| 48 | 59 | | foreach (var item in property.Value.EnumerateArray()) |
| | 60 | | { |
| 12 | 61 | | if (item.ValueKind == JsonValueKind.Null) |
| | 62 | | { |
| 0 | 63 | | array.Add(null); |
| | 64 | | } |
| | 65 | | else |
| | 66 | | { |
| 12 | 67 | | array.Add(RegionalReplicationStatus.DeserializeRegionalReplicationStatus(item)); |
| | 68 | | } |
| | 69 | | } |
| 12 | 70 | | summary = array; |
| | 71 | | continue; |
| | 72 | | } |
| | 73 | | } |
| 12 | 74 | | return new ReplicationStatus(aggregatedState, summary); |
| | 75 | | } |
| | 76 | | } |
| | 77 | | } |