| | 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.Iot.Hub.Service.Models |
| | 14 | | { |
| | 15 | | public partial class TwinConfiguration : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 0 | 19 | | writer.WriteStartObject(); |
| 0 | 20 | | if (Optional.IsDefined(Id)) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("id"); |
| 0 | 23 | | writer.WriteStringValue(Id); |
| | 24 | | } |
| 0 | 25 | | if (Optional.IsDefined(SchemaVersion)) |
| | 26 | | { |
| 0 | 27 | | writer.WritePropertyName("schemaVersion"); |
| 0 | 28 | | writer.WriteStringValue(SchemaVersion); |
| | 29 | | } |
| 0 | 30 | | if (Optional.IsCollectionDefined(Labels)) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName("labels"); |
| 0 | 33 | | writer.WriteStartObject(); |
| 0 | 34 | | foreach (var item in Labels) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName(item.Key); |
| 0 | 37 | | writer.WriteStringValue(item.Value); |
| | 38 | | } |
| 0 | 39 | | writer.WriteEndObject(); |
| | 40 | | } |
| 0 | 41 | | if (Optional.IsDefined(Content)) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("content"); |
| 0 | 44 | | writer.WriteObjectValue(Content); |
| | 45 | | } |
| 0 | 46 | | if (Optional.IsDefined(TargetCondition)) |
| | 47 | | { |
| 0 | 48 | | writer.WritePropertyName("targetCondition"); |
| 0 | 49 | | writer.WriteStringValue(TargetCondition); |
| | 50 | | } |
| 0 | 51 | | if (Optional.IsDefined(CreatedTimeUtc)) |
| | 52 | | { |
| 0 | 53 | | writer.WritePropertyName("createdTimeUtc"); |
| 0 | 54 | | writer.WriteStringValue(CreatedTimeUtc.Value, "O"); |
| | 55 | | } |
| 0 | 56 | | if (Optional.IsDefined(LastUpdatedTimeUtc)) |
| | 57 | | { |
| 0 | 58 | | writer.WritePropertyName("lastUpdatedTimeUtc"); |
| 0 | 59 | | writer.WriteStringValue(LastUpdatedTimeUtc.Value, "O"); |
| | 60 | | } |
| 0 | 61 | | if (Optional.IsDefined(Priority)) |
| | 62 | | { |
| 0 | 63 | | writer.WritePropertyName("priority"); |
| 0 | 64 | | writer.WriteNumberValue(Priority.Value); |
| | 65 | | } |
| 0 | 66 | | if (Optional.IsDefined(SystemMetrics)) |
| | 67 | | { |
| 0 | 68 | | writer.WritePropertyName("systemMetrics"); |
| 0 | 69 | | writer.WriteObjectValue(SystemMetrics); |
| | 70 | | } |
| 0 | 71 | | if (Optional.IsDefined(Metrics)) |
| | 72 | | { |
| 0 | 73 | | writer.WritePropertyName("metrics"); |
| 0 | 74 | | writer.WriteObjectValue(Metrics); |
| | 75 | | } |
| 0 | 76 | | if (Optional.IsDefined(Etag)) |
| | 77 | | { |
| 0 | 78 | | writer.WritePropertyName("etag"); |
| 0 | 79 | | writer.WriteStringValue(Etag); |
| | 80 | | } |
| 0 | 81 | | writer.WriteEndObject(); |
| 0 | 82 | | } |
| | 83 | |
|
| | 84 | | internal static TwinConfiguration DeserializeTwinConfiguration(JsonElement element) |
| | 85 | | { |
| 0 | 86 | | Optional<string> id = default; |
| 0 | 87 | | Optional<string> schemaVersion = default; |
| 0 | 88 | | Optional<IDictionary<string, string>> labels = default; |
| 0 | 89 | | Optional<ConfigurationContent> content = default; |
| 0 | 90 | | Optional<string> targetCondition = default; |
| 0 | 91 | | Optional<DateTimeOffset> createdTimeUtc = default; |
| 0 | 92 | | Optional<DateTimeOffset> lastUpdatedTimeUtc = default; |
| 0 | 93 | | Optional<int> priority = default; |
| 0 | 94 | | Optional<ConfigurationMetrics> systemMetrics = default; |
| 0 | 95 | | Optional<ConfigurationMetrics> metrics = default; |
| 0 | 96 | | Optional<string> etag = default; |
| 0 | 97 | | foreach (var property in element.EnumerateObject()) |
| | 98 | | { |
| 0 | 99 | | if (property.NameEquals("id")) |
| | 100 | | { |
| 0 | 101 | | id = property.Value.GetString(); |
| 0 | 102 | | continue; |
| | 103 | | } |
| 0 | 104 | | if (property.NameEquals("schemaVersion")) |
| | 105 | | { |
| 0 | 106 | | schemaVersion = property.Value.GetString(); |
| 0 | 107 | | continue; |
| | 108 | | } |
| 0 | 109 | | if (property.NameEquals("labels")) |
| | 110 | | { |
| 0 | 111 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 112 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 113 | | { |
| 0 | 114 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 115 | | } |
| 0 | 116 | | labels = dictionary; |
| 0 | 117 | | continue; |
| | 118 | | } |
| 0 | 119 | | if (property.NameEquals("content")) |
| | 120 | | { |
| 0 | 121 | | content = ConfigurationContent.DeserializeConfigurationContent(property.Value); |
| 0 | 122 | | continue; |
| | 123 | | } |
| 0 | 124 | | if (property.NameEquals("targetCondition")) |
| | 125 | | { |
| 0 | 126 | | targetCondition = property.Value.GetString(); |
| 0 | 127 | | continue; |
| | 128 | | } |
| 0 | 129 | | if (property.NameEquals("createdTimeUtc")) |
| | 130 | | { |
| 0 | 131 | | createdTimeUtc = property.Value.GetDateTimeOffset("O"); |
| 0 | 132 | | continue; |
| | 133 | | } |
| 0 | 134 | | if (property.NameEquals("lastUpdatedTimeUtc")) |
| | 135 | | { |
| 0 | 136 | | lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("O"); |
| 0 | 137 | | continue; |
| | 138 | | } |
| 0 | 139 | | if (property.NameEquals("priority")) |
| | 140 | | { |
| 0 | 141 | | priority = property.Value.GetInt32(); |
| 0 | 142 | | continue; |
| | 143 | | } |
| 0 | 144 | | if (property.NameEquals("systemMetrics")) |
| | 145 | | { |
| 0 | 146 | | systemMetrics = ConfigurationMetrics.DeserializeConfigurationMetrics(property.Value); |
| 0 | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | if (property.NameEquals("metrics")) |
| | 150 | | { |
| 0 | 151 | | metrics = ConfigurationMetrics.DeserializeConfigurationMetrics(property.Value); |
| 0 | 152 | | continue; |
| | 153 | | } |
| 0 | 154 | | if (property.NameEquals("etag")) |
| | 155 | | { |
| 0 | 156 | | etag = property.Value.GetString(); |
| | 157 | | continue; |
| | 158 | | } |
| | 159 | | } |
| 0 | 160 | | return new TwinConfiguration(id.Value, schemaVersion.Value, Optional.ToDictionary(labels), content.Value, ta |
| | 161 | | } |
| | 162 | | } |
| | 163 | | } |