| | 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 EventHub : IUtf8JsonSerializable |
| | 16 | | { |
| | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 18 | | { |
| 0 | 19 | | writer.WriteStartObject(); |
| 0 | 20 | | writer.WritePropertyName("connectionString-PrimaryKey"); |
| 0 | 21 | | writer.WriteStringValue(ConnectionStringPrimaryKey); |
| 0 | 22 | | writer.WritePropertyName("connectionString-SecondaryKey"); |
| 0 | 23 | | writer.WriteStringValue(ConnectionStringSecondaryKey); |
| 0 | 24 | | writer.WritePropertyName("endpointType"); |
| 0 | 25 | | writer.WriteStringValue(EndpointType.ToString()); |
| 0 | 26 | | if (Optional.IsCollectionDefined(Tags)) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName("tags"); |
| 0 | 29 | | writer.WriteStartObject(); |
| 0 | 30 | | foreach (var item in Tags) |
| | 31 | | { |
| 0 | 32 | | writer.WritePropertyName(item.Key); |
| 0 | 33 | | writer.WriteStringValue(item.Value); |
| | 34 | | } |
| 0 | 35 | | writer.WriteEndObject(); |
| | 36 | | } |
| 0 | 37 | | writer.WriteEndObject(); |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | internal static EventHub DeserializeEventHub(JsonElement element) |
| | 41 | | { |
| 0 | 42 | | string connectionStringPrimaryKey = default; |
| 0 | 43 | | string connectionStringSecondaryKey = default; |
| 0 | 44 | | EndpointType endpointType = default; |
| 0 | 45 | | Optional<EndpointProvisioningState> provisioningState = default; |
| 0 | 46 | | Optional<DateTimeOffset> createdTime = default; |
| 0 | 47 | | Optional<IDictionary<string, string>> tags = default; |
| 0 | 48 | | foreach (var property in element.EnumerateObject()) |
| | 49 | | { |
| 0 | 50 | | if (property.NameEquals("connectionString-PrimaryKey")) |
| | 51 | | { |
| 0 | 52 | | connectionStringPrimaryKey = property.Value.GetString(); |
| 0 | 53 | | continue; |
| | 54 | | } |
| 0 | 55 | | if (property.NameEquals("connectionString-SecondaryKey")) |
| | 56 | | { |
| 0 | 57 | | connectionStringSecondaryKey = property.Value.GetString(); |
| 0 | 58 | | continue; |
| | 59 | | } |
| 0 | 60 | | if (property.NameEquals("endpointType")) |
| | 61 | | { |
| 0 | 62 | | endpointType = new EndpointType(property.Value.GetString()); |
| 0 | 63 | | continue; |
| | 64 | | } |
| 0 | 65 | | if (property.NameEquals("provisioningState")) |
| | 66 | | { |
| 0 | 67 | | provisioningState = new EndpointProvisioningState(property.Value.GetString()); |
| 0 | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | if (property.NameEquals("createdTime")) |
| | 71 | | { |
| 0 | 72 | | createdTime = property.Value.GetDateTimeOffset("O"); |
| 0 | 73 | | continue; |
| | 74 | | } |
| 0 | 75 | | if (property.NameEquals("tags")) |
| | 76 | | { |
| 0 | 77 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 78 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 79 | | { |
| 0 | 80 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 81 | | } |
| 0 | 82 | | tags = dictionary; |
| | 83 | | continue; |
| | 84 | | } |
| | 85 | | } |
| 0 | 86 | | return new EventHub(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), |
| | 87 | | } |
| | 88 | | } |
| | 89 | | } |