Creating and managing annotation stores

This page explains how to create, label, view, and delete annotation stores. For an overview of annotation stores and annotation records, see Annotations.

Creating an annotation store

Before you can create an annotation store, you need to create a dataset.

The following samples show how to create an annotation store.

gcloud

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

To create an annotation store, run the gcloud alpha healthcare annotation-stores create command. The annotation store ID must be unique in the dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.

The following sample shows how to create an annotation store:

gcloud alpha healthcare annotation-stores create ANNOTATION_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION 

If the request is successful, the command prompt displays the following message:

Created annotationStore [ANNOTATION_STORE_ID].

API

To create an annotation store, use the projects.locations.datasets.annotationStores.create method.

curl command

To create an annotation store, make a POST request and provide the name of the parent dataset, the name of the annotation store, and an access token. The following sample shows a POST request using curl. Set a name for the annotation store in the ANNOTATION_STORE_ID variable. The annotation store must be unique in its parent dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.

curl -X POST \
    --data "" \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://healthcare.googleapis.com/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores?annotationStoreId=ANNOTATION_STORE_ID"

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

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
}

PowerShell

To create an annotation store, make a POST request and provide the name of the parent dataset, the name of the annotation store, and an access token. The following sample shows a POST request using Windows PowerShell. Set a name for the annotation store in the ANNOTATION_STORE_ID variable. The annotation store must be unique in its parent dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.

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

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Uri "https://healthcare.googleapis.com/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores?annotationStoreId=ANNOTATION_STORE_ID" | 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
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
}

Labeling an annotation store

You can add one or more key-value labels to an annotation store. One use case for using annotation stores could be adding labels and tags for annotation records relating to text or images.

The following samples show how to add labels to an annotation store.

API

To add labels to an annotation store, use the projects.locations.datasets.annotationStores.patch method.

curl command

To label an annotation store, make a PATCH request and provide the name of the parent dataset, the name of the annotation store, the label data to update, an update mask, and an access token. The following sample shows a PATCH request using curl.

curl -X PATCH \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    --data "{
      'labels': {
        'KEY': 'VALUE'
      }
    }" \
    "https://healthcare.googleapis.com/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID?updateMask=labels"

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

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID",
  "labels": {
    "KEY": "VALUE"
  }
}

PowerShell

To label an annotation store, make a PATCH request and provide the name of the parent dataset, the name of the annotation store, the label data to update, an update mask, and an access token. The following sample shows a PATCH request using Windows PowerShell.

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

Invoke-WebRequest `
  -Method Patch `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body "{
      'labels': {
        'KEY': 'VALUE'
      }
  }" `
  -Uri "https://healthcare.googleapis.com/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID?updateMask=labels" | 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
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID",
  "labels": {
    "KEY": "VALUE"
  }
}

Getting annotation store details

The following samples show how to get details about an annotation store.

gcloud

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

To view details about an annotation store, run the gcloud alpha healthcare annotation-stores describe command.

The following sample shows how to get details about an annotation store:

gcloud alpha healthcare annotation-stores describe ANNOTATION_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION 

If the request is successful, the command prompt displays the annotation store details:

name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotation-stores/ANNOTATION_STORE_ID

API

To get details about an annotation store, use the projects.locations.datasets.annotationStores.get method.

curl command

To get details about an annotation store, make a GET request and provide the name of the parent dataset, the name of the annotation store, 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/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"

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

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
}

If you configured any fields in the AnnotationStore resource, they also appear in the response.

PowerShell

To get details about an annotation store, make a GET request and provide the name of the parent dataset, the name of the annotation store, 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/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID" | 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
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
}

If you configured any fields in the AnnotationStore resource, they also appear in the response.

Listing annotation stores in a dataset

The following samples show how to list the annotation stores in a dataset.

gcloud

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

To list the annotation stores in a dataset, run the gcloud alpha healthcare annotation-stores list command.

The following sample shows how to list the annotation stores in a dataset:

gcloud alpha healthcare annotation-stores list --dataset=DATASET_ID 

If the request is successful, the command prompt lists the annotation stores:

ID                   LOCATION     TOPIC
ANNOTATION_STORE_ID  us-central1

API

To list the annotation stores in a dataset, use the projects.locations.datasets.annotationStores.list method.

curl command

To list the annotation stores in a dataset, make a GET request and provide the name of the parent dataset 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/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores"

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

200 OK
{
  "annotationStores": [
    {
      "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
    },
    {
      ...
    }
  ]
}

If you configured any fields in the AnnotationStore resource, they also appear in the response.

PowerShell

To list the annotation stores in a dataset, make a GET request and provide the name of the parent dataset 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/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores" | 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
{
  "annotationStores": [
    {
      "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID"
    },
    {
      ...
    }
  ]
}

If you configured any fields in the AnnotationStore resource, they also appear in the response.

Deleting an annotation store

The following samples show how to delete an annotation store.

gcloud

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

To delete an annotation store, run the gcloud alpha healthcare annotation-stores delete command:

  1. Run the delete command.

    gcloud alpha healthcare annotation-stores delete ANNOTATION_STORE_ID \
      --dataset=DATASET_ID \
      --location=REGION 
    
  2. To confirm, type Y.

If the request is successful, the command prompt displays the following message:

Deleted annotationStore [ANNOTATION_STORE_ID]

API

To delete an annotation store, use the projects.locations.datasets.annotationStores.delete method.

curl command

To delete an annotation store, make a DELETE request and provide the name of the parent dataset, the name of the annotation store, and an access token. The following sample shows a DELETE request using curl.

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

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

200 OK
{}

PowerShell

To delete an annotation store, make a DELETE request and provide the name of the parent dataset, the name of the annotation store, and an access token. The following sample shows a DELETE request using Windows PowerShell.

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

Invoke-WebRequest `
  -Method Delete `
  -Uri "https://healthcare.googleapis.com/v1alpha2/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/annotationStores/ANNOTATION_STORE_ID" | Select-Object -Expand Content

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

200 OK
{}

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Cloud Healthcare API