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