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