Skip to content

Commit 6376033

Browse files
authored
[PrivateDns] Add customization code for RecordSet (Azure#32085)
1 parent a22eaa8 commit 6376033

File tree

134 files changed

+31267
-2133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+31267
-2133
lines changed

sdk/privatedns/Azure.ResourceManager.PrivateDns/api/Azure.ResourceManager.PrivateDns.netstandard2.0.cs

Lines changed: 343 additions & 301 deletions
Large diffs are not rendered by default.
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.Core;
9+
using Azure.ResourceManager.PrivateDns;
10+
11+
namespace Azure.ResourceManager.PrivateDns.Models
12+
{
13+
internal partial class PrivateDnsARecordListResult
14+
{
15+
internal static PrivateDnsARecordListResult DeserializePrivateDnsARecordListResult(JsonElement element)
16+
{
17+
Optional<IReadOnlyList<PrivateDnsARecordData>> value = default;
18+
Optional<string> nextLink = default;
19+
foreach (var property in element.EnumerateObject())
20+
{
21+
if (property.NameEquals("value"))
22+
{
23+
if (property.Value.ValueKind == JsonValueKind.Null)
24+
{
25+
property.ThrowNonNullablePropertyIsNull();
26+
continue;
27+
}
28+
List<PrivateDnsARecordData> array = new List<PrivateDnsARecordData>();
29+
foreach (var item in property.Value.EnumerateArray())
30+
{
31+
array.Add(PrivateDnsARecordData.DeserializePrivateDnsARecordData(item));
32+
}
33+
value = array;
34+
continue;
35+
}
36+
if (property.NameEquals("nextLink"))
37+
{
38+
nextLink = property.Value.GetString();
39+
continue;
40+
}
41+
}
42+
return new PrivateDnsARecordListResult(Optional.ToList(value), nextLink.Value);
43+
}
44+
}
45+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 Azure.Core;
8+
using Azure.ResourceManager.PrivateDns;
9+
10+
namespace Azure.ResourceManager.PrivateDns.Models
11+
{
12+
/// <summary> The response to a record set List operation. </summary>
13+
internal partial class PrivateDnsARecordListResult
14+
{
15+
/// <summary> Initializes a new instance of PrivateDnsARecordSetListResult. </summary>
16+
internal PrivateDnsARecordListResult()
17+
{
18+
Value = new ChangeTrackingList<PrivateDnsARecordData>();
19+
}
20+
21+
/// <summary> Initializes a new instance of PrivateDnsARecordSetListResult. </summary>
22+
/// <param name="value"> Information about the record sets in the response. </param>
23+
/// <param name="nextLink"> The continuation token for the next page of results. </param>
24+
internal PrivateDnsARecordListResult(IReadOnlyList<PrivateDnsARecordData> value, string nextLink)
25+
{
26+
Value = value;
27+
NextLink = nextLink;
28+
}
29+
30+
/// <summary> Information about the record sets in the response. </summary>
31+
public IReadOnlyList<PrivateDnsARecordData> Value { get; }
32+
/// <summary> The continuation token for the next page of results. </summary>
33+
public string NextLink { get; }
34+
}
35+
}

0 commit comments

Comments
 (0)