public async Task <Response <VpnConnectionData> > GetAsync(string resourceGroupName, string gatewayName, string connectionName, 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)); } using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VpnConnectionData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = VpnConnectionData.DeserializeVpnConnectionData(document.RootElement); return(Response.FromValue(value, message.Response)); }
VpnConnection IOperationSource <VpnConnection> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = VpnConnectionData.DeserializeVpnConnectionData(document.RootElement); return(new VpnConnection(_client, data)); }
internal static VpnGatewayData DeserializeVpnGatewayData(JsonElement element) { Optional <ETag> etag = default; Optional <ResourceIdentifier> id = default; Optional <string> name = default; Optional <ResourceType> type = default; Optional <AzureLocation> location = default; Optional <IDictionary <string, string> > tags = default; Optional <WritableSubResource> virtualHub = default; Optional <IList <VpnConnectionData> > connections = default; Optional <BgpSettings> bgpSettings = default; Optional <NetworkProvisioningState> provisioningState = default; Optional <int> vpnGatewayScaleUnit = default; Optional <IReadOnlyList <VpnGatewayIPConfiguration> > ipConfigurations = default; Optional <bool> isRoutingPreferenceInternet = default; Optional <IList <VpnGatewayNatRuleData> > natRules = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } etag = new ETag(property.Value.GetString()); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("location")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } location = new AzureLocation(property.Value.GetString()); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("virtualHub")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualHub = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("connections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VpnConnectionData> array = new List <VpnConnectionData>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VpnConnectionData.DeserializeVpnConnectionData(item)); } connections = array; continue; } if (property0.NameEquals("bgpSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } bgpSettings = BgpSettings.DeserializeBgpSettings(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new NetworkProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("vpnGatewayScaleUnit")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnGatewayScaleUnit = property0.Value.GetInt32(); continue; } if (property0.NameEquals("ipConfigurations")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VpnGatewayIPConfiguration> array = new List <VpnGatewayIPConfiguration>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VpnGatewayIPConfiguration.DeserializeVpnGatewayIPConfiguration(item)); } ipConfigurations = array; continue; } if (property0.NameEquals("isRoutingPreferenceInternet")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isRoutingPreferenceInternet = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("natRules")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VpnGatewayNatRuleData> array = new List <VpnGatewayNatRuleData>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VpnGatewayNatRuleData.DeserializeVpnGatewayNatRuleData(item)); } natRules = array; continue; } } continue; } } return(new VpnGatewayData(id.Value, name.Value, Optional.ToNullable(type), Optional.ToNullable(location), Optional.ToDictionary(tags), Optional.ToNullable(etag), virtualHub, Optional.ToList(connections), bgpSettings.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(vpnGatewayScaleUnit), Optional.ToList(ipConfigurations), Optional.ToNullable(isRoutingPreferenceInternet), Optional.ToList(natRules))); }