public async Task <Response <VpnSiteLinkConnection> > GetAsync(string resourceGroupName, string gatewayName, string connectionName, string linkConnectionName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } if (connectionName == null) { throw new ArgumentNullException(nameof(connectionName)); } if (linkConnectionName == null) { throw new ArgumentNullException(nameof(linkConnectionName)); } using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName, linkConnectionName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VpnSiteLinkConnection value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal static VpnConnectionData DeserializeVpnConnectionData(JsonElement element) { Optional <string> name = default; Optional <string> etag = default; ResourceIdentifier id = default; Optional <SubResource> remoteVpnSite = default; Optional <int> routingWeight = default; Optional <int> dpdTimeoutSeconds = default; Optional <VpnConnectionStatus> connectionStatus = default; Optional <VirtualNetworkGatewayConnectionProtocol> vpnConnectionProtocolType = default; Optional <long> ingressBytesTransferred = default; Optional <long> egressBytesTransferred = default; Optional <int> connectionBandwidth = default; Optional <string> sharedKey = default; Optional <bool> enableBgp = default; Optional <bool> usePolicyBasedTrafficSelectors = default; Optional <IList <IpsecPolicy> > ipsecPolicies = default; Optional <IList <TrafficSelectorPolicy> > trafficSelectorPolicies = default; Optional <bool> enableRateLimiting = default; Optional <bool> enableInternetSecurity = default; Optional <bool> useLocalAzureIpAddress = default; Optional <ProvisioningState> provisioningState = default; Optional <IList <VpnSiteLinkConnection> > vpnLinkConnections = default; Optional <RoutingConfiguration> routingConfiguration = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("remoteVpnSite")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } remoteVpnSite = SubResource.DeserializeSubResource(property0.Value); continue; } if (property0.NameEquals("routingWeight")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } routingWeight = property0.Value.GetInt32(); continue; } if (property0.NameEquals("dpdTimeoutSeconds")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } dpdTimeoutSeconds = property0.Value.GetInt32(); continue; } if (property0.NameEquals("connectionStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } connectionStatus = new VpnConnectionStatus(property0.Value.GetString()); continue; } if (property0.NameEquals("vpnConnectionProtocolType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnConnectionProtocolType = new VirtualNetworkGatewayConnectionProtocol(property0.Value.GetString()); continue; } if (property0.NameEquals("ingressBytesTransferred")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } ingressBytesTransferred = property0.Value.GetInt64(); continue; } if (property0.NameEquals("egressBytesTransferred")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } egressBytesTransferred = property0.Value.GetInt64(); continue; } if (property0.NameEquals("connectionBandwidth")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } connectionBandwidth = property0.Value.GetInt32(); continue; } if (property0.NameEquals("sharedKey")) { sharedKey = property0.Value.GetString(); continue; } if (property0.NameEquals("enableBgp")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableBgp = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("usePolicyBasedTrafficSelectors")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } usePolicyBasedTrafficSelectors = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("ipsecPolicies")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <IpsecPolicy> array = new List <IpsecPolicy>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(IpsecPolicy.DeserializeIpsecPolicy(item)); } ipsecPolicies = array; continue; } if (property0.NameEquals("trafficSelectorPolicies")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <TrafficSelectorPolicy> array = new List <TrafficSelectorPolicy>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(TrafficSelectorPolicy.DeserializeTrafficSelectorPolicy(item)); } trafficSelectorPolicies = array; continue; } if (property0.NameEquals("enableRateLimiting")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableRateLimiting = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("enableInternetSecurity")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableInternetSecurity = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("useLocalAzureIpAddress")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } useLocalAzureIpAddress = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("vpnLinkConnections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VpnSiteLinkConnection> array = new List <VpnSiteLinkConnection>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(item)); } vpnLinkConnections = array; continue; } if (property0.NameEquals("routingConfiguration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } routingConfiguration = RoutingConfiguration.DeserializeRoutingConfiguration(property0.Value); continue; } } continue; } } return(new VpnConnectionData(id, name.Value, etag.Value, remoteVpnSite.Value, Optional.ToNullable(routingWeight), Optional.ToNullable(dpdTimeoutSeconds), Optional.ToNullable(connectionStatus), Optional.ToNullable(vpnConnectionProtocolType), Optional.ToNullable(ingressBytesTransferred), Optional.ToNullable(egressBytesTransferred), Optional.ToNullable(connectionBandwidth), sharedKey.Value, Optional.ToNullable(enableBgp), Optional.ToNullable(usePolicyBasedTrafficSelectors), Optional.ToList(ipsecPolicies), Optional.ToList(trafficSelectorPolicies), Optional.ToNullable(enableRateLimiting), Optional.ToNullable(enableInternetSecurity), Optional.ToNullable(useLocalAzureIpAddress), Optional.ToNullable(provisioningState), Optional.ToList(vpnLinkConnections), routingConfiguration.Value)); }