This page explains how to create, edit, view, and delete datasets. For an overview of datasets, see the Data model documentation.
Creating a dataset
To use the Cloud Healthcare API, you must create at least one dataset.
The following examples show how to create a dataset.
Console
- In the Cloud Console, go to the Datasets page.
- Click Create dataset.
- Choose a dataset identifier that's unique in your project and region. If the identifier is not unique, the dataset creation fails.
- Choose the region where the dataset permanently resides and then click Create.
The new dataset appears in the list.
gcloud
To create a dataset, run the
gcloud healthcare datasets create
command:
- The DATASET_ID must be unique within the region. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
- The region can be
us-central1
,us-west2
,europe-west2
,europe-west4
,europe-west6
,northamerica-northeast1
,southamerica-east1
,asia-east2
,asia-northeast1
,asia-southeast1
,australia-southeast1
, orus
. To use the default region for the project, omit the--location
option.
gcloud healthcare datasets create DATASET_ID \ --location=LOCATION
The command line displays the operation ID and, after the operation completes, a confirmation that the dataset was created:
Create request issued for: [DATASET_ID] Waiting for operation [projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID] to complete...done. Created dataset [DATASET_ID].
To view more details about the operation, run the gcloud healthcare operations describe
command, providing the OPERATION_ID from the response:
gcloud healthcare operations describe OPERATION_ID \ --dataset=DATASET_ID
The response includes done: true
:
done: true metadata: '@type': type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata apiMethodName: google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset createTime: 'CREATE_TIME' endTime: 'END_TIME' name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID response: '@type': type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID
API
To create a dataset, use the projects.locations.datasets.create
method.
curl
To create a dataset, make a POST
request and specify the following information:
- A name for the dataset. The dataset ID must be unique in its region. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
- An access token
The following sample shows a POST
request using curl
.
curl -X POST \ --data "" \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }
The response contains an operation name. To track the status of the operation
and view more details, use the
Operation get
method:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
If the request is successful, the server returns a response with the status of the operation in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata", "apiMethodName": "google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset", "createTime": "CREATE_TIME", "endTime": "END_TIME", "logsUrl": "https://console.cloud.google.com/logs/viewer/CLOUD_LOGGING_URL" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset", "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" } }
PowerShell
To create a dataset, make a POST
request and specify the following information:
- A name for the dataset. The dataset ID must be unique in its region. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
- An access token
The following sample shows a POST
request using Windows PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }
The response contains an operation name. To track the status of the operation
and view more details, use the
Operation get
method:
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content
If the request is successful, the server returns a response with the status of the operation in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata", "apiMethodName": "google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset", "createTime": "CREATE_TIME", "endTime": "END_TIME", "logsUrl": "https://console.cloud.google.com/logs/viewer/CLOUD_LOGGING_URL" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset", "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" } }
Go
Java
Node.js
Python
Editing a dataset
The following examples show how to edit an existing dataset.
Console
Cloud Console does not support editing a healthcare dataset. Instead,
use curl
, Windows PowerShell, or your preferred language.
gcloud
To edit a dataset, run the
gcloud healthcare datasets update
command, specifying the new time zone. For example, you can set the time zone
to "Canada/Eastern".
gcloud healthcare datasets update DATASET_ID \ --location=LOCATION \ --time-zone=TIME_ZONE
If the request is successful, the command prompt displays the operation and dataset details:
Updated dataset [DATASET_ID]. name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID timeZone: TIME_ZONE
API
To edit a dataset, use the projects.locations.datasets.patch
method.
curl
To edit a dataset, make a PATCH
request and specify the following information:
- The name of the dataset
- The metadata to update
- An update mask
- An access token
The following sample shows how to update the time zone by making a PATCH
request using curl
.
Replace the TIMEZONE
variable with a value, such as UTC
. The time zone value
must be in uppercase.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'timeZone': 'TIMEZONE' }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID?updateMask=timeZone"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" "timeZone": "TIMEZONE" }
PowerShell
To edit a dataset, make a PATCH
request and specify the following information:
- The name of the dataset
- The metadata to update
- An update mask
- An access token
The following sample shows how to update the time zone by making a PATCH
request using Windows PowerShell.
Replace the TIMEZONE
variable with a value, such as UTC
. The time zone value
must be in uppercase.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Patch ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'timeZone': 'TIMEZONE' }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID?updateMask=timeZone" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" "timeZone": "TIMEZONE" }
Go
Java
Node.js
Python
Getting dataset details
The following examples show how to get details about a dataset.
Console
To view the data stores in a dataset:
- In the Cloud Console, go to the Datasets page.
- Click the ID of the dataset whose data stores you want to view.
gcloud
To view details about a dataset, run the
gcloud healthcare datasets describe
command:
gcloud healthcare datasets describe DATASET_ID \ --location=LOCATION
If the request is successful, the command prompt displays the dataset details:
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID timeZone: TIME_ZONE
API
To get details about a dataset, use the projects.locations.datasets.get
method.
curl
To get details about a dataset, make a GET
request and specify the following
information:
- The name of the dataset
- An access token
The following sample shows a GET
request using curl
.
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" "timeZone": "UTC" }
PowerShell
To get details about a dataset, make a GET
request and specify the following
information:
- The name of the dataset
- An access token
The following sample shows a GET
request using Windows PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" "timeZone": "UTC" }
Go
Java
Node.js
Python
The following examples show how to list the datasets in your project.
Console
To list the datasets in your project, in the Cloud Console, go to the Healthcare Datasets page.
gcloud
To list the datasets in your project, run the
gcloud healthcare datasets list
command:
gcloud healthcare datasets list
If the request is successful, the command prompt lists the datasets:
ID LOCATION TIMEZONE DATASET_ID LOCATION TIME_ZONE
API
To list the datasets in your project, use the projects.locations.datasets.list
method.
curl
To list the datasets in your project, make a GET
request and specify the
following information:
- The name of your project
- An access token
The following sample shows a GET
request using curl
.
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets"
If the request is successful, the server returns the response in JSON format:
{ "datasets": [ { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID", "timeZone": "UTC" }, { ... ... } ] }
PowerShell
To list the datasets in your project, make a GET
request and specify the
following information:
- The name of your project
- An access token
The following sample shows a GET
request using Windows PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{ "datasets": [ { "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID", "timeZone": "UTC" }, { ... ... } ] }
Go
Java
Node.js
Python
Deleting a dataset
The following examples show how to delete a dataset.
Console
To delete a dataset:
- In the Cloud Console, go to the Datasets page.
- Select the dataset that you want to delete and then click Delete.
- To confirm, type the dataset identifier and then click Delete.
gcloud
To delete a dataset, run the
gcloud healthcare datasets delete
command:
Run the
delete
command:gcloud healthcare datasets delete DATASET_ID \ --location=LOCATION
To confirm, type Y.
If the request is successful, the command prompt displays:
Deleted dataset [DATASET_ID]
API
To delete a dataset, use the projects.locations.datasets.delete
method.
curl
To delete a dataset, make a DELETE
request and specify the following information:
- The name of the dataset
- An access token
The following sample shows a DELETE
request using curl
.
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
If the request is successful, the server returns the response in JSON format:
{}
PowerShell
To delete a dataset, make a DELETE
request and specify the following information:
- The name of the dataset
- An access token
The following sample shows a DELETE
request using Windows PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Delete ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format:
{}
Go
Java
Node.js
Python
What's next
- De-identify sensitive data
- Create and manage DICOM stores
- Create and manage FHIR stores
- Create and manage HL7v2 stores