VirtualNetworkGatewayResource IOperationSource <VirtualNetworkGatewayResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = VirtualNetworkGatewayData.DeserializeVirtualNetworkGatewayData(document.RootElement); return(new VirtualNetworkGatewayResource(_client, data)); }
internal static VirtualNetworkGatewayConnectionData DeserializeVirtualNetworkGatewayConnectionData(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 <string> authorizationKey = default; VirtualNetworkGatewayData virtualNetworkGateway1 = default; Optional <VirtualNetworkGatewayData> virtualNetworkGateway2 = default; Optional <LocalNetworkGatewayData> localNetworkGateway2 = default; Optional <IList <WritableSubResource> > ingressNatRules = default; Optional <IList <WritableSubResource> > egressNatRules = default; VirtualNetworkGatewayConnectionType connectionType = default; Optional <VirtualNetworkGatewayConnectionProtocol> connectionProtocol = default; Optional <int> routingWeight = default; Optional <int> dpdTimeoutSeconds = default; Optional <VirtualNetworkGatewayConnectionMode> connectionMode = default; Optional <string> sharedKey = default; Optional <VirtualNetworkGatewayConnectionStatus> connectionStatus = default; Optional <IReadOnlyList <TunnelConnectionHealth> > tunnelConnectionStatus = default; Optional <long> egressBytesTransferred = default; Optional <long> ingressBytesTransferred = default; Optional <WritableSubResource> peer = default; Optional <bool> enableBgp = default; Optional <bool> useLocalAzureIpAddress = default; Optional <bool> usePolicyBasedTrafficSelectors = default; Optional <IList <IPsecPolicy> > ipsecPolicies = default; Optional <IList <TrafficSelectorPolicy> > trafficSelectorPolicies = default; Optional <Guid> resourceGuid = default; Optional <NetworkProvisioningState> provisioningState = default; Optional <bool> expressRouteGatewayBypass = 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("authorizationKey")) { authorizationKey = property0.Value.GetString(); continue; } if (property0.NameEquals("virtualNetworkGateway1")) { virtualNetworkGateway1 = VirtualNetworkGatewayData.DeserializeVirtualNetworkGatewayData(property0.Value); continue; } if (property0.NameEquals("virtualNetworkGateway2")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualNetworkGateway2 = VirtualNetworkGatewayData.DeserializeVirtualNetworkGatewayData(property0.Value); continue; } if (property0.NameEquals("localNetworkGateway2")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } localNetworkGateway2 = LocalNetworkGatewayData.DeserializeLocalNetworkGatewayData(property0.Value); continue; } if (property0.NameEquals("ingressNatRules")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WritableSubResource> array = new List <WritableSubResource>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString())); } ingressNatRules = array; continue; } if (property0.NameEquals("egressNatRules")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WritableSubResource> array = new List <WritableSubResource>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString())); } egressNatRules = array; continue; } if (property0.NameEquals("connectionType")) { connectionType = new VirtualNetworkGatewayConnectionType(property0.Value.GetString()); continue; } if (property0.NameEquals("connectionProtocol")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } connectionProtocol = new VirtualNetworkGatewayConnectionProtocol(property0.Value.GetString()); 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("connectionMode")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } connectionMode = new VirtualNetworkGatewayConnectionMode(property0.Value.GetString()); continue; } if (property0.NameEquals("sharedKey")) { sharedKey = property0.Value.GetString(); continue; } if (property0.NameEquals("connectionStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } connectionStatus = new VirtualNetworkGatewayConnectionStatus(property0.Value.GetString()); continue; } if (property0.NameEquals("tunnelConnectionStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <TunnelConnectionHealth> array = new List <TunnelConnectionHealth>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(TunnelConnectionHealth.DeserializeTunnelConnectionHealth(item)); } tunnelConnectionStatus = array; continue; } if (property0.NameEquals("egressBytesTransferred")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } egressBytesTransferred = property0.Value.GetInt64(); continue; } if (property0.NameEquals("ingressBytesTransferred")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } ingressBytesTransferred = property0.Value.GetInt64(); continue; } if (property0.NameEquals("peer")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } peer = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("enableBgp")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableBgp = 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("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("resourceGuid")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } resourceGuid = property0.Value.GetGuid(); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new NetworkProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("expressRouteGatewayBypass")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } expressRouteGatewayBypass = property0.Value.GetBoolean(); continue; } } continue; } } return(new VirtualNetworkGatewayConnectionData(id.Value, name.Value, Optional.ToNullable(type), Optional.ToNullable(location), Optional.ToDictionary(tags), Optional.ToNullable(etag), authorizationKey.Value, virtualNetworkGateway1, virtualNetworkGateway2.Value, localNetworkGateway2.Value, Optional.ToList(ingressNatRules), Optional.ToList(egressNatRules), connectionType, Optional.ToNullable(connectionProtocol), Optional.ToNullable(routingWeight), Optional.ToNullable(dpdTimeoutSeconds), Optional.ToNullable(connectionMode), sharedKey.Value, Optional.ToNullable(connectionStatus), Optional.ToList(tunnelConnectionStatus), Optional.ToNullable(egressBytesTransferred), Optional.ToNullable(ingressBytesTransferred), peer, Optional.ToNullable(enableBgp), Optional.ToNullable(useLocalAzureIpAddress), Optional.ToNullable(usePolicyBasedTrafficSelectors), Optional.ToList(ipsecPolicies), Optional.ToList(trafficSelectorPolicies), Optional.ToNullable(resourceGuid), Optional.ToNullable(provisioningState), Optional.ToNullable(expressRouteGatewayBypass))); }