| | 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.Iot.Hub.Service.Models |
| | 12 | | { |
| | 13 | | public partial class AuthenticationMechanism : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 120 | 17 | | writer.WriteStartObject(); |
| 120 | 18 | | if (Optional.IsDefined(SymmetricKey)) |
| | 19 | | { |
| 40 | 20 | | writer.WritePropertyName("symmetricKey"); |
| 40 | 21 | | writer.WriteObjectValue(SymmetricKey); |
| | 22 | | } |
| 120 | 23 | | if (Optional.IsDefined(X509Thumbprint)) |
| | 24 | | { |
| 40 | 25 | | writer.WritePropertyName("x509Thumbprint"); |
| 40 | 26 | | writer.WriteObjectValue(X509Thumbprint); |
| | 27 | | } |
| 120 | 28 | | if (Optional.IsDefined(Type)) |
| | 29 | | { |
| 120 | 30 | | writer.WritePropertyName("type"); |
| 120 | 31 | | writer.WriteStringValue(Type.Value.ToString()); |
| | 32 | | } |
| 120 | 33 | | writer.WriteEndObject(); |
| 120 | 34 | | } |
| | 35 | |
|
| | 36 | | internal static AuthenticationMechanism DeserializeAuthenticationMechanism(JsonElement element) |
| | 37 | | { |
| 232 | 38 | | Optional<SymmetricKey> symmetricKey = default; |
| 232 | 39 | | Optional<X509Thumbprint> x509Thumbprint = default; |
| 232 | 40 | | Optional<AuthenticationMechanismType> type = default; |
| 1856 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 696 | 43 | | if (property.NameEquals("symmetricKey")) |
| | 44 | | { |
| 232 | 45 | | symmetricKey = SymmetricKey.DeserializeSymmetricKey(property.Value); |
| 232 | 46 | | continue; |
| | 47 | | } |
| 464 | 48 | | if (property.NameEquals("x509Thumbprint")) |
| | 49 | | { |
| 232 | 50 | | x509Thumbprint = X509Thumbprint.DeserializeX509Thumbprint(property.Value); |
| 232 | 51 | | continue; |
| | 52 | | } |
| 232 | 53 | | if (property.NameEquals("type")) |
| | 54 | | { |
| 232 | 55 | | type = new AuthenticationMechanismType(property.Value.GetString()); |
| | 56 | | continue; |
| | 57 | | } |
| | 58 | | } |
| 232 | 59 | | return new AuthenticationMechanism(symmetricKey.Value, x509Thumbprint.Value, Optional.ToNullable(type)); |
| | 60 | | } |
| | 61 | | } |
| | 62 | | } |