public virtual SnapshotUpdateOperation Update(SnapshotUpdate snapshot, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } using var scope = _clientDiagnostics.CreateScope("Snapshot.Update"); scope.Start(); try { var response = _restClient.Update(Id.ResourceGroupName, Id.Name, snapshot, cancellationToken); var operation = new SnapshotUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateUpdateRequest(Id.ResourceGroupName, Id.Name, snapshot).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <SnapshotUpdateOperation> UpdateAsync(SnapshotUpdate snapshot, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } using var scope = _clientDiagnostics.CreateScope("Snapshot.Update"); scope.Start(); try { var response = await _snapshotsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, snapshot, cancellationToken).ConfigureAwait(false); var operation = new SnapshotUpdateOperation(this, _clientDiagnostics, Pipeline, _snapshotsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, snapshot).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }