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