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