| | 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; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Text.Json; |
| | 11 | | using Azure.Core; |
| | 12 | |
|
| | 13 | | namespace Azure.ResourceManager.DigitalTwins.Models |
| | 14 | | { |
| | 15 | | public partial class DigitalTwinsDescription : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 8 | 19 | | writer.WriteStartObject(); |
| 8 | 20 | | writer.WritePropertyName("location"); |
| 8 | 21 | | writer.WriteStringValue(Location); |
| 8 | 22 | | if (Optional.IsCollectionDefined(Tags)) |
| | 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 | | } |
| | 35 | | else |
| | 36 | | { |
| 0 | 37 | | writer.WriteNull("tags"); |
| | 38 | | } |
| | 39 | | } |
| 8 | 40 | | if (Optional.IsDefined(Sku)) |
| | 41 | | { |
| 0 | 42 | | writer.WritePropertyName("sku"); |
| 0 | 43 | | writer.WriteObjectValue(Sku); |
| | 44 | | } |
| 8 | 45 | | writer.WritePropertyName("properties"); |
| 8 | 46 | | writer.WriteStartObject(); |
| 8 | 47 | | writer.WriteEndObject(); |
| 8 | 48 | | writer.WriteEndObject(); |
| 8 | 49 | | } |
| | 50 | |
|
| | 51 | | internal static DigitalTwinsDescription DeserializeDigitalTwinsDescription(JsonElement element) |
| | 52 | | { |
| 42 | 53 | | Optional<string> id = default; |
| 42 | 54 | | Optional<string> name = default; |
| 42 | 55 | | Optional<string> type = default; |
| 42 | 56 | | string location = default; |
| 42 | 57 | | Optional<IDictionary<string, string>> tags = default; |
| 42 | 58 | | Optional<DigitalTwinsSkuInfo> sku = default; |
| 42 | 59 | | Optional<DateTimeOffset> createdTime = default; |
| 42 | 60 | | Optional<DateTimeOffset> lastUpdatedTime = default; |
| 42 | 61 | | Optional<ProvisioningState> provisioningState = default; |
| 42 | 62 | | Optional<string> hostName = default; |
| 588 | 63 | | foreach (var property in element.EnumerateObject()) |
| | 64 | | { |
| 252 | 65 | | if (property.NameEquals("id")) |
| | 66 | | { |
| 42 | 67 | | id = property.Value.GetString(); |
| 42 | 68 | | continue; |
| | 69 | | } |
| 210 | 70 | | if (property.NameEquals("name")) |
| | 71 | | { |
| 42 | 72 | | name = property.Value.GetString(); |
| 42 | 73 | | continue; |
| | 74 | | } |
| 168 | 75 | | if (property.NameEquals("type")) |
| | 76 | | { |
| 42 | 77 | | type = property.Value.GetString(); |
| 42 | 78 | | continue; |
| | 79 | | } |
| 126 | 80 | | if (property.NameEquals("location")) |
| | 81 | | { |
| 42 | 82 | | location = property.Value.GetString(); |
| 42 | 83 | | continue; |
| | 84 | | } |
| 84 | 85 | | if (property.NameEquals("tags")) |
| | 86 | | { |
| 42 | 87 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 88 | | { |
| 42 | 89 | | tags = null; |
| 42 | 90 | | continue; |
| | 91 | | } |
| 0 | 92 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 93 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 94 | | { |
| 0 | 95 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 96 | | } |
| 0 | 97 | | tags = dictionary; |
| 0 | 98 | | continue; |
| | 99 | | } |
| 42 | 100 | | if (property.NameEquals("sku")) |
| | 101 | | { |
| 0 | 102 | | sku = DigitalTwinsSkuInfo.DeserializeDigitalTwinsSkuInfo(property.Value); |
| 0 | 103 | | continue; |
| | 104 | | } |
| 42 | 105 | | if (property.NameEquals("properties")) |
| | 106 | | { |
| 420 | 107 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 108 | | { |
| 168 | 109 | | if (property0.NameEquals("createdTime")) |
| | 110 | | { |
| 42 | 111 | | createdTime = property0.Value.GetDateTimeOffset("O"); |
| 42 | 112 | | continue; |
| | 113 | | } |
| 126 | 114 | | if (property0.NameEquals("lastUpdatedTime")) |
| | 115 | | { |
| 42 | 116 | | lastUpdatedTime = property0.Value.GetDateTimeOffset("O"); |
| 42 | 117 | | continue; |
| | 118 | | } |
| 84 | 119 | | if (property0.NameEquals("provisioningState")) |
| | 120 | | { |
| 42 | 121 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 42 | 122 | | continue; |
| | 123 | | } |
| 42 | 124 | | if (property0.NameEquals("hostName")) |
| | 125 | | { |
| 42 | 126 | | hostName = property0.Value.GetString(); |
| | 127 | | continue; |
| | 128 | | } |
| | 129 | | } |
| | 130 | | continue; |
| | 131 | | } |
| | 132 | | } |
| 42 | 133 | | return new DigitalTwinsDescription(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), |
| | 134 | | } |
| | 135 | | } |
| | 136 | | } |