Long-running operations (Advanced)

Some methods of the Translation API return a long-running operation. These methods are asynchronous, and the operation may not be completed when the method returns a response. You can check on the status of an operation, or cancel an operation.

Operation status

The following shows how to poll an operation's status.

REST & CMD LINE

Call the get method for the operation resource.

Before using any of the request data below, make the following replacements:

  • project-number-or-id: your GCP project number, or ID
  • location-id: the location you chose for your Cloud Storage bucket
  • operation-id: operation ID you received above

HTTP method and URL:

GET https://translation.googleapis.com/v3/projects/project-number-or-id/locations/location-id/operations/operation-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/project-number/locations/location-id/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.translation.v3.SomeOperationMetadata",
    "state": "SUCCEEDED",
    "submitTime": "2019-11-27T22:59:40Z"
  }
}

When the operation has completed, a state value of SUCCEEDED is returned.

Operation cancelation

The following shows how to cancel an operation.

REST & CMD LINE

Call the cancel method on the operation resource.

Before using any of the request data below, make the following replacements:

  • project-number: your GCP project number, or ID
  • location-id: the location you chose for your Cloud Storage bucket
  • operation-id: operation ID you received above

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/project-number-or-id/locations/location-id/operations/operation-id:cancel

To send your request, expand one of these options:

You should receive a successful status code (2xx) and an empty response.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Translation
Need help? Visit our support page.