public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationResource.Delete"); scope.Start(); try { var response = _customLocationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); var operation = new ExtendedLocationArmOperation(_customLocationClientDiagnostics, Pipeline, _customLocationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletionResponse(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ArmOperation> DeleteAsync(bool waitForCompletion, CancellationToken cancellationToken = default) { using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocation.Delete"); scope.Start(); try { var response = await _customLocationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); var operation = new ExtendedLocationArmOperation(_customLocationClientDiagnostics, Pipeline, _customLocationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <CustomLocation> CreateOrUpdate(WaitUntil waitUntil, string resourceName, CustomLocationData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationCollection.CreateOrUpdate"); scope.Start(); try { var response = _customLocationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, resourceName, parameters, cancellationToken); var operation = new ExtendedLocationArmOperation <CustomLocation>(new CustomLocationOperationSource(Client), _customLocationClientDiagnostics, Pipeline, _customLocationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }