public virtual AfdRuleCreateOperation CreateOrUpdate(string ruleName, AfdRuleData rule, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (ruleName == null) { throw new ArgumentNullException(nameof(ruleName)); } if (rule == null) { throw new ArgumentNullException(nameof(rule)); } using var scope = _clientDiagnostics.CreateScope("AfdRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = _afdRulesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule, cancellationToken); var operation = new AfdRuleCreateOperation(Parent, _clientDiagnostics, Pipeline, _afdRulesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <AfdRule> CreateOrUpdate(bool waitForCompletion, string ruleName, AfdRuleData rule, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ruleName, nameof(ruleName)); if (rule == null) { throw new ArgumentNullException(nameof(rule)); } using var scope = _afdRuleClientDiagnostics.CreateScope("AfdRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = _afdRuleRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule, cancellationToken); var operation = new CdnArmOperation <AfdRule>(new AfdRuleOperationSource(Client), _afdRuleClientDiagnostics, Pipeline, _afdRuleRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }