| | 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.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Iot.Hub.Service.Models |
| | 13 | | { |
| | 14 | | public partial class ModuleIdentity : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 92 | 18 | | writer.WriteStartObject(); |
| 92 | 19 | | if (Optional.IsDefined(ModuleId)) |
| | 20 | | { |
| 92 | 21 | | writer.WritePropertyName("moduleId"); |
| 92 | 22 | | writer.WriteStringValue(ModuleId); |
| | 23 | | } |
| 92 | 24 | | if (Optional.IsDefined(ManagedBy)) |
| | 25 | | { |
| 16 | 26 | | writer.WritePropertyName("managedBy"); |
| 16 | 27 | | writer.WriteStringValue(ManagedBy); |
| | 28 | | } |
| 92 | 29 | | if (Optional.IsDefined(DeviceId)) |
| | 30 | | { |
| 92 | 31 | | writer.WritePropertyName("deviceId"); |
| 92 | 32 | | writer.WriteStringValue(DeviceId); |
| | 33 | | } |
| 92 | 34 | | if (Optional.IsDefined(GenerationId)) |
| | 35 | | { |
| 16 | 36 | | writer.WritePropertyName("generationId"); |
| 16 | 37 | | writer.WriteStringValue(GenerationId); |
| | 38 | | } |
| 92 | 39 | | if (Optional.IsDefined(Etag)) |
| | 40 | | { |
| 16 | 41 | | writer.WritePropertyName("etag"); |
| 16 | 42 | | writer.WriteStringValue(Etag); |
| | 43 | | } |
| 92 | 44 | | if (Optional.IsDefined(ConnectionState)) |
| | 45 | | { |
| 16 | 46 | | writer.WritePropertyName("connectionState"); |
| 16 | 47 | | writer.WriteStringValue(ConnectionState.Value.ToString()); |
| | 48 | | } |
| 92 | 49 | | if (Optional.IsDefined(ConnectionStateUpdatedTime)) |
| | 50 | | { |
| 16 | 51 | | writer.WritePropertyName("connectionStateUpdatedTime"); |
| 16 | 52 | | writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "O"); |
| | 53 | | } |
| 92 | 54 | | if (Optional.IsDefined(LastActivityTime)) |
| | 55 | | { |
| 16 | 56 | | writer.WritePropertyName("lastActivityTime"); |
| 16 | 57 | | writer.WriteStringValue(LastActivityTime.Value, "O"); |
| | 58 | | } |
| 92 | 59 | | if (Optional.IsDefined(CloudToDeviceMessageCount)) |
| | 60 | | { |
| 16 | 61 | | writer.WritePropertyName("cloudToDeviceMessageCount"); |
| 16 | 62 | | writer.WriteNumberValue(CloudToDeviceMessageCount.Value); |
| | 63 | | } |
| 92 | 64 | | if (Optional.IsDefined(Authentication)) |
| | 65 | | { |
| 56 | 66 | | writer.WritePropertyName("authentication"); |
| 56 | 67 | | writer.WriteObjectValue(Authentication); |
| | 68 | | } |
| 92 | 69 | | writer.WriteEndObject(); |
| 92 | 70 | | } |
| | 71 | |
|
| | 72 | | internal static ModuleIdentity DeserializeModuleIdentity(JsonElement element) |
| | 73 | | { |
| 152 | 74 | | Optional<string> moduleId = default; |
| 152 | 75 | | Optional<string> managedBy = default; |
| 152 | 76 | | Optional<string> deviceId = default; |
| 152 | 77 | | Optional<string> generationId = default; |
| 152 | 78 | | Optional<string> etag = default; |
| 152 | 79 | | Optional<ModuleConnectionState> connectionState = default; |
| 152 | 80 | | Optional<DateTimeOffset> connectionStateUpdatedTime = default; |
| 152 | 81 | | Optional<DateTimeOffset> lastActivityTime = default; |
| 152 | 82 | | Optional<int> cloudToDeviceMessageCount = default; |
| 152 | 83 | | Optional<AuthenticationMechanism> authentication = default; |
| 3344 | 84 | | foreach (var property in element.EnumerateObject()) |
| | 85 | | { |
| 1520 | 86 | | if (property.NameEquals("moduleId")) |
| | 87 | | { |
| 152 | 88 | | moduleId = property.Value.GetString(); |
| 152 | 89 | | continue; |
| | 90 | | } |
| 1368 | 91 | | if (property.NameEquals("managedBy")) |
| | 92 | | { |
| 152 | 93 | | managedBy = property.Value.GetString(); |
| 152 | 94 | | continue; |
| | 95 | | } |
| 1216 | 96 | | if (property.NameEquals("deviceId")) |
| | 97 | | { |
| 152 | 98 | | deviceId = property.Value.GetString(); |
| 152 | 99 | | continue; |
| | 100 | | } |
| 1064 | 101 | | if (property.NameEquals("generationId")) |
| | 102 | | { |
| 152 | 103 | | generationId = property.Value.GetString(); |
| 152 | 104 | | continue; |
| | 105 | | } |
| 912 | 106 | | if (property.NameEquals("etag")) |
| | 107 | | { |
| 152 | 108 | | etag = property.Value.GetString(); |
| 152 | 109 | | continue; |
| | 110 | | } |
| 760 | 111 | | if (property.NameEquals("connectionState")) |
| | 112 | | { |
| 152 | 113 | | connectionState = new ModuleConnectionState(property.Value.GetString()); |
| 152 | 114 | | continue; |
| | 115 | | } |
| 608 | 116 | | if (property.NameEquals("connectionStateUpdatedTime")) |
| | 117 | | { |
| 152 | 118 | | connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); |
| 152 | 119 | | continue; |
| | 120 | | } |
| 456 | 121 | | if (property.NameEquals("lastActivityTime")) |
| | 122 | | { |
| 152 | 123 | | lastActivityTime = property.Value.GetDateTimeOffset("O"); |
| 152 | 124 | | continue; |
| | 125 | | } |
| 304 | 126 | | if (property.NameEquals("cloudToDeviceMessageCount")) |
| | 127 | | { |
| 152 | 128 | | cloudToDeviceMessageCount = property.Value.GetInt32(); |
| 152 | 129 | | continue; |
| | 130 | | } |
| 152 | 131 | | if (property.NameEquals("authentication")) |
| | 132 | | { |
| 152 | 133 | | authentication = AuthenticationMechanism.DeserializeAuthenticationMechanism(property.Value); |
| | 134 | | continue; |
| | 135 | | } |
| | 136 | | } |
| 152 | 137 | | return new ModuleIdentity(moduleId.Value, managedBy.Value, deviceId.Value, generationId.Value, etag.Value, O |
| | 138 | | } |
| | 139 | | } |
| | 140 | | } |