| | 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.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.ResourceManager.Compute.Models |
| | 14 | | { |
| | 15 | | public partial class GalleryImageVersionPublishingProfile : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 16 | 19 | | writer.WriteStartObject(); |
| 16 | 20 | | if (TargetRegions != null) |
| | 21 | | { |
| 16 | 22 | | writer.WritePropertyName("targetRegions"); |
| 16 | 23 | | writer.WriteStartArray(); |
| 64 | 24 | | foreach (var item in TargetRegions) |
| | 25 | | { |
| 16 | 26 | | writer.WriteObjectValue(item); |
| | 27 | | } |
| 16 | 28 | | writer.WriteEndArray(); |
| | 29 | | } |
| 16 | 30 | | if (ReplicaCount != null) |
| | 31 | | { |
| 16 | 32 | | writer.WritePropertyName("replicaCount"); |
| 16 | 33 | | writer.WriteNumberValue(ReplicaCount.Value); |
| | 34 | | } |
| 16 | 35 | | if (ExcludeFromLatest != null) |
| | 36 | | { |
| 0 | 37 | | writer.WritePropertyName("excludeFromLatest"); |
| 0 | 38 | | writer.WriteBooleanValue(ExcludeFromLatest.Value); |
| | 39 | | } |
| 16 | 40 | | if (PublishedDate != null) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("publishedDate"); |
| 0 | 43 | | writer.WriteStringValue(PublishedDate.Value, "O"); |
| | 44 | | } |
| 16 | 45 | | if (EndOfLifeDate != null) |
| | 46 | | { |
| 16 | 47 | | writer.WritePropertyName("endOfLifeDate"); |
| 16 | 48 | | writer.WriteStringValue(EndOfLifeDate.Value, "O"); |
| | 49 | | } |
| 16 | 50 | | if (StorageAccountType != null) |
| | 51 | | { |
| 16 | 52 | | writer.WritePropertyName("storageAccountType"); |
| 16 | 53 | | writer.WriteStringValue(StorageAccountType.Value.ToString()); |
| | 54 | | } |
| 16 | 55 | | writer.WriteEndObject(); |
| 16 | 56 | | } |
| | 57 | |
|
| | 58 | | internal static GalleryImageVersionPublishingProfile DeserializeGalleryImageVersionPublishingProfile(JsonElement |
| | 59 | | { |
| 0 | 60 | | IList<TargetRegion> targetRegions = default; |
| 0 | 61 | | int? replicaCount = default; |
| 0 | 62 | | bool? excludeFromLatest = default; |
| 0 | 63 | | DateTimeOffset? publishedDate = default; |
| 0 | 64 | | DateTimeOffset? endOfLifeDate = default; |
| 0 | 65 | | StorageAccountType? storageAccountType = default; |
| 0 | 66 | | foreach (var property in element.EnumerateObject()) |
| | 67 | | { |
| 0 | 68 | | if (property.NameEquals("targetRegions")) |
| | 69 | | { |
| 0 | 70 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 71 | | { |
| | 72 | | continue; |
| | 73 | | } |
| 0 | 74 | | List<TargetRegion> array = new List<TargetRegion>(); |
| 0 | 75 | | foreach (var item in property.Value.EnumerateArray()) |
| | 76 | | { |
| 0 | 77 | | if (item.ValueKind == JsonValueKind.Null) |
| | 78 | | { |
| 0 | 79 | | array.Add(null); |
| | 80 | | } |
| | 81 | | else |
| | 82 | | { |
| 0 | 83 | | array.Add(TargetRegion.DeserializeTargetRegion(item)); |
| | 84 | | } |
| | 85 | | } |
| 0 | 86 | | targetRegions = array; |
| 0 | 87 | | continue; |
| | 88 | | } |
| 0 | 89 | | if (property.NameEquals("replicaCount")) |
| | 90 | | { |
| 0 | 91 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 92 | | { |
| | 93 | | continue; |
| | 94 | | } |
| 0 | 95 | | replicaCount = property.Value.GetInt32(); |
| 0 | 96 | | continue; |
| | 97 | | } |
| 0 | 98 | | if (property.NameEquals("excludeFromLatest")) |
| | 99 | | { |
| 0 | 100 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| | 102 | | continue; |
| | 103 | | } |
| 0 | 104 | | excludeFromLatest = property.Value.GetBoolean(); |
| 0 | 105 | | continue; |
| | 106 | | } |
| 0 | 107 | | if (property.NameEquals("publishedDate")) |
| | 108 | | { |
| 0 | 109 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 110 | | { |
| | 111 | | continue; |
| | 112 | | } |
| 0 | 113 | | publishedDate = property.Value.GetDateTimeOffset("O"); |
| 0 | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | if (property.NameEquals("endOfLifeDate")) |
| | 117 | | { |
| 0 | 118 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 119 | | { |
| | 120 | | continue; |
| | 121 | | } |
| 0 | 122 | | endOfLifeDate = property.Value.GetDateTimeOffset("O"); |
| 0 | 123 | | continue; |
| | 124 | | } |
| 0 | 125 | | if (property.NameEquals("storageAccountType")) |
| | 126 | | { |
| 0 | 127 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | storageAccountType = new StorageAccountType(property.Value.GetString()); |
| | 132 | | continue; |
| | 133 | | } |
| | 134 | | } |
| 0 | 135 | | return new GalleryImageVersionPublishingProfile(targetRegions, replicaCount, excludeFromLatest, publishedDat |
| | 136 | | } |
| | 137 | | } |
| | 138 | | } |