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