public virtual VpnGatewayCreateOrUpdateOperation CreateOrUpdate(string gatewayName, VpnGatewayData vpnGatewayParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } if (vpnGatewayParameters == null) { throw new ArgumentNullException(nameof(vpnGatewayParameters)); } using var scope = _clientDiagnostics.CreateScope("VpnGatewayContainer.CreateOrUpdate"); scope.Start(); try { var response = _restClient.CreateOrUpdate(Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken); var operation = new VpnGatewayCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <VpnGatewayResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string gatewayName, VpnGatewayData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = await _vpnGatewayRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <VpnGatewayResource>(new VpnGatewayOperationSource(Client), _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual VpnGatewayCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string gatewayName, VpnGatewayData vpnGatewayParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); if (vpnGatewayParameters == null) { throw new ArgumentNullException(nameof(vpnGatewayParameters)); } using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = _vpnGatewayRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken); var operation = new VpnGatewayCreateOrUpdateOperation(ArmClient, _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }