| | 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 ManagementPolicy : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 4 | 18 | | writer.WriteStartObject(); |
| 4 | 19 | | if (Id != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("id"); |
| 0 | 22 | | writer.WriteStringValue(Id); |
| | 23 | | } |
| 4 | 24 | | if (Name != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("name"); |
| 0 | 27 | | writer.WriteStringValue(Name); |
| | 28 | | } |
| 4 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 4 | 34 | | writer.WritePropertyName("properties"); |
| 4 | 35 | | writer.WriteStartObject(); |
| 4 | 36 | | if (LastModifiedTime != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("lastModifiedTime"); |
| 0 | 39 | | writer.WriteStringValue(LastModifiedTime.Value, "O"); |
| | 40 | | } |
| 4 | 41 | | if (Policy != null) |
| | 42 | | { |
| 4 | 43 | | writer.WritePropertyName("policy"); |
| 4 | 44 | | writer.WriteObjectValue(Policy); |
| | 45 | | } |
| 4 | 46 | | writer.WriteEndObject(); |
| 4 | 47 | | writer.WriteEndObject(); |
| 4 | 48 | | } |
| | 49 | |
|
| | 50 | | internal static ManagementPolicy DeserializeManagementPolicy(JsonElement element) |
| | 51 | | { |
| 8 | 52 | | string id = default; |
| 8 | 53 | | string name = default; |
| 8 | 54 | | string type = default; |
| 8 | 55 | | DateTimeOffset? lastModifiedTime = default; |
| 8 | 56 | | ManagementPolicySchema policy = default; |
| 80 | 57 | | foreach (var property in element.EnumerateObject()) |
| | 58 | | { |
| 32 | 59 | | if (property.NameEquals("id")) |
| | 60 | | { |
| 8 | 61 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 62 | | { |
| | 63 | | continue; |
| | 64 | | } |
| 8 | 65 | | id = property.Value.GetString(); |
| 8 | 66 | | continue; |
| | 67 | | } |
| 24 | 68 | | if (property.NameEquals("name")) |
| | 69 | | { |
| 8 | 70 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 71 | | { |
| | 72 | | continue; |
| | 73 | | } |
| 8 | 74 | | name = property.Value.GetString(); |
| 8 | 75 | | continue; |
| | 76 | | } |
| 16 | 77 | | if (property.NameEquals("type")) |
| | 78 | | { |
| 8 | 79 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 80 | | { |
| | 81 | | continue; |
| | 82 | | } |
| 8 | 83 | | type = property.Value.GetString(); |
| 8 | 84 | | continue; |
| | 85 | | } |
| 8 | 86 | | if (property.NameEquals("properties")) |
| | 87 | | { |
| 48 | 88 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 89 | | { |
| 16 | 90 | | if (property0.NameEquals("lastModifiedTime")) |
| | 91 | | { |
| 8 | 92 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 93 | | { |
| | 94 | | continue; |
| | 95 | | } |
| 8 | 96 | | lastModifiedTime = property0.Value.GetDateTimeOffset("O"); |
| 8 | 97 | | continue; |
| | 98 | | } |
| 8 | 99 | | if (property0.NameEquals("policy")) |
| | 100 | | { |
| 8 | 101 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 102 | | { |
| | 103 | | continue; |
| | 104 | | } |
| 8 | 105 | | policy = ManagementPolicySchema.DeserializeManagementPolicySchema(property0.Value); |
| | 106 | | continue; |
| | 107 | | } |
| | 108 | | } |
| | 109 | | continue; |
| | 110 | | } |
| | 111 | | } |
| 8 | 112 | | return new ManagementPolicy(id, name, type, lastModifiedTime, policy); |
| | 113 | | } |
| | 114 | | } |
| | 115 | | } |