| | 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.Storage.Models |
| | 13 | | { |
| | 14 | | public partial class ImmutabilityPolicyProperties : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Etag != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("etag"); |
| 0 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 0 | 24 | | if (UpdateHistory != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("updateHistory"); |
| 0 | 27 | | writer.WriteStartArray(); |
| 0 | 28 | | foreach (var item in UpdateHistory) |
| | 29 | | { |
| 0 | 30 | | writer.WriteObjectValue(item); |
| | 31 | | } |
| 0 | 32 | | writer.WriteEndArray(); |
| | 33 | | } |
| 0 | 34 | | writer.WritePropertyName("properties"); |
| 0 | 35 | | writer.WriteStartObject(); |
| 0 | 36 | | if (ImmutabilityPeriodSinceCreationInDays != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("immutabilityPeriodSinceCreationInDays"); |
| 0 | 39 | | writer.WriteNumberValue(ImmutabilityPeriodSinceCreationInDays.Value); |
| | 40 | | } |
| 0 | 41 | | if (State != null) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("state"); |
| 0 | 44 | | writer.WriteStringValue(State.Value.ToString()); |
| | 45 | | } |
| 0 | 46 | | if (AllowProtectedAppendWrites != null) |
| | 47 | | { |
| 0 | 48 | | writer.WritePropertyName("allowProtectedAppendWrites"); |
| 0 | 49 | | writer.WriteBooleanValue(AllowProtectedAppendWrites.Value); |
| | 50 | | } |
| 0 | 51 | | writer.WriteEndObject(); |
| 0 | 52 | | writer.WriteEndObject(); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | internal static ImmutabilityPolicyProperties DeserializeImmutabilityPolicyProperties(JsonElement element) |
| | 56 | | { |
| 4 | 57 | | string etag = default; |
| 4 | 58 | | IList<UpdateHistoryProperty> updateHistory = default; |
| 4 | 59 | | int? immutabilityPeriodSinceCreationInDays = default; |
| 4 | 60 | | ImmutabilityPolicyState? state = default; |
| 4 | 61 | | bool? allowProtectedAppendWrites = default; |
| 32 | 62 | | foreach (var property in element.EnumerateObject()) |
| | 63 | | { |
| 12 | 64 | | if (property.NameEquals("etag")) |
| | 65 | | { |
| 4 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| | 68 | | continue; |
| | 69 | | } |
| 4 | 70 | | etag = property.Value.GetString(); |
| 4 | 71 | | continue; |
| | 72 | | } |
| 8 | 73 | | if (property.NameEquals("updateHistory")) |
| | 74 | | { |
| 4 | 75 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| | 77 | | continue; |
| | 78 | | } |
| 4 | 79 | | List<UpdateHistoryProperty> array = new List<UpdateHistoryProperty>(); |
| 32 | 80 | | foreach (var item in property.Value.EnumerateArray()) |
| | 81 | | { |
| 12 | 82 | | if (item.ValueKind == JsonValueKind.Null) |
| | 83 | | { |
| 0 | 84 | | array.Add(null); |
| | 85 | | } |
| | 86 | | else |
| | 87 | | { |
| 12 | 88 | | array.Add(UpdateHistoryProperty.DeserializeUpdateHistoryProperty(item)); |
| | 89 | | } |
| | 90 | | } |
| 4 | 91 | | updateHistory = array; |
| 4 | 92 | | continue; |
| | 93 | | } |
| 4 | 94 | | if (property.NameEquals("properties")) |
| | 95 | | { |
| 24 | 96 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 97 | | { |
| 8 | 98 | | if (property0.NameEquals("immutabilityPeriodSinceCreationInDays")) |
| | 99 | | { |
| 4 | 100 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| | 102 | | continue; |
| | 103 | | } |
| 4 | 104 | | immutabilityPeriodSinceCreationInDays = property0.Value.GetInt32(); |
| 4 | 105 | | continue; |
| | 106 | | } |
| 4 | 107 | | if (property0.NameEquals("state")) |
| | 108 | | { |
| 4 | 109 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 110 | | { |
| | 111 | | continue; |
| | 112 | | } |
| 4 | 113 | | state = new ImmutabilityPolicyState(property0.Value.GetString()); |
| 4 | 114 | | continue; |
| | 115 | | } |
| 0 | 116 | | if (property0.NameEquals("allowProtectedAppendWrites")) |
| | 117 | | { |
| 0 | 118 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 119 | | { |
| | 120 | | continue; |
| | 121 | | } |
| 0 | 122 | | allowProtectedAppendWrites = property0.Value.GetBoolean(); |
| | 123 | | continue; |
| | 124 | | } |
| | 125 | | } |
| | 126 | | continue; |
| | 127 | | } |
| | 128 | | } |
| 4 | 129 | | return new ImmutabilityPolicyProperties(etag, updateHistory, immutabilityPeriodSinceCreationInDays, state, a |
| | 130 | | } |
| | 131 | | } |
| | 132 | | } |