cancel method

Future<Empty> cancel(
  1. GoogleLongrunningCancelOperationRequest request,
  2. String name, {
  3. String? $fields,
})

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

request - The metadata request object.

Request parameters:

name - The name of the operation resource to be cancelled. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/operations/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Empty.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Empty> cancel(
  GoogleLongrunningCancelOperationRequest request,
  core.String name, {
  core.String? $fields,
}) async {
  final _body = convert.json.encode(request);
  final _queryParams = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final _url = 'v1alpha1/' + core.Uri.encodeFull('$name') + ':cancel';

  final _response = await _requester.request(
    _url,
    'POST',
    body: _body,
    queryParams: _queryParams,
  );
  return Empty.fromJson(_response as core.Map<core.String, core.dynamic>);
}