| | 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.Network.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 | | if (Location != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("location"); |
| 0 | 37 | | writer.WriteStringValue(Location); |
| | 38 | | } |
| 0 | 39 | | if (Tags != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("tags"); |
| 0 | 42 | | writer.WriteStartObject(); |
| 0 | 43 | | foreach (var item in Tags) |
| | 44 | | { |
| 0 | 45 | | writer.WritePropertyName(item.Key); |
| 0 | 46 | | writer.WriteStringValue(item.Value); |
| | 47 | | } |
| 0 | 48 | | writer.WriteEndObject(); |
| | 49 | | } |
| 0 | 50 | | writer.WriteEndObject(); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | internal static Resource DeserializeResource(JsonElement element) |
| | 54 | | { |
| 0 | 55 | | string id = default; |
| 0 | 56 | | string name = default; |
| 0 | 57 | | string type = default; |
| 0 | 58 | | string location = default; |
| 0 | 59 | | IDictionary<string, string> tags = default; |
| 0 | 60 | | foreach (var property in element.EnumerateObject()) |
| | 61 | | { |
| 0 | 62 | | if (property.NameEquals("id")) |
| | 63 | | { |
| 0 | 64 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 65 | | { |
| | 66 | | continue; |
| | 67 | | } |
| 0 | 68 | | id = property.Value.GetString(); |
| 0 | 69 | | continue; |
| | 70 | | } |
| 0 | 71 | | if (property.NameEquals("name")) |
| | 72 | | { |
| 0 | 73 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 74 | | { |
| | 75 | | continue; |
| | 76 | | } |
| 0 | 77 | | name = property.Value.GetString(); |
| 0 | 78 | | continue; |
| | 79 | | } |
| 0 | 80 | | if (property.NameEquals("type")) |
| | 81 | | { |
| 0 | 82 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 83 | | { |
| | 84 | | continue; |
| | 85 | | } |
| 0 | 86 | | type = property.Value.GetString(); |
| 0 | 87 | | continue; |
| | 88 | | } |
| 0 | 89 | | if (property.NameEquals("location")) |
| | 90 | | { |
| 0 | 91 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 92 | | { |
| | 93 | | continue; |
| | 94 | | } |
| 0 | 95 | | location = property.Value.GetString(); |
| 0 | 96 | | continue; |
| | 97 | | } |
| 0 | 98 | | if (property.NameEquals("tags")) |
| | 99 | | { |
| 0 | 100 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| | 102 | | continue; |
| | 103 | | } |
| 0 | 104 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 105 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 106 | | { |
| 0 | 107 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 108 | | { |
| 0 | 109 | | dictionary.Add(property0.Name, null); |
| | 110 | | } |
| | 111 | | else |
| | 112 | | { |
| 0 | 113 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 114 | | } |
| | 115 | | } |
| 0 | 116 | | tags = dictionary; |
| | 117 | | continue; |
| | 118 | | } |
| | 119 | | } |
| 0 | 120 | | return new Resource(id, name, type, location, tags); |
| | 121 | | } |
| | 122 | | } |
| | 123 | | } |