| | 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 UpdateHistoryProperty : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Update != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("update"); |
| 0 | 22 | | writer.WriteStringValue(Update.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (ImmutabilityPeriodSinceCreationInDays != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("immutabilityPeriodSinceCreationInDays"); |
| 0 | 27 | | writer.WriteNumberValue(ImmutabilityPeriodSinceCreationInDays.Value); |
| | 28 | | } |
| 0 | 29 | | if (Timestamp != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("timestamp"); |
| 0 | 32 | | writer.WriteStringValue(Timestamp.Value, "O"); |
| | 33 | | } |
| 0 | 34 | | if (ObjectIdentifier != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("objectIdentifier"); |
| 0 | 37 | | writer.WriteStringValue(ObjectIdentifier); |
| | 38 | | } |
| 0 | 39 | | if (TenantId != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("tenantId"); |
| 0 | 42 | | writer.WriteStringValue(TenantId); |
| | 43 | | } |
| 0 | 44 | | if (Upn != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("upn"); |
| 0 | 47 | | writer.WriteStringValue(Upn); |
| | 48 | | } |
| 0 | 49 | | writer.WriteEndObject(); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | internal static UpdateHistoryProperty DeserializeUpdateHistoryProperty(JsonElement element) |
| | 53 | | { |
| 12 | 54 | | ImmutabilityPolicyUpdateType? update = default; |
| 12 | 55 | | int? immutabilityPeriodSinceCreationInDays = default; |
| 12 | 56 | | DateTimeOffset? timestamp = default; |
| 12 | 57 | | string objectIdentifier = default; |
| 12 | 58 | | string tenantId = default; |
| 12 | 59 | | string upn = default; |
| 144 | 60 | | foreach (var property in element.EnumerateObject()) |
| | 61 | | { |
| 60 | 62 | | if (property.NameEquals("update")) |
| | 63 | | { |
| 12 | 64 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| | 66 | | continue; |
| | 67 | | } |
| 12 | 68 | | update = new ImmutabilityPolicyUpdateType(property.Value.GetString()); |
| 12 | 69 | | continue; |
| | 70 | | } |
| 48 | 71 | | if (property.NameEquals("immutabilityPeriodSinceCreationInDays")) |
| | 72 | | { |
| 12 | 73 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 74 | | { |
| | 75 | | continue; |
| | 76 | | } |
| 12 | 77 | | immutabilityPeriodSinceCreationInDays = property.Value.GetInt32(); |
| 12 | 78 | | continue; |
| | 79 | | } |
| 36 | 80 | | if (property.NameEquals("timestamp")) |
| | 81 | | { |
| 12 | 82 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 83 | | { |
| | 84 | | continue; |
| | 85 | | } |
| 12 | 86 | | timestamp = property.Value.GetDateTimeOffset("O"); |
| 12 | 87 | | continue; |
| | 88 | | } |
| 24 | 89 | | if (property.NameEquals("objectIdentifier")) |
| | 90 | | { |
| 12 | 91 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 92 | | { |
| | 93 | | continue; |
| | 94 | | } |
| 12 | 95 | | objectIdentifier = property.Value.GetString(); |
| 12 | 96 | | continue; |
| | 97 | | } |
| 12 | 98 | | if (property.NameEquals("tenantId")) |
| | 99 | | { |
| 12 | 100 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| | 102 | | continue; |
| | 103 | | } |
| 12 | 104 | | tenantId = property.Value.GetString(); |
| 12 | 105 | | continue; |
| | 106 | | } |
| 0 | 107 | | if (property.NameEquals("upn")) |
| | 108 | | { |
| 0 | 109 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 110 | | { |
| | 111 | | continue; |
| | 112 | | } |
| 0 | 113 | | upn = property.Value.GetString(); |
| | 114 | | continue; |
| | 115 | | } |
| | 116 | | } |
| 12 | 117 | | return new UpdateHistoryProperty(update, immutabilityPeriodSinceCreationInDays, timestamp, objectIdentifier, |
| | 118 | | } |
| | 119 | | } |
| | 120 | | } |