public async virtual Task <RestorePointCreateOperation> CreateOrUpdateAsync(string restorePointName, RestorePointData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (restorePointName == null) { throw new ArgumentNullException(nameof(restorePointName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("RestorePointContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateAsync(Id.ResourceGroupName, Id.Name, restorePointName, parameters, cancellationToken).ConfigureAwait(false); var operation = new RestorePointCreateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateRequest(Id.ResourceGroupName, Id.Name, restorePointName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ArmOperation <RestorePoint> > CreateOrUpdateAsync(bool waitForCompletion, string restorePointName, RestorePointData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(restorePointName, nameof(restorePointName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _restorePointClientDiagnostics.CreateScope("RestorePointCollection.CreateOrUpdate"); scope.Start(); try { var response = await _restorePointRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restorePointName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <RestorePoint>(new RestorePointOperationSource(Client), _restorePointClientDiagnostics, Pipeline, _restorePointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restorePointName, parameters).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <RestorePointResource> > UpdateAsync(WaitUntil waitUntil, RestorePointData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _restorePointClientDiagnostics.CreateScope("RestorePointResource.Update"); scope.Start(); try { var response = await _restorePointRestClient.CreateAsync(Id.Parent.Name, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <RestorePointResource>(new RestorePointOperationSource(Client), _restorePointClientDiagnostics, Pipeline, _restorePointRestClient.CreateCreateRequest(Id.Parent.Name, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }