public virtual async Task <ArmOperation <CommandOutput> > InvokeCommandAsync(WaitUntil waitUntil, CommandPostBody body, CancellationToken cancellationToken = default) { Argument.AssertNotNull(body, nameof(body)); using var scope = _clusterResourceCassandraClustersClientDiagnostics.CreateScope("ClusterResource.InvokeCommand"); scope.Start(); try { var response = await _clusterResourceCassandraClustersRestClient.InvokeCommandAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); var operation = new CosmosDBArmOperation <CommandOutput>(new CommandOutputOperationSource(), _clusterResourceCassandraClustersClientDiagnostics, Pipeline, _clusterResourceCassandraClustersRestClient.CreateInvokeCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ClusterResourceInvokeCommandOperation> InvokeCommandAsync(bool waitForCompletion, CommandPostBody body, CancellationToken cancellationToken = default) { if (body == null) { throw new ArgumentNullException(nameof(body)); } using var scope = _clusterResourceCassandraClustersClientDiagnostics.CreateScope("ClusterResource.InvokeCommand"); scope.Start(); try { var response = await _clusterResourceCassandraClustersRestClient.InvokeCommandAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body, cancellationToken).ConfigureAwait(false); var operation = new ClusterResourceInvokeCommandOperation(_clusterResourceCassandraClustersClientDiagnostics, Pipeline, _clusterResourceCassandraClustersRestClient.CreateInvokeCommandRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, body).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }