public async Task <Response <VirtualNetworkGatewayNatRuleData> > GetAsync(string subscriptionId, string resourceGroupName, string virtualNetworkGatewayName, string natRuleName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (virtualNetworkGatewayName == null) { throw new ArgumentNullException(nameof(virtualNetworkGatewayName)); } if (natRuleName == null) { throw new ArgumentNullException(nameof(natRuleName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualNetworkGatewayName, natRuleName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VirtualNetworkGatewayNatRuleData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = VirtualNetworkGatewayNatRuleData.DeserializeVirtualNetworkGatewayNatRuleData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal VirtualNetworkGatewayNatRule(ArmResource options, VirtualNetworkGatewayNatRuleData resource) : base(options, new ResourceIdentifier(resource.Id)) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _virtualNetworkGatewayNatRulesRestClient = new VirtualNetworkGatewayNatRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
VirtualNetworkGatewayNatRuleResource IOperationSource <VirtualNetworkGatewayNatRuleResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = VirtualNetworkGatewayNatRuleData.DeserializeVirtualNetworkGatewayNatRuleData(document.RootElement); return(new VirtualNetworkGatewayNatRuleResource(_client, data)); }
internal VirtualNetworkGatewayNatRule(ArmResource options, VirtualNetworkGatewayNatRuleData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new VirtualNetworkGatewayNatRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
public async virtual Task <VirtualNetworkGatewayNatRuleCreateOrUpdateOperation> CreateOrUpdateAsync(string natRuleName, VirtualNetworkGatewayNatRuleData natRuleParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (natRuleName == null) { throw new ArgumentNullException(nameof(natRuleName)); } if (natRuleParameters == null) { throw new ArgumentNullException(nameof(natRuleParameters)); } using var scope = _clientDiagnostics.CreateScope("VirtualNetworkGatewayNatRuleContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters, cancellationToken).ConfigureAwait(false); var operation = new VirtualNetworkGatewayNatRuleCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal VirtualNetworkGatewayNatRule(ArmClient client, VirtualNetworkGatewayNatRuleData data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
public virtual VirtualNetworkGatewayNatRuleCreateOrUpdateOperation CreateOrUpdate(string natRuleName, VirtualNetworkGatewayNatRuleData natRuleParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (natRuleName == null) { throw new ArgumentNullException(nameof(natRuleName)); } if (natRuleParameters == null) { throw new ArgumentNullException(nameof(natRuleParameters)); } using var scope = _clientDiagnostics.CreateScope("VirtualNetworkGatewayNatRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = _virtualNetworkGatewayNatRulesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters, cancellationToken); var operation = new VirtualNetworkGatewayNatRuleCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _virtualNetworkGatewayNatRulesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal static VirtualNetworkGatewayData DeserializeVirtualNetworkGatewayData(JsonElement element) { Optional <ExtendedLocation> extendedLocation = default; Optional <string> etag = default; Optional <string> name = default; Optional <string> type = default; Optional <string> location = default; Optional <IDictionary <string, string> > tags = default; ResourceIdentifier id = default; Optional <IList <VirtualNetworkGatewayIPConfiguration> > ipConfigurations = default; Optional <VirtualNetworkGatewayType> gatewayType = default; Optional <VpnType> vpnType = default; Optional <VpnGatewayGeneration> vpnGatewayGeneration = default; Optional <bool> enableBgp = default; Optional <bool> enablePrivateIpAddress = default; Optional <bool> activeActive = default; Optional <SubResource> gatewayDefaultSite = default; Optional <VirtualNetworkGatewaySku> sku = default; Optional <VpnClientConfiguration> vpnClientConfiguration = default; Optional <BgpSettings> bgpSettings = default; Optional <AddressSpace> customRoutes = default; Optional <string> resourceGuid = default; Optional <ProvisioningState> provisioningState = default; Optional <bool> enableDnsForwarding = default; Optional <string> inboundDnsForwardingEndpoint = default; Optional <string> vNetExtendedLocationResourceId = default; Optional <IList <VirtualNetworkGatewayNatRuleData> > natRules = default; Optional <bool> enableBgpRouteTranslationForNat = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("extendedLocation")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("location")) { location = 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("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("ipConfigurations")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VirtualNetworkGatewayIPConfiguration> array = new List <VirtualNetworkGatewayIPConfiguration>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VirtualNetworkGatewayIPConfiguration.DeserializeVirtualNetworkGatewayIPConfiguration(item)); } ipConfigurations = array; continue; } if (property0.NameEquals("gatewayType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } gatewayType = new VirtualNetworkGatewayType(property0.Value.GetString()); continue; } if (property0.NameEquals("vpnType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnType = new VpnType(property0.Value.GetString()); continue; } if (property0.NameEquals("vpnGatewayGeneration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnGatewayGeneration = new VpnGatewayGeneration(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("enablePrivateIpAddress")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enablePrivateIpAddress = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("activeActive")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } activeActive = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("gatewayDefaultSite")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } gatewayDefaultSite = SubResource.DeserializeSubResource(property0.Value); continue; } if (property0.NameEquals("sku")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } sku = VirtualNetworkGatewaySku.DeserializeVirtualNetworkGatewaySku(property0.Value); continue; } if (property0.NameEquals("vpnClientConfiguration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnClientConfiguration = VpnClientConfiguration.DeserializeVpnClientConfiguration(property0.Value); continue; } if (property0.NameEquals("bgpSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } bgpSettings = BgpSettings.DeserializeBgpSettings(property0.Value); continue; } if (property0.NameEquals("customRoutes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } customRoutes = AddressSpace.DeserializeAddressSpace(property0.Value); continue; } if (property0.NameEquals("resourceGuid")) { resourceGuid = property0.Value.GetString(); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("enableDnsForwarding")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableDnsForwarding = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("inboundDnsForwardingEndpoint")) { inboundDnsForwardingEndpoint = property0.Value.GetString(); continue; } if (property0.NameEquals("vNetExtendedLocationResourceId")) { vNetExtendedLocationResourceId = property0.Value.GetString(); continue; } if (property0.NameEquals("natRules")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VirtualNetworkGatewayNatRuleData> array = new List <VirtualNetworkGatewayNatRuleData>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VirtualNetworkGatewayNatRuleData.DeserializeVirtualNetworkGatewayNatRuleData(item)); } natRules = array; continue; } if (property0.NameEquals("enableBgpRouteTranslationForNat")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableBgpRouteTranslationForNat = property0.Value.GetBoolean(); continue; } } continue; } } return(new VirtualNetworkGatewayData(id, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), extendedLocation.Value, etag.Value, Optional.ToList(ipConfigurations), Optional.ToNullable(gatewayType), Optional.ToNullable(vpnType), Optional.ToNullable(vpnGatewayGeneration), Optional.ToNullable(enableBgp), Optional.ToNullable(enablePrivateIpAddress), Optional.ToNullable(activeActive), gatewayDefaultSite.Value, sku.Value, vpnClientConfiguration.Value, bgpSettings.Value, customRoutes.Value, resourceGuid.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(enableDnsForwarding), inboundDnsForwardingEndpoint.Value, vNetExtendedLocationResourceId.Value, Optional.ToList(natRules), Optional.ToNullable(enableBgpRouteTranslationForNat))); }
public async virtual Task <ArmOperation <VirtualNetworkGatewayNatRule> > CreateOrUpdateAsync(bool waitForCompletion, string natRuleName, VirtualNetworkGatewayNatRuleData natRuleParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(natRuleName, nameof(natRuleName)); Argument.AssertNotNull(natRuleParameters, nameof(natRuleParameters)); using var scope = _virtualNetworkGatewayNatRuleClientDiagnostics.CreateScope("VirtualNetworkGatewayNatRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = await _virtualNetworkGatewayNatRuleRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <VirtualNetworkGatewayNatRule>(new VirtualNetworkGatewayNatRuleOperationSource(Client), _virtualNetworkGatewayNatRuleClientDiagnostics, Pipeline, _virtualNetworkGatewayNatRuleRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, natRuleName, natRuleParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal VirtualNetworkGatewayNatRuleResource(ArmClient client, VirtualNetworkGatewayNatRuleData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <VirtualNetworkGatewayNatRuleResource> Update(WaitUntil waitUntil, VirtualNetworkGatewayNatRuleData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _virtualNetworkGatewayNatRuleClientDiagnostics.CreateScope("VirtualNetworkGatewayNatRuleResource.Update"); scope.Start(); try { var response = _virtualNetworkGatewayNatRuleRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new NetworkArmOperation <VirtualNetworkGatewayNatRuleResource>(new VirtualNetworkGatewayNatRuleOperationSource(Client), _virtualNetworkGatewayNatRuleClientDiagnostics, Pipeline, _virtualNetworkGatewayNatRuleRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }