| | 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.Compute.Models |
| | 12 | | { |
| | 13 | | public partial class TargetRegion : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 16 | 17 | | writer.WriteStartObject(); |
| 16 | 18 | | writer.WritePropertyName("name"); |
| 16 | 19 | | writer.WriteStringValue(Name); |
| 16 | 20 | | if (RegionalReplicaCount != null) |
| | 21 | | { |
| 16 | 22 | | writer.WritePropertyName("regionalReplicaCount"); |
| 16 | 23 | | writer.WriteNumberValue(RegionalReplicaCount.Value); |
| | 24 | | } |
| 16 | 25 | | if (StorageAccountType != null) |
| | 26 | | { |
| 16 | 27 | | writer.WritePropertyName("storageAccountType"); |
| 16 | 28 | | writer.WriteStringValue(StorageAccountType.Value.ToString()); |
| | 29 | | } |
| 16 | 30 | | if (Encryption != null) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("encryption"); |
| 0 | 33 | | writer.WriteObjectValue(Encryption); |
| | 34 | | } |
| 16 | 35 | | writer.WriteEndObject(); |
| 16 | 36 | | } |
| | 37 | |
|
| | 38 | | internal static TargetRegion DeserializeTargetRegion(JsonElement element) |
| | 39 | | { |
| 24 | 40 | | string name = default; |
| 24 | 41 | | int? regionalReplicaCount = default; |
| 24 | 42 | | StorageAccountType? storageAccountType = default; |
| 24 | 43 | | EncryptionImages encryption = default; |
| 192 | 44 | | foreach (var property in element.EnumerateObject()) |
| | 45 | | { |
| 72 | 46 | | if (property.NameEquals("name")) |
| | 47 | | { |
| 24 | 48 | | name = property.Value.GetString(); |
| 24 | 49 | | continue; |
| | 50 | | } |
| 48 | 51 | | if (property.NameEquals("regionalReplicaCount")) |
| | 52 | | { |
| 24 | 53 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 54 | | { |
| | 55 | | continue; |
| | 56 | | } |
| 24 | 57 | | regionalReplicaCount = property.Value.GetInt32(); |
| 24 | 58 | | continue; |
| | 59 | | } |
| 24 | 60 | | if (property.NameEquals("storageAccountType")) |
| | 61 | | { |
| 24 | 62 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 63 | | { |
| | 64 | | continue; |
| | 65 | | } |
| 24 | 66 | | storageAccountType = new StorageAccountType(property.Value.GetString()); |
| 24 | 67 | | continue; |
| | 68 | | } |
| 0 | 69 | | if (property.NameEquals("encryption")) |
| | 70 | | { |
| 0 | 71 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| | 73 | | continue; |
| | 74 | | } |
| 0 | 75 | | encryption = EncryptionImages.DeserializeEncryptionImages(property.Value); |
| | 76 | | continue; |
| | 77 | | } |
| | 78 | | } |
| 24 | 79 | | return new TargetRegion(name, regionalReplicaCount, storageAccountType, encryption); |
| | 80 | | } |
| | 81 | | } |
| | 82 | | } |