| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.EventHubs.Models |
| | 12 | | { |
| | 13 | | public partial class Sku : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 56 | 17 | | writer.WriteStartObject(); |
| 56 | 18 | | writer.WritePropertyName("name"); |
| 56 | 19 | | writer.WriteStringValue(Name.ToString()); |
| 56 | 20 | | if (Tier != null) |
| | 21 | | { |
| 56 | 22 | | writer.WritePropertyName("tier"); |
| 56 | 23 | | writer.WriteStringValue(Tier.Value.ToString()); |
| | 24 | | } |
| 56 | 25 | | if (Capacity != null) |
| | 26 | | { |
| 24 | 27 | | writer.WritePropertyName("capacity"); |
| 24 | 28 | | writer.WriteNumberValue(Capacity.Value); |
| | 29 | | } |
| 56 | 30 | | writer.WriteEndObject(); |
| 56 | 31 | | } |
| | 32 | |
|
| | 33 | | internal static Sku DeserializeSku(JsonElement element) |
| | 34 | | { |
| 144 | 35 | | SkuName name = default; |
| 144 | 36 | | SkuTier? tier = default; |
| 144 | 37 | | int? capacity = default; |
| 1152 | 38 | | foreach (var property in element.EnumerateObject()) |
| | 39 | | { |
| 432 | 40 | | if (property.NameEquals("name")) |
| | 41 | | { |
| 144 | 42 | | name = new SkuName(property.Value.GetString()); |
| 144 | 43 | | continue; |
| | 44 | | } |
| 288 | 45 | | if (property.NameEquals("tier")) |
| | 46 | | { |
| 144 | 47 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 48 | | { |
| | 49 | | continue; |
| | 50 | | } |
| 144 | 51 | | tier = new SkuTier(property.Value.GetString()); |
| 144 | 52 | | continue; |
| | 53 | | } |
| 144 | 54 | | if (property.NameEquals("capacity")) |
| | 55 | | { |
| 144 | 56 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 57 | | { |
| | 58 | | continue; |
| | 59 | | } |
| 144 | 60 | | capacity = property.Value.GetInt32(); |
| | 61 | | continue; |
| | 62 | | } |
| | 63 | | } |
| 144 | 64 | | return new Sku(name, tier, capacity); |
| | 65 | | } |
| | 66 | | } |
| | 67 | | } |