public async virtual Task <InboundNatRuleCreateOrUpdateOperation> CreateOrUpdateAsync(string inboundNatRuleName, InboundNatRuleData inboundNatRuleParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (inboundNatRuleName == null) { throw new ArgumentNullException(nameof(inboundNatRuleName)); } if (inboundNatRuleParameters == null) { throw new ArgumentNullException(nameof(inboundNatRuleParameters)); } using var scope = _clientDiagnostics.CreateScope("InboundNatRuleContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, Id.Name, inboundNatRuleName, inboundNatRuleParameters, cancellationToken).ConfigureAwait(false); var operation = new InboundNatRuleCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, Id.Name, inboundNatRuleName, inboundNatRuleParameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual InboundNatRuleCreateOrUpdateOperation CreateOrUpdate(string inboundNatRuleName, InboundNatRuleData inboundNatRuleParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (inboundNatRuleName == null) { throw new ArgumentNullException(nameof(inboundNatRuleName)); } if (inboundNatRuleParameters == null) { throw new ArgumentNullException(nameof(inboundNatRuleParameters)); } using var scope = _clientDiagnostics.CreateScope("InboundNatRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = _inboundNatRulesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, inboundNatRuleName, inboundNatRuleParameters, cancellationToken); var operation = new InboundNatRuleCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _inboundNatRulesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, inboundNatRuleName, inboundNatRuleParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }