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