| | 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 VpnConnection : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Name != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("name"); |
| 0 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 0 | 24 | | if (Etag != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("etag"); |
| 0 | 27 | | writer.WriteStringValue(Etag); |
| | 28 | | } |
| 0 | 29 | | if (Id != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("id"); |
| 0 | 32 | | writer.WriteStringValue(Id); |
| | 33 | | } |
| 0 | 34 | | writer.WritePropertyName("properties"); |
| 0 | 35 | | writer.WriteStartObject(); |
| 0 | 36 | | if (RemoteVpnSite != null) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("remoteVpnSite"); |
| 0 | 39 | | writer.WriteObjectValue(RemoteVpnSite); |
| | 40 | | } |
| 0 | 41 | | if (RoutingWeight != null) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("routingWeight"); |
| 0 | 44 | | writer.WriteNumberValue(RoutingWeight.Value); |
| | 45 | | } |
| 0 | 46 | | if (DpdTimeoutSeconds != null) |
| | 47 | | { |
| 0 | 48 | | writer.WritePropertyName("dpdTimeoutSeconds"); |
| 0 | 49 | | writer.WriteNumberValue(DpdTimeoutSeconds.Value); |
| | 50 | | } |
| 0 | 51 | | if (ConnectionStatus != null) |
| | 52 | | { |
| 0 | 53 | | writer.WritePropertyName("connectionStatus"); |
| 0 | 54 | | writer.WriteStringValue(ConnectionStatus.Value.ToString()); |
| | 55 | | } |
| 0 | 56 | | if (VpnConnectionProtocolType != null) |
| | 57 | | { |
| 0 | 58 | | writer.WritePropertyName("vpnConnectionProtocolType"); |
| 0 | 59 | | writer.WriteStringValue(VpnConnectionProtocolType.Value.ToString()); |
| | 60 | | } |
| 0 | 61 | | if (IngressBytesTransferred != null) |
| | 62 | | { |
| 0 | 63 | | writer.WritePropertyName("ingressBytesTransferred"); |
| 0 | 64 | | writer.WriteNumberValue(IngressBytesTransferred.Value); |
| | 65 | | } |
| 0 | 66 | | if (EgressBytesTransferred != null) |
| | 67 | | { |
| 0 | 68 | | writer.WritePropertyName("egressBytesTransferred"); |
| 0 | 69 | | writer.WriteNumberValue(EgressBytesTransferred.Value); |
| | 70 | | } |
| 0 | 71 | | if (ConnectionBandwidth != null) |
| | 72 | | { |
| 0 | 73 | | writer.WritePropertyName("connectionBandwidth"); |
| 0 | 74 | | writer.WriteNumberValue(ConnectionBandwidth.Value); |
| | 75 | | } |
| 0 | 76 | | if (SharedKey != null) |
| | 77 | | { |
| 0 | 78 | | writer.WritePropertyName("sharedKey"); |
| 0 | 79 | | writer.WriteStringValue(SharedKey); |
| | 80 | | } |
| 0 | 81 | | if (EnableBgp != null) |
| | 82 | | { |
| 0 | 83 | | writer.WritePropertyName("enableBgp"); |
| 0 | 84 | | writer.WriteBooleanValue(EnableBgp.Value); |
| | 85 | | } |
| 0 | 86 | | if (UsePolicyBasedTrafficSelectors != null) |
| | 87 | | { |
| 0 | 88 | | writer.WritePropertyName("usePolicyBasedTrafficSelectors"); |
| 0 | 89 | | writer.WriteBooleanValue(UsePolicyBasedTrafficSelectors.Value); |
| | 90 | | } |
| 0 | 91 | | if (IpsecPolicies != null) |
| | 92 | | { |
| 0 | 93 | | writer.WritePropertyName("ipsecPolicies"); |
| 0 | 94 | | writer.WriteStartArray(); |
| 0 | 95 | | foreach (var item in IpsecPolicies) |
| | 96 | | { |
| 0 | 97 | | writer.WriteObjectValue(item); |
| | 98 | | } |
| 0 | 99 | | writer.WriteEndArray(); |
| | 100 | | } |
| 0 | 101 | | if (EnableRateLimiting != null) |
| | 102 | | { |
| 0 | 103 | | writer.WritePropertyName("enableRateLimiting"); |
| 0 | 104 | | writer.WriteBooleanValue(EnableRateLimiting.Value); |
| | 105 | | } |
| 0 | 106 | | if (EnableInternetSecurity != null) |
| | 107 | | { |
| 0 | 108 | | writer.WritePropertyName("enableInternetSecurity"); |
| 0 | 109 | | writer.WriteBooleanValue(EnableInternetSecurity.Value); |
| | 110 | | } |
| 0 | 111 | | if (UseLocalAzureIpAddress != null) |
| | 112 | | { |
| 0 | 113 | | writer.WritePropertyName("useLocalAzureIpAddress"); |
| 0 | 114 | | writer.WriteBooleanValue(UseLocalAzureIpAddress.Value); |
| | 115 | | } |
| 0 | 116 | | if (ProvisioningState != null) |
| | 117 | | { |
| 0 | 118 | | writer.WritePropertyName("provisioningState"); |
| 0 | 119 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 120 | | } |
| 0 | 121 | | if (VpnLinkConnections != null) |
| | 122 | | { |
| 0 | 123 | | writer.WritePropertyName("vpnLinkConnections"); |
| 0 | 124 | | writer.WriteStartArray(); |
| 0 | 125 | | foreach (var item in VpnLinkConnections) |
| | 126 | | { |
| 0 | 127 | | writer.WriteObjectValue(item); |
| | 128 | | } |
| 0 | 129 | | writer.WriteEndArray(); |
| | 130 | | } |
| 0 | 131 | | if (RoutingConfiguration != null) |
| | 132 | | { |
| 0 | 133 | | writer.WritePropertyName("routingConfiguration"); |
| 0 | 134 | | writer.WriteObjectValue(RoutingConfiguration); |
| | 135 | | } |
| 0 | 136 | | writer.WriteEndObject(); |
| 0 | 137 | | writer.WriteEndObject(); |
| 0 | 138 | | } |
| | 139 | |
|
| | 140 | | internal static VpnConnection DeserializeVpnConnection(JsonElement element) |
| | 141 | | { |
| 0 | 142 | | string name = default; |
| 0 | 143 | | string etag = default; |
| 0 | 144 | | string id = default; |
| 0 | 145 | | SubResource remoteVpnSite = default; |
| 0 | 146 | | int? routingWeight = default; |
| 0 | 147 | | int? dpdTimeoutSeconds = default; |
| 0 | 148 | | VpnConnectionStatus? connectionStatus = default; |
| 0 | 149 | | VirtualNetworkGatewayConnectionProtocol? vpnConnectionProtocolType = default; |
| 0 | 150 | | long? ingressBytesTransferred = default; |
| 0 | 151 | | long? egressBytesTransferred = default; |
| 0 | 152 | | int? connectionBandwidth = default; |
| 0 | 153 | | string sharedKey = default; |
| 0 | 154 | | bool? enableBgp = default; |
| 0 | 155 | | bool? usePolicyBasedTrafficSelectors = default; |
| 0 | 156 | | IList<IpsecPolicy> ipsecPolicies = default; |
| 0 | 157 | | bool? enableRateLimiting = default; |
| 0 | 158 | | bool? enableInternetSecurity = default; |
| 0 | 159 | | bool? useLocalAzureIpAddress = default; |
| 0 | 160 | | ProvisioningState? provisioningState = default; |
| 0 | 161 | | IList<VpnSiteLinkConnection> vpnLinkConnections = default; |
| 0 | 162 | | RoutingConfiguration routingConfiguration = default; |
| 0 | 163 | | foreach (var property in element.EnumerateObject()) |
| | 164 | | { |
| 0 | 165 | | if (property.NameEquals("name")) |
| | 166 | | { |
| 0 | 167 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 168 | | { |
| | 169 | | continue; |
| | 170 | | } |
| 0 | 171 | | name = property.Value.GetString(); |
| 0 | 172 | | continue; |
| | 173 | | } |
| 0 | 174 | | if (property.NameEquals("etag")) |
| | 175 | | { |
| 0 | 176 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 177 | | { |
| | 178 | | continue; |
| | 179 | | } |
| 0 | 180 | | etag = property.Value.GetString(); |
| 0 | 181 | | continue; |
| | 182 | | } |
| 0 | 183 | | if (property.NameEquals("id")) |
| | 184 | | { |
| 0 | 185 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| | 187 | | continue; |
| | 188 | | } |
| 0 | 189 | | id = property.Value.GetString(); |
| 0 | 190 | | continue; |
| | 191 | | } |
| 0 | 192 | | if (property.NameEquals("properties")) |
| | 193 | | { |
| 0 | 194 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 195 | | { |
| 0 | 196 | | if (property0.NameEquals("remoteVpnSite")) |
| | 197 | | { |
| 0 | 198 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 199 | | { |
| | 200 | | continue; |
| | 201 | | } |
| 0 | 202 | | remoteVpnSite = DeserializeSubResource(property0.Value); |
| 0 | 203 | | continue; |
| | 204 | | } |
| 0 | 205 | | if (property0.NameEquals("routingWeight")) |
| | 206 | | { |
| 0 | 207 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 208 | | { |
| | 209 | | continue; |
| | 210 | | } |
| 0 | 211 | | routingWeight = property0.Value.GetInt32(); |
| 0 | 212 | | continue; |
| | 213 | | } |
| 0 | 214 | | if (property0.NameEquals("dpdTimeoutSeconds")) |
| | 215 | | { |
| 0 | 216 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 217 | | { |
| | 218 | | continue; |
| | 219 | | } |
| 0 | 220 | | dpdTimeoutSeconds = property0.Value.GetInt32(); |
| 0 | 221 | | continue; |
| | 222 | | } |
| 0 | 223 | | if (property0.NameEquals("connectionStatus")) |
| | 224 | | { |
| 0 | 225 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 226 | | { |
| | 227 | | continue; |
| | 228 | | } |
| 0 | 229 | | connectionStatus = new VpnConnectionStatus(property0.Value.GetString()); |
| 0 | 230 | | continue; |
| | 231 | | } |
| 0 | 232 | | if (property0.NameEquals("vpnConnectionProtocolType")) |
| | 233 | | { |
| 0 | 234 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 235 | | { |
| | 236 | | continue; |
| | 237 | | } |
| 0 | 238 | | vpnConnectionProtocolType = new VirtualNetworkGatewayConnectionProtocol(property0.Value.GetS |
| 0 | 239 | | continue; |
| | 240 | | } |
| 0 | 241 | | if (property0.NameEquals("ingressBytesTransferred")) |
| | 242 | | { |
| 0 | 243 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 244 | | { |
| | 245 | | continue; |
| | 246 | | } |
| 0 | 247 | | ingressBytesTransferred = property0.Value.GetInt64(); |
| 0 | 248 | | continue; |
| | 249 | | } |
| 0 | 250 | | if (property0.NameEquals("egressBytesTransferred")) |
| | 251 | | { |
| 0 | 252 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 253 | | { |
| | 254 | | continue; |
| | 255 | | } |
| 0 | 256 | | egressBytesTransferred = property0.Value.GetInt64(); |
| 0 | 257 | | continue; |
| | 258 | | } |
| 0 | 259 | | if (property0.NameEquals("connectionBandwidth")) |
| | 260 | | { |
| 0 | 261 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 262 | | { |
| | 263 | | continue; |
| | 264 | | } |
| 0 | 265 | | connectionBandwidth = property0.Value.GetInt32(); |
| 0 | 266 | | continue; |
| | 267 | | } |
| 0 | 268 | | if (property0.NameEquals("sharedKey")) |
| | 269 | | { |
| 0 | 270 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 271 | | { |
| | 272 | | continue; |
| | 273 | | } |
| 0 | 274 | | sharedKey = property0.Value.GetString(); |
| 0 | 275 | | continue; |
| | 276 | | } |
| 0 | 277 | | if (property0.NameEquals("enableBgp")) |
| | 278 | | { |
| 0 | 279 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 280 | | { |
| | 281 | | continue; |
| | 282 | | } |
| 0 | 283 | | enableBgp = property0.Value.GetBoolean(); |
| 0 | 284 | | continue; |
| | 285 | | } |
| 0 | 286 | | if (property0.NameEquals("usePolicyBasedTrafficSelectors")) |
| | 287 | | { |
| 0 | 288 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 289 | | { |
| | 290 | | continue; |
| | 291 | | } |
| 0 | 292 | | usePolicyBasedTrafficSelectors = property0.Value.GetBoolean(); |
| 0 | 293 | | continue; |
| | 294 | | } |
| 0 | 295 | | if (property0.NameEquals("ipsecPolicies")) |
| | 296 | | { |
| 0 | 297 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 298 | | { |
| | 299 | | continue; |
| | 300 | | } |
| 0 | 301 | | List<IpsecPolicy> array = new List<IpsecPolicy>(); |
| 0 | 302 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 303 | | { |
| 0 | 304 | | if (item.ValueKind == JsonValueKind.Null) |
| | 305 | | { |
| 0 | 306 | | array.Add(null); |
| | 307 | | } |
| | 308 | | else |
| | 309 | | { |
| 0 | 310 | | array.Add(IpsecPolicy.DeserializeIpsecPolicy(item)); |
| | 311 | | } |
| | 312 | | } |
| 0 | 313 | | ipsecPolicies = array; |
| 0 | 314 | | continue; |
| | 315 | | } |
| 0 | 316 | | if (property0.NameEquals("enableRateLimiting")) |
| | 317 | | { |
| 0 | 318 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 319 | | { |
| | 320 | | continue; |
| | 321 | | } |
| 0 | 322 | | enableRateLimiting = property0.Value.GetBoolean(); |
| 0 | 323 | | continue; |
| | 324 | | } |
| 0 | 325 | | if (property0.NameEquals("enableInternetSecurity")) |
| | 326 | | { |
| 0 | 327 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 328 | | { |
| | 329 | | continue; |
| | 330 | | } |
| 0 | 331 | | enableInternetSecurity = property0.Value.GetBoolean(); |
| 0 | 332 | | continue; |
| | 333 | | } |
| 0 | 334 | | if (property0.NameEquals("useLocalAzureIpAddress")) |
| | 335 | | { |
| 0 | 336 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 337 | | { |
| | 338 | | continue; |
| | 339 | | } |
| 0 | 340 | | useLocalAzureIpAddress = property0.Value.GetBoolean(); |
| 0 | 341 | | continue; |
| | 342 | | } |
| 0 | 343 | | if (property0.NameEquals("provisioningState")) |
| | 344 | | { |
| 0 | 345 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 346 | | { |
| | 347 | | continue; |
| | 348 | | } |
| 0 | 349 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 0 | 350 | | continue; |
| | 351 | | } |
| 0 | 352 | | if (property0.NameEquals("vpnLinkConnections")) |
| | 353 | | { |
| 0 | 354 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 355 | | { |
| | 356 | | continue; |
| | 357 | | } |
| 0 | 358 | | List<VpnSiteLinkConnection> array = new List<VpnSiteLinkConnection>(); |
| 0 | 359 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 360 | | { |
| 0 | 361 | | if (item.ValueKind == JsonValueKind.Null) |
| | 362 | | { |
| 0 | 363 | | array.Add(null); |
| | 364 | | } |
| | 365 | | else |
| | 366 | | { |
| 0 | 367 | | array.Add(VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(item)); |
| | 368 | | } |
| | 369 | | } |
| 0 | 370 | | vpnLinkConnections = array; |
| 0 | 371 | | continue; |
| | 372 | | } |
| 0 | 373 | | if (property0.NameEquals("routingConfiguration")) |
| | 374 | | { |
| 0 | 375 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 376 | | { |
| | 377 | | continue; |
| | 378 | | } |
| 0 | 379 | | routingConfiguration = RoutingConfiguration.DeserializeRoutingConfiguration(property0.Value) |
| | 380 | | continue; |
| | 381 | | } |
| | 382 | | } |
| | 383 | | continue; |
| | 384 | | } |
| | 385 | | } |
| 0 | 386 | | return new VpnConnection(id, name, etag, remoteVpnSite, routingWeight, dpdTimeoutSeconds, connectionStatus, |
| | 387 | | } |
| | 388 | | } |
| | 389 | | } |