| | 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 DeviceIdentity : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 72 | 19 | | writer.WriteStartObject(); |
| 72 | 20 | | if (Optional.IsDefined(DeviceId)) |
| | 21 | | { |
| 72 | 22 | | writer.WritePropertyName("deviceId"); |
| 72 | 23 | | writer.WriteStringValue(DeviceId); |
| | 24 | | } |
| 72 | 25 | | if (Optional.IsDefined(GenerationId)) |
| | 26 | | { |
| 16 | 27 | | writer.WritePropertyName("generationId"); |
| 16 | 28 | | writer.WriteStringValue(GenerationId); |
| | 29 | | } |
| 72 | 30 | | if (Optional.IsDefined(Etag)) |
| | 31 | | { |
| 16 | 32 | | writer.WritePropertyName("etag"); |
| 16 | 33 | | writer.WriteStringValue(Etag); |
| | 34 | | } |
| 72 | 35 | | if (Optional.IsDefined(ConnectionState)) |
| | 36 | | { |
| 16 | 37 | | writer.WritePropertyName("connectionState"); |
| 16 | 38 | | writer.WriteStringValue(ConnectionState.Value.ToString()); |
| | 39 | | } |
| 72 | 40 | | if (Optional.IsDefined(Status)) |
| | 41 | | { |
| 24 | 42 | | writer.WritePropertyName("status"); |
| 24 | 43 | | writer.WriteStringValue(Status.Value.ToString()); |
| | 44 | | } |
| 72 | 45 | | if (Optional.IsDefined(StatusReason)) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("statusReason"); |
| 0 | 48 | | writer.WriteStringValue(StatusReason); |
| | 49 | | } |
| 72 | 50 | | if (Optional.IsDefined(ConnectionStateUpdatedTime)) |
| | 51 | | { |
| 16 | 52 | | writer.WritePropertyName("connectionStateUpdatedTime"); |
| 16 | 53 | | writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "O"); |
| | 54 | | } |
| 72 | 55 | | if (Optional.IsDefined(StatusUpdatedTime)) |
| | 56 | | { |
| 16 | 57 | | writer.WritePropertyName("statusUpdatedTime"); |
| 16 | 58 | | writer.WriteStringValue(StatusUpdatedTime.Value, "O"); |
| | 59 | | } |
| 72 | 60 | | if (Optional.IsDefined(LastActivityTime)) |
| | 61 | | { |
| 16 | 62 | | writer.WritePropertyName("lastActivityTime"); |
| 16 | 63 | | writer.WriteStringValue(LastActivityTime.Value, "O"); |
| | 64 | | } |
| 72 | 65 | | if (Optional.IsDefined(CloudToDeviceMessageCount)) |
| | 66 | | { |
| 16 | 67 | | writer.WritePropertyName("cloudToDeviceMessageCount"); |
| 16 | 68 | | writer.WriteNumberValue(CloudToDeviceMessageCount.Value); |
| | 69 | | } |
| 72 | 70 | | if (Optional.IsDefined(Authentication)) |
| | 71 | | { |
| 16 | 72 | | writer.WritePropertyName("authentication"); |
| 16 | 73 | | writer.WriteObjectValue(Authentication); |
| | 74 | | } |
| 72 | 75 | | if (Optional.IsDefined(Capabilities)) |
| | 76 | | { |
| 16 | 77 | | writer.WritePropertyName("capabilities"); |
| 16 | 78 | | writer.WriteObjectValue(Capabilities); |
| | 79 | | } |
| 72 | 80 | | if (Optional.IsDefined(DeviceScope)) |
| | 81 | | { |
| 0 | 82 | | writer.WritePropertyName("deviceScope"); |
| 0 | 83 | | writer.WriteStringValue(DeviceScope); |
| | 84 | | } |
| 72 | 85 | | if (Optional.IsCollectionDefined(ParentScopes)) |
| | 86 | | { |
| 12 | 87 | | writer.WritePropertyName("parentScopes"); |
| 12 | 88 | | writer.WriteStartArray(); |
| 0 | 89 | | foreach (var item in ParentScopes) |
| | 90 | | { |
| 0 | 91 | | writer.WriteStringValue(item); |
| | 92 | | } |
| 12 | 93 | | writer.WriteEndArray(); |
| | 94 | | } |
| 72 | 95 | | writer.WriteEndObject(); |
| 72 | 96 | | } |
| | 97 | |
|
| | 98 | | internal static DeviceIdentity DeserializeDeviceIdentity(JsonElement element) |
| | 99 | | { |
| 80 | 100 | | Optional<string> deviceId = default; |
| 80 | 101 | | Optional<string> generationId = default; |
| 80 | 102 | | Optional<string> etag = default; |
| 80 | 103 | | Optional<DeviceConnectionState> connectionState = default; |
| 80 | 104 | | Optional<DeviceStatus> status = default; |
| 80 | 105 | | Optional<string> statusReason = default; |
| 80 | 106 | | Optional<DateTimeOffset> connectionStateUpdatedTime = default; |
| 80 | 107 | | Optional<DateTimeOffset> statusUpdatedTime = default; |
| 80 | 108 | | Optional<DateTimeOffset> lastActivityTime = default; |
| 80 | 109 | | Optional<int> cloudToDeviceMessageCount = default; |
| 80 | 110 | | Optional<AuthenticationMechanism> authentication = default; |
| 80 | 111 | | Optional<DeviceCapabilities> capabilities = default; |
| 80 | 112 | | Optional<string> deviceScope = default; |
| 80 | 113 | | Optional<IList<string>> parentScopes = default; |
| 2208 | 114 | | foreach (var property in element.EnumerateObject()) |
| | 115 | | { |
| 1024 | 116 | | if (property.NameEquals("deviceId")) |
| | 117 | | { |
| 80 | 118 | | deviceId = property.Value.GetString(); |
| 80 | 119 | | continue; |
| | 120 | | } |
| 944 | 121 | | if (property.NameEquals("generationId")) |
| | 122 | | { |
| 80 | 123 | | generationId = property.Value.GetString(); |
| 80 | 124 | | continue; |
| | 125 | | } |
| 864 | 126 | | if (property.NameEquals("etag")) |
| | 127 | | { |
| 80 | 128 | | etag = property.Value.GetString(); |
| 80 | 129 | | continue; |
| | 130 | | } |
| 784 | 131 | | if (property.NameEquals("connectionState")) |
| | 132 | | { |
| 80 | 133 | | connectionState = new DeviceConnectionState(property.Value.GetString()); |
| 80 | 134 | | continue; |
| | 135 | | } |
| 704 | 136 | | if (property.NameEquals("status")) |
| | 137 | | { |
| 80 | 138 | | status = new DeviceStatus(property.Value.GetString()); |
| 80 | 139 | | continue; |
| | 140 | | } |
| 624 | 141 | | if (property.NameEquals("statusReason")) |
| | 142 | | { |
| 80 | 143 | | statusReason = property.Value.GetString(); |
| 80 | 144 | | continue; |
| | 145 | | } |
| 544 | 146 | | if (property.NameEquals("connectionStateUpdatedTime")) |
| | 147 | | { |
| 80 | 148 | | connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); |
| 80 | 149 | | continue; |
| | 150 | | } |
| 464 | 151 | | if (property.NameEquals("statusUpdatedTime")) |
| | 152 | | { |
| 80 | 153 | | statusUpdatedTime = property.Value.GetDateTimeOffset("O"); |
| 80 | 154 | | continue; |
| | 155 | | } |
| 384 | 156 | | if (property.NameEquals("lastActivityTime")) |
| | 157 | | { |
| 80 | 158 | | lastActivityTime = property.Value.GetDateTimeOffset("O"); |
| 80 | 159 | | continue; |
| | 160 | | } |
| 304 | 161 | | if (property.NameEquals("cloudToDeviceMessageCount")) |
| | 162 | | { |
| 80 | 163 | | cloudToDeviceMessageCount = property.Value.GetInt32(); |
| 80 | 164 | | continue; |
| | 165 | | } |
| 224 | 166 | | if (property.NameEquals("authentication")) |
| | 167 | | { |
| 80 | 168 | | authentication = AuthenticationMechanism.DeserializeAuthenticationMechanism(property.Value); |
| 80 | 169 | | continue; |
| | 170 | | } |
| 144 | 171 | | if (property.NameEquals("capabilities")) |
| | 172 | | { |
| 80 | 173 | | capabilities = DeviceCapabilities.DeserializeDeviceCapabilities(property.Value); |
| 80 | 174 | | continue; |
| | 175 | | } |
| 64 | 176 | | if (property.NameEquals("deviceScope")) |
| | 177 | | { |
| 0 | 178 | | deviceScope = property.Value.GetString(); |
| 0 | 179 | | continue; |
| | 180 | | } |
| 64 | 181 | | if (property.NameEquals("parentScopes")) |
| | 182 | | { |
| 64 | 183 | | List<string> array = new List<string>(); |
| 0 | 184 | | foreach (var item in property.Value.EnumerateArray()) |
| | 185 | | { |
| 0 | 186 | | array.Add(item.GetString()); |
| | 187 | | } |
| 64 | 188 | | parentScopes = array; |
| | 189 | | continue; |
| | 190 | | } |
| | 191 | | } |
| 80 | 192 | | return new DeviceIdentity(deviceId.Value, generationId.Value, etag.Value, Optional.ToNullable(connectionStat |
| | 193 | | } |
| | 194 | | } |
| | 195 | | } |