public virtual P2SVpnGatewayCreateOrUpdateOperation CreateOrUpdate(string gatewayName, P2SVpnGatewayData p2SVpnGatewayParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } if (p2SVpnGatewayParameters == null) { throw new ArgumentNullException(nameof(p2SVpnGatewayParameters)); } using var scope = _clientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = _restClient.CreateOrUpdate(Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters, cancellationToken); var operation = new P2SVpnGatewayCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <P2SVpnGatewayCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string gatewayName, P2SVpnGatewayData p2SVpnGatewayParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); if (p2SVpnGatewayParameters == null) { throw new ArgumentNullException(nameof(p2SVpnGatewayParameters)); } using var scope = _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = await _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters, cancellationToken).ConfigureAwait(false); var operation = new P2SVpnGatewayCreateOrUpdateOperation(ArmClient, _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics, Pipeline, _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }