| | 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.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Network.Models |
| | 13 | | { |
| | 14 | | public partial class IpAllocation : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Etag != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("etag"); |
| 0 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 0 | 24 | | if (Id != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("id"); |
| 0 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 0 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 0 | 34 | | if (Type != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("type"); |
| 0 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 0 | 39 | | if (Location != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("location"); |
| 0 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 0 | 44 | | if (Tags != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("tags"); |
| 0 | 47 | | writer.WriteStartObject(); |
| 0 | 48 | | foreach (var item in Tags) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName(item.Key); |
| 0 | 51 | | writer.WriteStringValue(item.Value); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndObject(); |
| | 54 | | } |
| 0 | 55 | | writer.WritePropertyName("properties"); |
| 0 | 56 | | writer.WriteStartObject(); |
| 0 | 57 | | if (Subnet != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("subnet"); |
| 0 | 60 | | writer.WriteObjectValue(Subnet); |
| | 61 | | } |
| 0 | 62 | | if (VirtualNetwork != null) |
| | 63 | | { |
| 0 | 64 | | writer.WritePropertyName("virtualNetwork"); |
| 0 | 65 | | writer.WriteObjectValue(VirtualNetwork); |
| | 66 | | } |
| 0 | 67 | | if (TypePropertiesType != null) |
| | 68 | | { |
| 0 | 69 | | writer.WritePropertyName("type"); |
| 0 | 70 | | writer.WriteStringValue(TypePropertiesType.Value.ToString()); |
| | 71 | | } |
| 0 | 72 | | if (Prefix != null) |
| | 73 | | { |
| 0 | 74 | | writer.WritePropertyName("prefix"); |
| 0 | 75 | | writer.WriteStringValue(Prefix); |
| | 76 | | } |
| 0 | 77 | | if (PrefixLength != null) |
| | 78 | | { |
| 0 | 79 | | writer.WritePropertyName("prefixLength"); |
| 0 | 80 | | writer.WriteNumberValue(PrefixLength.Value); |
| | 81 | | } |
| 0 | 82 | | if (PrefixType != null) |
| | 83 | | { |
| 0 | 84 | | writer.WritePropertyName("prefixType"); |
| 0 | 85 | | writer.WriteStringValue(PrefixType.Value.ToString()); |
| | 86 | | } |
| 0 | 87 | | if (IpamAllocationId != null) |
| | 88 | | { |
| 0 | 89 | | writer.WritePropertyName("ipamAllocationId"); |
| 0 | 90 | | writer.WriteStringValue(IpamAllocationId); |
| | 91 | | } |
| 0 | 92 | | if (AllocationTags != null) |
| | 93 | | { |
| 0 | 94 | | writer.WritePropertyName("allocationTags"); |
| 0 | 95 | | writer.WriteStartObject(); |
| 0 | 96 | | foreach (var item in AllocationTags) |
| | 97 | | { |
| 0 | 98 | | writer.WritePropertyName(item.Key); |
| 0 | 99 | | writer.WriteStringValue(item.Value); |
| | 100 | | } |
| 0 | 101 | | writer.WriteEndObject(); |
| | 102 | | } |
| 0 | 103 | | writer.WriteEndObject(); |
| 0 | 104 | | writer.WriteEndObject(); |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | internal static IpAllocation DeserializeIpAllocation(JsonElement element) |
| | 108 | | { |
| 0 | 109 | | string etag = default; |
| 0 | 110 | | string id = default; |
| 0 | 111 | | string name = default; |
| 0 | 112 | | string type = default; |
| 0 | 113 | | string location = default; |
| 0 | 114 | | IDictionary<string, string> tags = default; |
| 0 | 115 | | SubResource subnet = default; |
| 0 | 116 | | SubResource virtualNetwork = default; |
| 0 | 117 | | IpAllocationType? type0 = default; |
| 0 | 118 | | string prefix = default; |
| 0 | 119 | | int? prefixLength = default; |
| 0 | 120 | | IPVersion? prefixType = default; |
| 0 | 121 | | string ipamAllocationId = default; |
| 0 | 122 | | IDictionary<string, string> allocationTags = default; |
| 0 | 123 | | foreach (var property in element.EnumerateObject()) |
| | 124 | | { |
| 0 | 125 | | if (property.NameEquals("etag")) |
| | 126 | | { |
| 0 | 127 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| | 129 | | continue; |
| | 130 | | } |
| 0 | 131 | | etag = property.Value.GetString(); |
| 0 | 132 | | continue; |
| | 133 | | } |
| 0 | 134 | | if (property.NameEquals("id")) |
| | 135 | | { |
| 0 | 136 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 137 | | { |
| | 138 | | continue; |
| | 139 | | } |
| 0 | 140 | | id = property.Value.GetString(); |
| 0 | 141 | | continue; |
| | 142 | | } |
| 0 | 143 | | if (property.NameEquals("name")) |
| | 144 | | { |
| 0 | 145 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | name = property.Value.GetString(); |
| 0 | 150 | | continue; |
| | 151 | | } |
| 0 | 152 | | if (property.NameEquals("type")) |
| | 153 | | { |
| 0 | 154 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 0 | 158 | | type = property.Value.GetString(); |
| 0 | 159 | | continue; |
| | 160 | | } |
| 0 | 161 | | if (property.NameEquals("location")) |
| | 162 | | { |
| 0 | 163 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 0 | 167 | | location = property.Value.GetString(); |
| 0 | 168 | | continue; |
| | 169 | | } |
| 0 | 170 | | if (property.NameEquals("tags")) |
| | 171 | | { |
| 0 | 172 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 0 | 176 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 177 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 178 | | { |
| 0 | 179 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 180 | | { |
| 0 | 181 | | dictionary.Add(property0.Name, null); |
| | 182 | | } |
| | 183 | | else |
| | 184 | | { |
| 0 | 185 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 186 | | } |
| | 187 | | } |
| 0 | 188 | | tags = dictionary; |
| 0 | 189 | | continue; |
| | 190 | | } |
| 0 | 191 | | if (property.NameEquals("properties")) |
| | 192 | | { |
| 0 | 193 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 194 | | { |
| 0 | 195 | | if (property0.NameEquals("subnet")) |
| | 196 | | { |
| 0 | 197 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 198 | | { |
| | 199 | | continue; |
| | 200 | | } |
| 0 | 201 | | subnet = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 202 | | continue; |
| | 203 | | } |
| 0 | 204 | | if (property0.NameEquals("virtualNetwork")) |
| | 205 | | { |
| 0 | 206 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 207 | | { |
| | 208 | | continue; |
| | 209 | | } |
| 0 | 210 | | virtualNetwork = SubResource.DeserializeSubResource(property0.Value); |
| 0 | 211 | | continue; |
| | 212 | | } |
| 0 | 213 | | if (property0.NameEquals("type")) |
| | 214 | | { |
| 0 | 215 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 216 | | { |
| | 217 | | continue; |
| | 218 | | } |
| 0 | 219 | | type0 = new IpAllocationType(property0.Value.GetString()); |
| 0 | 220 | | continue; |
| | 221 | | } |
| 0 | 222 | | if (property0.NameEquals("prefix")) |
| | 223 | | { |
| 0 | 224 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 225 | | { |
| | 226 | | continue; |
| | 227 | | } |
| 0 | 228 | | prefix = property0.Value.GetString(); |
| 0 | 229 | | continue; |
| | 230 | | } |
| 0 | 231 | | if (property0.NameEquals("prefixLength")) |
| | 232 | | { |
| 0 | 233 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 234 | | { |
| | 235 | | continue; |
| | 236 | | } |
| 0 | 237 | | prefixLength = property0.Value.GetInt32(); |
| 0 | 238 | | continue; |
| | 239 | | } |
| 0 | 240 | | if (property0.NameEquals("prefixType")) |
| | 241 | | { |
| 0 | 242 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 243 | | { |
| | 244 | | continue; |
| | 245 | | } |
| 0 | 246 | | prefixType = new IPVersion(property0.Value.GetString()); |
| 0 | 247 | | continue; |
| | 248 | | } |
| 0 | 249 | | if (property0.NameEquals("ipamAllocationId")) |
| | 250 | | { |
| 0 | 251 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 252 | | { |
| | 253 | | continue; |
| | 254 | | } |
| 0 | 255 | | ipamAllocationId = property0.Value.GetString(); |
| 0 | 256 | | continue; |
| | 257 | | } |
| 0 | 258 | | if (property0.NameEquals("allocationTags")) |
| | 259 | | { |
| 0 | 260 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 261 | | { |
| | 262 | | continue; |
| | 263 | | } |
| 0 | 264 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 265 | | foreach (var property1 in property0.Value.EnumerateObject()) |
| | 266 | | { |
| 0 | 267 | | if (property1.Value.ValueKind == JsonValueKind.Null) |
| | 268 | | { |
| 0 | 269 | | dictionary.Add(property1.Name, null); |
| | 270 | | } |
| | 271 | | else |
| | 272 | | { |
| 0 | 273 | | dictionary.Add(property1.Name, property1.Value.GetString()); |
| | 274 | | } |
| | 275 | | } |
| 0 | 276 | | allocationTags = dictionary; |
| | 277 | | continue; |
| | 278 | | } |
| | 279 | | } |
| | 280 | | continue; |
| | 281 | | } |
| | 282 | | } |
| 0 | 283 | | return new IpAllocation(id, name, type, location, tags, etag, subnet, virtualNetwork, type0, prefix, prefixL |
| | 284 | | } |
| | 285 | | } |
| | 286 | | } |