Managing long-running operations

This page describes how to manage the lifecycle of a Cloud Healthcare API long-running operation.

Long-running operations (LROs) are returned when method calls might take a long time to complete. The Cloud Healthcare API creates LROs for several methods. An example is the method to create a dataset, projects.locations.datasets.create. When projects.locations.datasets.create is called, the Cloud Healthcare API creates an LRO to track the dataset creation status. The Cloud Healthcare API provides operations APIs that let you check the status of LROs. You can also list LROs.

LROs are managed at the dataset level. If you are calling a method that returns an LRO, like projects.locations.datasets.dicomStores.import, then to view the LRO's status, make a request to the DICOM store's parent dataset.

In addition to the REST API, the following sources generate long-running operations when you call the methods listed in Methods that return a long-running operation:

You can manage your Cloud Healthcare API LROs using the Google Cloud Platform Console, the gcloud command-line tool, or the REST API.

Note that the record of an LRO is kept for approximately 30 days after the LRO finishes, meaning that you cannot view or list an LRO after that point.

Methods that return a long-running operation

The following methods return an LRO:

Dataset operations:

DICOM operations:

FHIR operations:

Getting details about a long-running operation

The following samples show how to get details about an LRO.

Note that the version of the Cloud Healthcare API shown in the response when getting details about an LRO will be the same as the API version of the method that initiated the LRO.

Console

After calling a method using either the gcloud tool or the API that returns an LRO, you can view details about the LRO in the GCP Console.

  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Click the name of the dataset containing the long-running operation you want to view.
  3. Click Operations.

A list of LROs in the dataset and their status displays. If the status of any operation is listed as "Errors", then click Errors to display the error details.

gcloud

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

Suppose that you receive the following response after calling gcloud alpha healthcare datasets deidentify:

Request issued for: [DATASET_ID]
Waiting for operation [OPERATION_ID] to complete...

The response shows that the Cloud Healthcare API created an LRO with an operation ID. The command continues to run until it finishes, at which point it outputs the following:

Request issued for: [DATASET_ID]
Waiting for operation [OPERATION_ID] to complete...done
name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID

To get details about an LRO, run the gcloud alpha healthcare operations describe command, specifying the dataset ID and the operation ID.

gcloud alpha healthcare operations describe OPERATION_ID --dataset=DATASET_ID

You can also retrieve the operation ID by listing long-running database operations.

If the request is successful, the command prompt displays the operation details:

done: true
metadata:
'@type': type.googleapis.com/google.cloud.healthcare.v1alpha2.OperationMetadata
apiMethodName: google.cloud.healthcare.v1alpha2.dataset.DatasetService.DeidentifyDataset
createTime: '2019-01-01T00:00:00Z'
endTime: '2019-01-01T00:00:00Z'
name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID
response:
'@type': type.googleapis.com/google.cloud.healthcare.v1alpha2.dataset.DeidentifySummary

API

To get the status of and view details about an LRO, use the projects.locations.datasets.operations.get method.

curl command

To get details about an LRO, make a GET request and provide the name of the dataset, the operation ID, and an access token.

Suppose that you receive the following response after calling projects.locations.datasets.deidentify:

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID"
}

The name value in the response shows that the Cloud Healthcare API created an LRO named projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID.

The following sample shows how to use a GET request to get details about an LRO using curl.

curl -X GET \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID"

You can also retrieve the LRO name by listing long-running database operations.

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format. When an LRO finishes, the done field will be set to true.

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.DeidentifyDataset",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME"
  },
  "done": true,
  "response": {
    "@type": "...",
    "successStoreCount": "SUCCESS_STORE_COUNT"
  }
}

To poll an LRO, repeatedly invoke the projects.locations.datasets.operations.get method until the operation finishes. Use a backoff between each poll request, such as 10 seconds.

PowerShell

To get details about an LRO, make a GET request and provide the name of the dataset, the operation ID, and an access token.

Suppose that you receive the following response after calling projects.locations.datasets.deidentify:

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID"
}

The name value in the response shows that the Cloud Healthcare API created an LRO named projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID.

The following sample shows how to use a GET request to get details about an LRO using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content

You can also retrieve the LRO name by listing long-running database operations.

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format. When an LRO finishes, the done field will be set to true.

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.DeidentifyDataset",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME"
  },
  "done": true,
  "response": {
    "@type": "...",
    "successStoreCount": "SUCCESS_STORE_COUNT"
  }
}

To poll an LRO, repeatedly invoke the projects.locations.datasets.operations.get method until the operation finishes. Use a backoff between each poll request, such as 10 seconds.

Listing long-running operations

The following samples show how to list the long-running operations in a dataset.

Console

After calling methods using gcloud tool or the API that return an LRO, you can view a list of LROs in the GCP Console.

  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Click the name of the dataset containing the long-running operation you want to view.
  3. Click Operations.

A list of LROs in the dataset and their status displays. If the status of any operation is listed as "Errors", then click Errors to display the error details.

gcloud

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

To list the LROs in a dataset, run the gcloud alpha healthcare operations list command.

gcloud alpha healthcare operations describe \
  --dataset=DATASET_ID \
  --location=REGION

If the request is successful, the command prompt lists the LROs:

ID                    LOCATION     DONE
OPERATION_ID          REGION       {TRUE|FALSE}
...

API

To list the LROs in a dataset, use the projects.locations.datasets.operations.list method.

curl command

To list the LROs in a dataset, make a GET request and provide the dataset name and an access token. The following sample shows a GET request using curl.

curl -X GET \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "operations": [
    {
      "name": "PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
        "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.DeidentifyDataset",
        "createTime": "CREATE_TIME",
        "endTime": "END_TIME"
      },
      "done": true,
      "response": {
        "@type": "...",
        "successStoreCount": "SUCCESS_STORE_COUNT"
      }
    },
    ...
  ]
}

PowerShell

To list the LROs in a dataset, make a GET request and provide the dataset name and an access token. The following sample shows a GET request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "operations": [
    {
      "name": "PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
        "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.DeidentifyDataset",
        "createTime": "CREATE_TIME",
        "endTime": "END_TIME"
      },
      "done": true,
      "response": {
        "@type": "...",
        "successStoreCount": "SUCCESS_STORE_COUNT"
      }
    },
    ...
  ]
}

¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...

Cloud Healthcare API