public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { using var scope = _collectorPolicyClientDiagnostics.CreateScope("CollectorPolicyResource.Delete"); scope.Start(); try { var response = _collectorPolicyRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); var operation = new NetworkFunctionArmOperation(_collectorPolicyClientDiagnostics, Pipeline, _collectorPolicyRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletionResponse(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation> DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { using var scope = _azureTrafficCollectorClientDiagnostics.CreateScope("AzureTrafficCollectorResource.Delete"); scope.Start(); try { var response = await _azureTrafficCollectorRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); var operation = new NetworkFunctionArmOperation(_azureTrafficCollectorClientDiagnostics, Pipeline, _azureTrafficCollectorRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <CollectorPolicyResource> Update(WaitUntil waitUntil, CollectorPolicyData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _collectorPolicyClientDiagnostics.CreateScope("CollectorPolicyResource.Update"); scope.Start(); try { var response = _collectorPolicyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new NetworkFunctionArmOperation <CollectorPolicyResource>(new CollectorPolicyOperationSource(Client), _collectorPolicyClientDiagnostics, Pipeline, _collectorPolicyRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <AzureTrafficCollectorResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string azureTrafficCollectorName, AzureTrafficCollectorData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(azureTrafficCollectorName, nameof(azureTrafficCollectorName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _azureTrafficCollectorClientDiagnostics.CreateScope("AzureTrafficCollectorCollection.CreateOrUpdate"); scope.Start(); try { var response = await _azureTrafficCollectorRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, azureTrafficCollectorName, data, cancellationToken).ConfigureAwait(false); var operation = new NetworkFunctionArmOperation <AzureTrafficCollectorResource>(new AzureTrafficCollectorOperationSource(Client), _azureTrafficCollectorClientDiagnostics, Pipeline, _azureTrafficCollectorRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, azureTrafficCollectorName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }