This page shows how to create and manage consent stores.
The Consent Management API is a tool for recording user consents, managing actions based on those consents, and maintaining associated documentation and records.
The organization using the Consent Management API is responsible for obtaining and maintaining the required consents necessary to permit the processing of any data through the Consent Management API.
The Consent Management API fulfills the role of a policy decision point. Policy enforcement must be implemented in the application or through a proxy. For more information, see Attribute-based access control.
Set up permissions
To use the features in this guide, you must have the
roles/healthcare.consentStoreAdmin
role. However, to perform additional useful operations with the
Consent Management API, additional permissions might be required. See
Access control
for more details.
Creating a consent store
Consent stores are the top-level resources that contain all information related to the configuration and operation of the Consent Management API. Consent stores belong to a Cloud Healthcare API dataset, which is assigned to a region when it is created. This region is the geographic location in which your consent store operates.
Console
In the Google Cloud console, go to the Datasets page.
Select the dataset where you want to create a consent store.
Click Create data store.
Select Consent as the data store type.
In the ID field, enter a name of your choice that's unique in your dataset. If the name is not unique, the store creation fails.
Click Next.
In Configure your Consent Store select one of the following options to determine when consents in your store expire:
- No default expiration time means that, by default, consents do not expire.
- Default expiration time means that, by default, consents expire after the number of days defined in the Expiration time field.
To allow new consent resources to be created using
consentStores.patch
, click Allow consent creation on update.Click Next.
Click Add label to define optional key and value labels to organize your Google Cloud resources.
Click Create.
gcloud
To create a consent store, run the gcloud healthcare consent-stores create
command.
Before using any of the command data below, make the following replacements:
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID:
an identifier for the consent store. The consent store ID must have the following:
- A unique ID in its dataset
- A Unicode string of 1-256 characters consisting of the following:
- Numbers
- Letters
- Underscores
- Dashes
- Periods
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud healthcare consent-stores create CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
Windows (PowerShell)
gcloud healthcare consent-stores create CONSENT_STORE_ID ` --dataset=DATASET_ID ` --location=LOCATION
Windows (cmd.exe)
gcloud healthcare consent-stores create CONSENT_STORE_ID ^ --dataset=DATASET_ID ^ --location=LOCATION
You should receive a response similar to the following:
Response
Created consentStore [CONSENT_STORE_ID].
REST
To create a consent store, use the projects.locations.datasets.consentStores.create
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID:
an identifier for the consent store. The consent store ID must have the following:
- A unique ID in its dataset
- A Unicode string of 1-256 characters consisting of the following:
- Numbers
- Letters
- Underscores
- Dashes
- Periods
- DEFAULT_CONSENT_EXPIRATION_DURATION: an optional default time, specified in seconds, until consents created in this store expire. This duration must be at least 24 hours (86400 seconds) and must be in the format
DEFAULT_CONSENT_EXPIRATION_DURATIONs
. - ENABLE_CONSENT_CREATE_ON_UPDATE: an optional boolean that determines whether requests to patch a non-existent consent resource using
consentStores.patch
should create that resource. Default isFALSE
.
Request JSON body:
{ "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs", "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE" }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs", "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE" } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores?consentStoreId=CONSENT_STORE_ID"
PowerShell
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs", "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE" } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores?consentStoreId=CONSENT_STORE_ID" | Select-Object -Expand Content
APIs Explorer
Copy the request body and open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Paste the request body in this tool, complete any other required fields, and click Execute.
You should receive a JSON response similar to the following:
Node.js
Python
Editing a consent store
After you create a consent store, you can update it. For example, you can add or remove labels to organize your consent stores.
The following samples show how to edit a consent store.
Console
To edit a consent store, complete the following steps:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset containing the consent store you want to edit.
- In the Data stores list, click the data store you want to edit.
- To edit the consent store's configuration, click the edit icon next to Consent Store Configuration.
For more information on the consent store's configuration options, see Creating a consent store. - To add one or more labels to the store, click Using resource labels. Labels, click Add label, and enter the key/value label. For more information on resource labels, see
- Click Save.
gcloud
To edit a consent store, run the gcloud healthcare consent-stores update
command.
Before using any of the command data below, make the following replacements:
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
- KEY: the key in a key-value pair used to organize consent stores. See
labels
for label requirements and limitations. - VALUE: the value in a key-value pair used to organize consent stores. See
labels
for label requirements and limitations.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud healthcare consent-stores update CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION \ --update-labels=KEY=VALUE
Windows (PowerShell)
gcloud healthcare consent-stores update CONSENT_STORE_ID ` --dataset=DATASET_ID ` --location=LOCATION ` --update-labels=KEY=VALUE
Windows (cmd.exe)
gcloud healthcare consent-stores update CONSENT_STORE_ID ^ --dataset=DATASET_ID ^ --location=LOCATION ^ --update-labels=KEY=VALUE
You should receive a response similar to the following:
Response
Updated consentStore [CONSENT_STORE_ID]. labels: KEY: VALUE name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID
REST
To edit a consent store, use the projects.locations.datasets.consentStores.patch
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
- KEY: the key in a key-value pair used to organize consent stores. See
labels
for label requirements and limitations. - VALUE: the value in a key-value pair used to organize consent stores. See
labels
for label requirements and limitations.
Request JSON body:
{ "labels": { "KEY": "VALUE" } }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "labels": { "KEY": "VALUE" } } EOF
Then execute the following command to send your REST request:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID?updateMask=labels"
PowerShell
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "labels": { "KEY": "VALUE" } } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID?updateMask=labels" | Select-Object -Expand Content
APIs Explorer
Copy the request body and open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Paste the request body in this tool, complete any other required fields, and click Execute.
You should receive a JSON response similar to the following:
Node.js
Python
Getting consent store details
The following samples show how to get details about a consent store.
Console
To view a consent store's details:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset containing the consent store you want to view.
- Click the name of the consent store.
The Datastore details page displays the details of the selected a consent store.
gcloud
To get details about a consent store, run the gcloud healthcare consent-stores describe
command.
Before using any of the command data below, make the following replacements:
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud healthcare consent-stores describe CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
Windows (PowerShell)
gcloud healthcare consent-stores describe CONSENT_STORE_ID ` --dataset=DATASET_ID ` --location=LOCATION
Windows (cmd.exe)
gcloud healthcare consent-stores describe CONSENT_STORE_ID ^ --dataset=DATASET_ID ^ --location=LOCATION
ConsentStore
resource, they also appear in the response.
Response
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID
REST
To get details about a consent store, use the projects.locations.datasets.consentStores.get
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID"
PowerShell
Execute the following command:
$cred = gcloud auth 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/consentStores/CONSENT_STORE_ID" | Select-Object -Expand Content
APIs Explorer
Open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
ConsentStore
resource, they also appear in the response.
Node.js
Python
Listing the consent stores in a dataset
The following samples show how to list the consent stores in a dataset.
Console
To view the data stores in a dataset:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset containing the data store you want to view.
gcloud
To list the consent stores in a dataset, run the gcloud healthcare consent-stores list
command.
Before using any of the command data below, make the following replacements:
- DATASET_ID: the consent store's parent dataset
- LOCATION: the dataset location
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud healthcare consent-stores list --dataset=DATASET_ID \ --location=LOCATION
Windows (PowerShell)
gcloud healthcare consent-stores list --dataset=DATASET_ID ` --location=LOCATION
Windows (cmd.exe)
gcloud healthcare consent-stores list --dataset=DATASET_ID ^ --location=LOCATION
ConsentStore
resource, they also appear in the response.
ID LABELS LOCATION CONSENT_STORE_ID LOCATION
REST
To list the consent stores in a dataset, use the projects.locations.datasets.consentStores.list
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- DATASET_ID: the consent store's parent dataset
- LOCATION: the dataset location
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores"
PowerShell
Execute the following command:
$cred = gcloud auth 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/consentStores" | Select-Object -Expand Content
APIs Explorer
Open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
ConsentStore
resource, they also appear in the response.
Node.js
Python
Deleting a consent store
The following samples show how to delete a consent store.
Console
To delete a data store:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset containing the data store you want to delete.
- Choose Delete from the Actions drop-down list for the data store that you want to delete.
- To confirm, type the data store name and then click Delete.
gcloud
To delete a consent store, run the gcloud healthcare consent-stores delete
command.
Before using any of the command data below, make the following replacements:
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud healthcare consent-stores delete CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
Windows (PowerShell)
gcloud healthcare consent-stores delete CONSENT_STORE_ID ` --dataset=DATASET_ID ` --location=LOCATION
Windows (cmd.exe)
gcloud healthcare consent-stores delete CONSENT_STORE_ID ^ --dataset=DATASET_ID ^ --location=LOCATION
Deleted consentStore [CONSENT_STORE_ID].
REST
To delete a consent store, use the projects.locations.datasets.consentStores.delete
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the consent store's parent dataset
- CONSENT_STORE_ID: the consent store ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID"
PowerShell
Execute the following command:
$cred = gcloud auth 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/consentStores/CONSENT_STORE_ID" | Select-Object -Expand Content
APIs Explorer
Open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
Node.js
Python
Audit logging
The Consent Management API writes the following types of audit logs:
- Admin Activity: record operations that modify the configuration or metadata of a resource. You can't disable Admin Activity audit logs.
- Data Access: contain API calls that read the configuration or metadata of resources, as well as external API calls that create, modify, or read customer-provided resource data. These logs must be enabled. For example, Data Access audit logs can be used to log what service made an access determination request, what information was provided in that request, and how the API responded to that request. For more information on Data Access audit logs, see Configuring Data Access audit logs. For more information about audit logging in the Cloud Healthcare API, visit Viewing Cloud Audit Logs.
For more information on audit logs for the Consent Management API, see Viewing Cloud Audit Logs.