|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +#nullable disable |
| 5 | + |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Text.Json; |
| 8 | +using Azure; |
| 9 | +using Azure.Core; |
| 10 | +using Azure.ResourceManager.Models; |
| 11 | +using Azure.ResourceManager.PrivateDns.Models; |
| 12 | + |
| 13 | +namespace Azure.ResourceManager.PrivateDns |
| 14 | +{ |
| 15 | + public partial class PrivateDnsARecordData : IUtf8JsonSerializable |
| 16 | + { |
| 17 | + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| 18 | + { |
| 19 | + writer.WriteStartObject(); |
| 20 | + if (Optional.IsDefined(ETag)) |
| 21 | + { |
| 22 | + writer.WritePropertyName("etag"); |
| 23 | + writer.WriteStringValue(ETag.Value.ToString()); |
| 24 | + } |
| 25 | + writer.WritePropertyName("properties"); |
| 26 | + writer.WriteStartObject(); |
| 27 | + if (Optional.IsCollectionDefined(Metadata)) |
| 28 | + { |
| 29 | + writer.WritePropertyName("metadata"); |
| 30 | + writer.WriteStartObject(); |
| 31 | + foreach (var item in Metadata) |
| 32 | + { |
| 33 | + writer.WritePropertyName(item.Key); |
| 34 | + writer.WriteStringValue(item.Value); |
| 35 | + } |
| 36 | + writer.WriteEndObject(); |
| 37 | + } |
| 38 | + if (Optional.IsDefined(TtlInSeconds)) |
| 39 | + { |
| 40 | + writer.WritePropertyName("ttl"); |
| 41 | + writer.WriteNumberValue(TtlInSeconds.Value); |
| 42 | + } |
| 43 | + if (Optional.IsCollectionDefined(PrivateDnsARecords)) |
| 44 | + { |
| 45 | + writer.WritePropertyName("aRecords"); |
| 46 | + writer.WriteStartArray(); |
| 47 | + foreach (var item in PrivateDnsARecords) |
| 48 | + { |
| 49 | + writer.WriteObjectValue(item); |
| 50 | + } |
| 51 | + writer.WriteEndArray(); |
| 52 | + } |
| 53 | + writer.WriteEndObject(); |
| 54 | + writer.WriteEndObject(); |
| 55 | + } |
| 56 | + |
| 57 | + internal static PrivateDnsARecordData DeserializePrivateDnsARecordData(JsonElement element) |
| 58 | + { |
| 59 | + Optional<ETag> etag = default; |
| 60 | + ResourceIdentifier id = default; |
| 61 | + string name = default; |
| 62 | + ResourceType type = default; |
| 63 | + Optional<SystemData> systemData = default; |
| 64 | + Optional<IDictionary<string, string>> metadata = default; |
| 65 | + Optional<long> ttl = default; |
| 66 | + Optional<string> fqdn = default; |
| 67 | + Optional<bool> isAutoRegistered = default; |
| 68 | + Optional<IList<PrivateDnsARecordInfo>> aRecords = default; |
| 69 | + foreach (var property in element.EnumerateObject()) |
| 70 | + { |
| 71 | + if (property.NameEquals("etag")) |
| 72 | + { |
| 73 | + if (property.Value.ValueKind == JsonValueKind.Null) |
| 74 | + { |
| 75 | + property.ThrowNonNullablePropertyIsNull(); |
| 76 | + continue; |
| 77 | + } |
| 78 | + etag = new ETag(property.Value.GetString()); |
| 79 | + continue; |
| 80 | + } |
| 81 | + if (property.NameEquals("id")) |
| 82 | + { |
| 83 | + id = new ResourceIdentifier(property.Value.GetString()); |
| 84 | + continue; |
| 85 | + } |
| 86 | + if (property.NameEquals("name")) |
| 87 | + { |
| 88 | + name = property.Value.GetString(); |
| 89 | + continue; |
| 90 | + } |
| 91 | + if (property.NameEquals("type")) |
| 92 | + { |
| 93 | + type = new ResourceType(property.Value.GetString()); |
| 94 | + continue; |
| 95 | + } |
| 96 | + if (property.NameEquals("systemData")) |
| 97 | + { |
| 98 | + if (property.Value.ValueKind == JsonValueKind.Null) |
| 99 | + { |
| 100 | + property.ThrowNonNullablePropertyIsNull(); |
| 101 | + continue; |
| 102 | + } |
| 103 | + systemData = JsonSerializer.Deserialize<SystemData>(property.Value.ToString()); |
| 104 | + continue; |
| 105 | + } |
| 106 | + if (property.NameEquals("properties")) |
| 107 | + { |
| 108 | + if (property.Value.ValueKind == JsonValueKind.Null) |
| 109 | + { |
| 110 | + property.ThrowNonNullablePropertyIsNull(); |
| 111 | + continue; |
| 112 | + } |
| 113 | + foreach (var property0 in property.Value.EnumerateObject()) |
| 114 | + { |
| 115 | + if (property0.NameEquals("metadata")) |
| 116 | + { |
| 117 | + if (property0.Value.ValueKind == JsonValueKind.Null) |
| 118 | + { |
| 119 | + property0.ThrowNonNullablePropertyIsNull(); |
| 120 | + continue; |
| 121 | + } |
| 122 | + Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 123 | + foreach (var property1 in property0.Value.EnumerateObject()) |
| 124 | + { |
| 125 | + dictionary.Add(property1.Name, property1.Value.GetString()); |
| 126 | + } |
| 127 | + metadata = dictionary; |
| 128 | + continue; |
| 129 | + } |
| 130 | + if (property0.NameEquals("ttl")) |
| 131 | + { |
| 132 | + if (property0.Value.ValueKind == JsonValueKind.Null) |
| 133 | + { |
| 134 | + property0.ThrowNonNullablePropertyIsNull(); |
| 135 | + continue; |
| 136 | + } |
| 137 | + ttl = property0.Value.GetInt64(); |
| 138 | + continue; |
| 139 | + } |
| 140 | + if (property0.NameEquals("fqdn")) |
| 141 | + { |
| 142 | + fqdn = property0.Value.GetString(); |
| 143 | + continue; |
| 144 | + } |
| 145 | + if (property0.NameEquals("isAutoRegistered")) |
| 146 | + { |
| 147 | + if (property0.Value.ValueKind == JsonValueKind.Null) |
| 148 | + { |
| 149 | + property0.ThrowNonNullablePropertyIsNull(); |
| 150 | + continue; |
| 151 | + } |
| 152 | + isAutoRegistered = property0.Value.GetBoolean(); |
| 153 | + continue; |
| 154 | + } |
| 155 | + if (property0.NameEquals("aRecords")) |
| 156 | + { |
| 157 | + if (property0.Value.ValueKind == JsonValueKind.Null) |
| 158 | + { |
| 159 | + property0.ThrowNonNullablePropertyIsNull(); |
| 160 | + continue; |
| 161 | + } |
| 162 | + List<PrivateDnsARecordInfo> array = new List<PrivateDnsARecordInfo>(); |
| 163 | + foreach (var item in property0.Value.EnumerateArray()) |
| 164 | + { |
| 165 | + array.Add(PrivateDnsARecordInfo.DeserializePrivateDnsARecordInfo(item)); |
| 166 | + } |
| 167 | + aRecords = array; |
| 168 | + continue; |
| 169 | + } |
| 170 | + } |
| 171 | + continue; |
| 172 | + } |
| 173 | + } |
| 174 | + return new PrivateDnsARecordData(id, name, type, systemData.Value, Optional.ToNullable(etag), Optional.ToDictionary(metadata), Optional.ToNullable(ttl), fqdn.Value, Optional.ToNullable(isAutoRegistered), Optional.ToList(aRecords)); |
| 175 | + } |
| 176 | + } |
| 177 | +} |
0 commit comments