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