| | 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.Resources.Models |
| | 13 | | { |
| | 14 | | public partial class GenericResource : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 112 | 18 | | writer.WriteStartObject(); |
| 112 | 19 | | if (Plan != null) |
| | 20 | | { |
| 8 | 21 | | writer.WritePropertyName("plan"); |
| 8 | 22 | | writer.WriteObjectValue(Plan); |
| | 23 | | } |
| 112 | 24 | | if (Properties != null) |
| | 25 | | { |
| 112 | 26 | | writer.WritePropertyName("properties"); |
| 112 | 27 | | writer.WriteObjectValue(Properties); |
| | 28 | | } |
| 112 | 29 | | if (Kind != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("kind"); |
| 0 | 32 | | writer.WriteStringValue(Kind); |
| | 33 | | } |
| 112 | 34 | | if (ManagedBy != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("managedBy"); |
| 0 | 37 | | writer.WriteStringValue(ManagedBy); |
| | 38 | | } |
| 112 | 39 | | if (Sku != null) |
| | 40 | | { |
| 72 | 41 | | writer.WritePropertyName("sku"); |
| 72 | 42 | | writer.WriteObjectValue(Sku); |
| | 43 | | } |
| 112 | 44 | | if (Identity != null) |
| | 45 | | { |
| 8 | 46 | | writer.WritePropertyName("identity"); |
| 8 | 47 | | writer.WriteObjectValue(Identity); |
| | 48 | | } |
| 112 | 49 | | if (Id != null) |
| | 50 | | { |
| 0 | 51 | | writer.WritePropertyName("id"); |
| 0 | 52 | | writer.WriteStringValue(Id); |
| | 53 | | } |
| 112 | 54 | | if (Name != null) |
| | 55 | | { |
| 0 | 56 | | writer.WritePropertyName("name"); |
| 0 | 57 | | writer.WriteStringValue(Name); |
| | 58 | | } |
| 112 | 59 | | if (Type != null) |
| | 60 | | { |
| 0 | 61 | | writer.WritePropertyName("type"); |
| 0 | 62 | | writer.WriteStringValue(Type); |
| | 63 | | } |
| 112 | 64 | | if (Location != null) |
| | 65 | | { |
| 112 | 66 | | writer.WritePropertyName("location"); |
| 112 | 67 | | writer.WriteStringValue(Location); |
| | 68 | | } |
| 112 | 69 | | if (Tags != null) |
| | 70 | | { |
| 48 | 71 | | writer.WritePropertyName("tags"); |
| 48 | 72 | | writer.WriteStartObject(); |
| 240 | 73 | | foreach (var item in Tags) |
| | 74 | | { |
| 72 | 75 | | writer.WritePropertyName(item.Key); |
| 72 | 76 | | writer.WriteStringValue(item.Value); |
| | 77 | | } |
| 48 | 78 | | writer.WriteEndObject(); |
| | 79 | | } |
| 112 | 80 | | writer.WriteEndObject(); |
| 112 | 81 | | } |
| | 82 | |
|
| | 83 | | internal static GenericResource DeserializeGenericResource(JsonElement element) |
| | 84 | | { |
| 52 | 85 | | Plan plan = default; |
| 52 | 86 | | object properties = default; |
| 52 | 87 | | string kind = default; |
| 52 | 88 | | string managedBy = default; |
| 52 | 89 | | Sku sku = default; |
| 52 | 90 | | Identity identity = default; |
| 52 | 91 | | string id = default; |
| 52 | 92 | | string name = default; |
| 52 | 93 | | string type = default; |
| 52 | 94 | | string location = default; |
| 52 | 95 | | IDictionary<string, string> tags = default; |
| 664 | 96 | | foreach (var property in element.EnumerateObject()) |
| | 97 | | { |
| 280 | 98 | | if (property.NameEquals("plan")) |
| | 99 | | { |
| 8 | 100 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| | 102 | | continue; |
| | 103 | | } |
| 8 | 104 | | plan = Plan.DeserializePlan(property.Value); |
| 8 | 105 | | continue; |
| | 106 | | } |
| 272 | 107 | | if (property.NameEquals("properties")) |
| | 108 | | { |
| 52 | 109 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 110 | | { |
| | 111 | | continue; |
| | 112 | | } |
| 52 | 113 | | properties = property.Value.GetObject(); |
| 52 | 114 | | continue; |
| | 115 | | } |
| 220 | 116 | | if (property.NameEquals("kind")) |
| | 117 | | { |
| 16 | 118 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 119 | | { |
| | 120 | | continue; |
| | 121 | | } |
| 16 | 122 | | kind = property.Value.GetString(); |
| 16 | 123 | | continue; |
| | 124 | | } |
| 204 | 125 | | if (property.NameEquals("managedBy")) |
| | 126 | | { |
| 0 | 127 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | managedBy = property.Value.GetString(); |
| 0 | 132 | | continue; |
| | 133 | | } |
| 204 | 134 | | if (property.NameEquals("sku")) |
| | 135 | | { |
| 24 | 136 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 137 | | { |
| | 138 | | continue; |
| | 139 | | } |
| 24 | 140 | | sku = Sku.DeserializeSku(property.Value); |
| 24 | 141 | | continue; |
| | 142 | | } |
| 180 | 143 | | if (property.NameEquals("identity")) |
| | 144 | | { |
| 4 | 145 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 4 | 149 | | identity = Identity.DeserializeIdentity(property.Value); |
| 4 | 150 | | continue; |
| | 151 | | } |
| 176 | 152 | | if (property.NameEquals("id")) |
| | 153 | | { |
| 32 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 32 | 158 | | id = property.Value.GetString(); |
| 32 | 159 | | continue; |
| | 160 | | } |
| 144 | 161 | | if (property.NameEquals("name")) |
| | 162 | | { |
| 32 | 163 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 32 | 167 | | name = property.Value.GetString(); |
| 32 | 168 | | continue; |
| | 169 | | } |
| 112 | 170 | | if (property.NameEquals("type")) |
| | 171 | | { |
| 20 | 172 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 20 | 176 | | type = property.Value.GetString(); |
| 20 | 177 | | continue; |
| | 178 | | } |
| 92 | 179 | | if (property.NameEquals("location")) |
| | 180 | | { |
| 52 | 181 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| | 183 | | continue; |
| | 184 | | } |
| 52 | 185 | | location = property.Value.GetString(); |
| 52 | 186 | | continue; |
| | 187 | | } |
| 40 | 188 | | if (property.NameEquals("tags")) |
| | 189 | | { |
| 32 | 190 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 191 | | { |
| | 192 | | continue; |
| | 193 | | } |
| 24 | 194 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 112 | 195 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 196 | | { |
| 32 | 197 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 198 | | { |
| 0 | 199 | | dictionary.Add(property0.Name, null); |
| | 200 | | } |
| | 201 | | else |
| | 202 | | { |
| 32 | 203 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 204 | | } |
| | 205 | | } |
| 24 | 206 | | tags = dictionary; |
| | 207 | | continue; |
| | 208 | | } |
| | 209 | | } |
| 52 | 210 | | return new GenericResource(id, name, type, location, tags, plan, properties, kind, managedBy, sku, identity) |
| | 211 | | } |
| | 212 | | } |
| | 213 | | } |