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; } }
AfdRule IOperationSource <AfdRule> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = AfdRuleData.DeserializeAfdRuleData(document.RootElement); return(new AfdRule(_client, data)); }
internal AfdRule(ArmResource options, AfdRuleData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _afdRulesRestClient = new AfdRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
internal AfdRule(ArmResource options, AfdRuleData data) : base(options, data.Id) { HasData = true; _data = data; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _afdRulesRestClient = new AfdRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif }
internal AfdRule(ArmResource options, AfdRuleData data) : base(options, data.Id) { HasData = true; _data = data; _clientDiagnostics = new ClientDiagnostics(ClientOptions); ClientOptions.TryGetApiVersion(ResourceType, out string apiVersion); _afdRulesRestClient = new AfdRulesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri, apiVersion); #if DEBUG ValidateResourceId(Id); #endif }
internal AfdRule(ArmClient client, AfdRuleData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual async Task <ArmOperation <AfdRuleResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string ruleName, AfdRuleData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ruleName, nameof(ruleName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _afdRuleClientDiagnostics.CreateScope("AfdRuleCollection.CreateOrUpdate"); scope.Start(); try { var response = await _afdRuleRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, data, cancellationToken).ConfigureAwait(false); var operation = new CdnArmOperation <AfdRuleResource>(new AfdRuleOperationSource(Client), _afdRuleClientDiagnostics, Pipeline, _afdRuleRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, 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 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; } }
public async virtual Task <AfdRuleCreateOrUpdateOperation> CreateOrUpdateAsync(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 = await _afdRuleRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule, cancellationToken).ConfigureAwait(false); var operation = new AfdRuleCreateOrUpdateOperation(ArmClient, _afdRuleClientDiagnostics, Pipeline, _afdRuleRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ruleName, rule).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }