Consent-Speicher erstellen und verwalten

Auf dieser Seite wird beschrieben, wie Sie Einwilligungsspeicher erstellen und verwalten.

Die Consent Management API ist ein Tool zum Aufzeichnen von Nutzereinwilligungen, zum Verwalten von Aktionen auf Grundlage dieser Einwilligungen und zum Verwalten der zugehörigen Dokumentation und der Datensätze.

Die Organisation, die die Consent Management API verwendet, ist für Erhalt und Pflege der erforderlichen Einwilligungen verantwortlich, um die Verarbeitung von Daten über die Consent Management API zu ermöglichen.

Die Consent Management API übernimmt die Rolle eines Richtlinienentscheidungspunkts. Die Richtlinienerzwingung muss in der Anwendung oder über einen Proxy implementiert werden. Weitere Informationen finden Sie unter Rollenbasierte Zugriffssteuerung.

Berechtigungen einrichten

Für die Verwendung dieser Features benötigen Sie die roles/healthcare.consentStoreAdmin-Rolle. Möglicherweise sind jedoch zusätzliche Berechtigungen erforderlich, um weitere nützliche Vorgänge mit der Consent Management API auszuführen. Weitere Informationen finden Sie unter Zugriffssteuerung.

Einwilligungsspeicher sind die Ressource auf oberster Ebene, die alle Informationen über die Konfiguration und den Betrieb der Consent Management API enthalten. Consent-Speicher gehören zu einem Cloud Healthcare API-Dataset, das einer Region bei der Erstellung zugewiesen wird. Diese Region ist der geografische Standort, an dem Ihr Consent-Speicher betrieben wird.

  1. Rufen Sie in der Google Cloud Console die Seite Datasets auf.

    Zu „Datasets“

  2. Wählen Sie das Dataset, in dem Sie einen Einwilligungsspeicher erstellen möchten.

  3. Klicken Sie auf Datenspeicher erstellen.

  4. Wählen Sie Einwilligung als Datenspeichertyp aus.

  5. Geben Sie in das Feld ID einen Namen Ihrer Wahl ein, der in Ihrem Dataset einmalig ist. Wenn der Name nicht einmalig ist, schlägt die Erstellung des Speichers fehl.

  6. Klicken Sie auf Next (Weiter).

  7. Wählen Sie unter Einwilligungsspeicher konfigurieren eine der folgenden Optionen aus, um festzulegen, wann die Einwilligungen in Ihrem Speicher ablaufen:

    • Keine Standardablaufzeit bedeutet, dass Einwilligungen standardmäßig nicht ablaufen.
    • Standardablaufzeit bedeutet, dass Einwilligungen standardmäßig nach der im Feld Ablaufzeit definierten Anzahl an Tagen ablaufen.
  8. Wenn Sie zulassen möchten, dass neue Einwilligungsressourcen mit consentStores.patcherstellt werden, klicken Sie auf Zustimmungserstellung bei Aktualisierung zulassen.

  9. Klicken Sie auf Next (Weiter).

  10. Klicken Sie auf Label hinzufügen, um optionale Label für Schlüssel und Werte zum Organisieren Ihrer Google Cloud-Ressourcen zu definieren.

  11. Klicken Sie auf Erstellen.

Führen Sie den gcloud healthcare consent-stores create-Befehl aus, um einen Einwilligungsspeicher zu erstellen.

Bevor Sie die folgenden Befehlsdaten verwenden, ersetzen Sie die folgenden Werte:

  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist eine Kennzeichnung für den Einwilligungsspeicher Die Einwilligungsspeicher-ID muss Folgendes enthalten:
    • Eine im eigenen Dataset eindeutige ID
    • Einen Unicode-String mit 1 bis 256 Zeichen, der Folgendes umfasst:
      • Nummern
      • Buchstaben
      • Unterstriche
      • Bindestriche
      • Punkte

Führen Sie den folgenden Befehl aus:

Linux, macOS oder 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

Sie sollten eine Antwort ähnlich der folgenden erhalten:

Antwort

Created consentStore [CONSENT_STORE_ID].

Verwenden Sie zum Erstellen eines Einwilligungsspeichers die Methode projects.locations.datasets.consentStores.create.

Bevor Sie die Anfragedaten verwenden, ersetzen Sie die folgenden Werte:

  • PROJECT_ID ist die ID Ihres Google Cloud-Projekts
  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist eine Kennzeichnung für den Einwilligungsspeicher Die Einwilligungsspeicher-ID muss Folgendes enthalten:
    • Eine im eigenen Dataset eindeutige ID
    • Einen Unicode-String mit 1 bis 256 Zeichen, der Folgendes umfasst:
      • Nummern
      • Buchstaben
      • Unterstriche
      • Bindestriche
      • Punkte
  • DEFAULT_CONSENT_EXPIRATION_DURATION ist eine optionale Standardzeit in Sekunden, die verstreichen muss, bevor die in diesem Speicher erstellten Einwilligungen ablaufen. Diese Dauer muss mindestens 24 Stunden (86.400 Sekunden) betragen und das Format DEFAULT_CONSENT_EXPIRATION_DURATIONs haben.
  • ENABLE_CONSENT_CREATE_ON_UPDATE ist ein optionaler boolescher Wert, der festlegt, ob Anfragen zum Patchen einer nicht vorhandenen Einwilligungsressource mit consentStores.patch diese Ressource erstellen können. Der Standardwert ist FALSE.

JSON-Text anfordern:

{
  "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs",
  "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE"
}

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json. Führen Sie folgenden Befehl im Terminal aus, um diese Datei im aktuellen Verzeichnis zu erstellen oder zu überschreiben:

cat > request.json << 'EOF'
{
  "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs",
  "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE"
}
EOF

Führen Sie dann folgenden Befehl aus, um Ihre REST-Anfrage zu senden:

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

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json. Führen Sie folgenden Befehl im Terminal aus, um diese Datei im aktuellen Verzeichnis zu erstellen oder zu überschreiben:

@'
{
  "defaultConsentTtl": "DEFAULT_CONSENT_EXPIRATION_DURATIONs",
  "enableConsentCreateOnUpdate": "ENABLE_CONSENT_CREATE_ON_UPDATE"
}
'@  | Out-File -FilePath request.json -Encoding utf8

Führen Sie dann folgenden Befehl aus, um Ihre REST-Anfrage zu senden:

$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

Kopieren Sie den Anfragetext und öffnen Sie die Referenzseite für Methoden. Der API Explorer wird rechts auf der Seite geöffnet. Sie können mit diesem Tool interagieren, um Anfragen zu senden. Fügen Sie den Anfragetext in dieses Tool ein, füllen Sie alle Pflichtfelder aus und klicken Sie auf Ausführen.

Sie sollten in etwa folgende JSON-Antwort erhalten:

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const createConsentStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const consentStoreId = 'my-consent-store';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {parent, consentStoreId};

  await healthcare.projects.locations.datasets.consentStores.create(request);
  console.log(`Created consent store: ${consentStoreId}`);
};

createConsentStore();
def create_consent_store(
    project_id: str, location: str, dataset_id: str, consent_store_id: str
):
    """Creates a new consent store within the parent dataset.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/consent
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the consent store's parent dataset ID
    # consent_store_id = 'my-consent-store'  # replace with the consent store's ID
    consent_store_parent = (
        f"projects/{project_id}/locations/{location}/datasets/{dataset_id}"
    )

    request = (
        client.projects()
        .locations()
        .datasets()
        .consentStores()
        .create(parent=consent_store_parent, body={}, consentStoreId=consent_store_id)
    )

    response = request.execute()
    print(f"Created consent store: {consent_store_id}")
    return response

Nachdem Sie einen Einwilligungsspeicher erstellt haben, können Sie ihn aktualisieren. Sie können beispielsweise Labels hinzufügen oder entfernen, um Ihre Einwilligungsspeicher zu organisieren.

In folgenden Beispielen wird gezeigt, wie Sie einen Einwilligungsspeicher bearbeiten.

Führen Sie folgende Schritte aus, um einen Einwilligungsspeicher zu bearbeiten:

  1. Rufen Sie in der Google Cloud Console die Seite Datasets auf.

    Zu „Datasets“

  2. Wählen Sie das Dataset aus, das den Einwilligungsspeicher enthält, den Sie bearbeiten möchten.
  3. Klicken Sie in der Liste Datenspeicher auf den Datenspeicher, den Sie bearbeiten möchten.
  4. Klicken Sie zum Bearbeiten der Konfiguration des Einwilligungsspeichers neben Konfiguration für Einwilligungsspeicher auf das Symbol "Bearbeiten".

    Weitere Informationen zu den Konfigurationsoptionen des Einwilligungsspeichers finden Sie unter Einwilligungsspeicher erstellen
  5. Um dem Speicher ein oder mehrere Labels hinzuzufügen, klicken Sie auf Labels und auf Label hinzufügen. Geben Sie dann das Schlüssel/Wert-Label ein. Weitere Informationen zu Ressourcenlabel finden Sie unter Ressourcenlabel verwenden.
  6. Klicken Sie auf Speichern.

Führen Sie den gcloud healthcare consent-stores update-Befehl aus, um einen Einwilligungsspeicher zu bearbeiten.

Bevor Sie die folgenden Befehlsdaten verwenden, ersetzen Sie die folgenden Werte:

  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID
  • KEY ist der Schlüssel in einem Schlüssel/Wert-Paar, mit dem Einwilligungsspeicher organisiert werden. Informationen zu Anforderungen und Einschränkungen für Labels finden Sie unter labels.
  • VALUE ist der Wert in einem Schlüssel/Wert-Paar, mit dem Einwilligungsspeicher organisiert werden. Informationen zu Anforderungen und Einschränkungen für Labels finden Sie unter labels.

Führen Sie den folgenden Befehl aus:

Linux, macOS oder 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

Sie sollten eine Antwort ähnlich der folgenden erhalten:

Antwort

Updated consentStore [CONSENT_STORE_ID].
labels:
  KEY: VALUE
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID

Zum Bearbeiten eines Einwilligungsspeichers verwenden Sie die Methode projects.locations.datasets.consentStores.patch.

Bevor Sie die Anfragedaten verwenden, ersetzen Sie die folgenden Werte:

  • PROJECT_ID ist die ID Ihres Google Cloud-Projekts
  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID
  • KEY ist der Schlüssel in einem Schlüssel/Wert-Paar, mit dem Einwilligungsspeicher organisiert werden. Informationen zu Anforderungen und Einschränkungen für Labels finden Sie unter labels.
  • VALUE ist der Wert in einem Schlüssel/Wert-Paar, mit dem Einwilligungsspeicher organisiert werden. Informationen zu Anforderungen und Einschränkungen für Labels finden Sie unter labels.

JSON-Text anfordern:

{
  "labels": {
    "KEY": "VALUE"
  }
}

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json. Führen Sie folgenden Befehl im Terminal aus, um diese Datei im aktuellen Verzeichnis zu erstellen oder zu überschreiben:

cat > request.json << 'EOF'
{
  "labels": {
    "KEY": "VALUE"
  }
}
EOF

Führen Sie dann folgenden Befehl aus, um Ihre REST-Anfrage zu senden:

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

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json. Führen Sie folgenden Befehl im Terminal aus, um diese Datei im aktuellen Verzeichnis zu erstellen oder zu überschreiben:

@'
{
  "labels": {
    "KEY": "VALUE"
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

Führen Sie dann folgenden Befehl aus, um Ihre REST-Anfrage zu senden:

$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

Kopieren Sie den Anfragetext und öffnen Sie die Referenzseite für Methoden. Der API Explorer wird rechts auf der Seite geöffnet. Sie können mit diesem Tool interagieren, um Anfragen zu senden. Fügen Sie den Anfragetext in dieses Tool ein, füllen Sie alle Pflichtfelder aus und klicken Sie auf Ausführen.

Sie sollten in etwa folgende JSON-Antwort erhalten:

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const patchConsentStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const consentStoreId = 'my-consent-store';
  // const defaultConsentTtl = '172800s' Must be at least 24 hours, specified
  // in seconds, appended with 's' character.
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/consentStores/${consentStoreId}`;
  const request = {
    name,
    updateMask: 'defaultConsentTtl',
    resource: {
      defaultConsentTtl: defaultConsentTtl,
    },
  };

  await healthcare.projects.locations.datasets.consentStores.patch(request);
  console.log(
    `Patched consent store ${consentStoreId} with default consent time-to-live ${defaultConsentTtl}`
  );
};

patchConsentStore();
def patch_consent_store(
    project_id: str,
    location: str,
    dataset_id: str,
    consent_store_id: str,
    default_consent_ttl,
):
    """Updates the consent store.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/consent
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the consent store's parent dataset ID
    # consent_store_id = 'my-consent-store'  # replace with the consent store's ID
    # default_consent_ttl = '172800s'  # replace with a default TTL
    consent_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    consent_store_name = "{}/consentStores/{}".format(
        consent_store_parent, consent_store_id
    )

    # Updates the default time-to-live (TTL) of consents in the consent store.
    # Updating the TTL does not affect the expiration time of existing consents.
    # Specify as a duration in seconds with up to nine fractional digits,
    # terminated by "s", for example "172800s".
    # Minimum value is 24 hours, or "86400s" in seconds.
    patch = {"defaultConsentTtl": default_consent_ttl}

    request = (
        client.projects()
        .locations()
        .datasets()
        .consentStores()
        .patch(name=consent_store_name, updateMask="defaultConsentTtl", body=patch)
    )

    response = request.execute()
    print(
        "Patched consent store {} with new default consent TTL: {}".format(
            consent_store_id, default_consent_ttl
        )
    )

    return response

Die folgenden Beispiele zeigen, wie Sie Details zu einem Einwilligungsspeicher abrufen können.

So rufen Sie die Details eines Einwilligungsspeichers auf:

  1. Rufen Sie in der Google Cloud Console die Seite Datasets auf.

    Zu „Datasets“

  2. Wählen Sie das Dataset aus, das den Einwilligungsspeicher enthält, den Sie anzeigen möchten.
  3. Klicken Sie auf den Namen des Consent-Speichers.
  4. Auf der Seite Datenspeicherdetails werden die Details des ausgewählten Consent-Speichers angezeigt.

Führen Sie den gcloud healthcare consent-stores describe-Befehl aus, um Details zu einem Einwilligungsspeicher abzurufen.

Bevor Sie die folgenden Befehlsdaten verwenden, ersetzen Sie die folgenden Werte:

  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID

Führen Sie den folgenden Befehl aus:

Linux, macOS oder 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
Wenn Sie Felder in der Ressource ConsentStore konfiguriert haben, sind diese auch in der Antwort enthalten.

Antwort

name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID

Details zu einem Einwilligungsspeicher erhalten Sie mit der Methode projects.locations.datasets.consentStores.get.

Bevor Sie die Anfragedaten verwenden, ersetzen Sie die folgenden Werte:

  • PROJECT_ID ist die ID Ihres Google Cloud-Projekts
  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Führen Sie folgenden Befehl aus:

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

Führen Sie folgenden Befehl aus:

$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

Öffnen Sie die Methodenreferenzseite. Der API Explorer wird rechts auf der Seite geöffnet. Sie können mit diesem Tool interagieren, um Anfragen zu senden. Füllen Sie die Pflichtfelder aus und klicken Sie auf Ausführen.

Wenn Sie in der Ressource ConsentStore Felder konfiguriert haben, werden diese auch in der Antwort angezeigt.
const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const getConsentStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const consentStoreId = 'my-consent-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/consentStores/${consentStoreId}`;
  const request = {name};

  const consentStore =
    await healthcare.projects.locations.datasets.consentStores.get(request);
  console.log(consentStore.data);
};

getConsentStore();
def get_consent_store(
    project_id: str, location: str, dataset_id: str, consent_store_id: str
):
    """Gets the specified consent store.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/consent
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    # Imports Python's built-in "json" module
    import json

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the consent store's parent dataset ID
    # consent_store_id = 'my-consent-store'  # replace with the consent store's ID
    consent_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    consent_store_name = "{}/consentStores/{}".format(
        consent_store_parent, consent_store_id
    )

    consent_stores = client.projects().locations().datasets().consentStores()
    consent_store = consent_stores.get(name=consent_store_name).execute()

    print(json.dumps(consent_store, indent=2))
    return consent_store

In den folgenden Beispielen wird gezeigt, wie Sie Einwilligungsspeicher in einem Dataset auflisten.

So zeigen Sie die Datenspeicher in einem Dataset an:

  1. Rufen Sie in der Google Cloud Console die Seite Datasets auf.

    Zu „Datasets“

  2. Wählen Sie das Dataset aus, das den Datenspeicher enthält, den Sie anzeigen möchten.

Führen Sie den gcloud healthcare consent-stores list-Befehl aus, um die Einwilligungsspeicher in einem Dataset aufzulisten.

Bevor Sie die folgenden Befehlsdaten verwenden, ersetzen Sie die folgenden Werte:

  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • LOCATION ist der Standort des Datasets

Führen Sie den folgenden Befehl aus:

Linux, macOS oder 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
Wenn Sie Felder in der Ressource ConsentStore konfiguriert haben, sind diese auch in der Antwort enthalten.
ID               LABELS  LOCATION
CONSENT_STORE_ID           LOCATION

Verwenden Sie die Methode projects.locations.datasets.consentStores.list, um die Einwilligungsspeicher in einem Dataset aufzulisten.

Bevor Sie die Anfragedaten verwenden, ersetzen Sie die folgenden Werte:

  • PROJECT_ID ist die ID Ihres Google Cloud-Projekts
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • LOCATION ist der Standort des Datasets

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Führen Sie folgenden Befehl aus:

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

Führen Sie folgenden Befehl aus:

$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

Öffnen Sie die Methodenreferenzseite. Der API Explorer wird rechts auf der Seite geöffnet. Sie können mit diesem Tool interagieren, um Anfragen zu senden. Füllen Sie die Pflichtfelder aus und klicken Sie auf Ausführen.

Wenn Sie in der Ressource ConsentStore Felder konfiguriert haben, werden diese auch in der Antwort angezeigt.
const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const listConsentStores = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {parent};

  const consentStores =
    await healthcare.projects.locations.datasets.consentStores.list(request);
  console.log(JSON.stringify(consentStores.data));
};

listConsentStores();
def list_consent_stores(project_id, location, dataset_id):
    """Lists the consent stores in the given dataset.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/consent
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the consent store's parent dataset ID
    consent_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )

    consent_stores = (
        client.projects()
        .locations()
        .datasets()
        .consentStores()
        .list(parent=consent_store_parent)
        .execute()
        .get("consentStores", [])
    )

    for consent_store in consent_stores:
        print(consent_store)

    return consent_stores

In den folgenden Beispielen wird gezeigt, wie Sie einen Einwilligungsspeicher löschen.

So löschen Sie einen Datenspeicher:

  1. Rufen Sie in der Google Cloud Console die Seite Datasets auf.

    Zu „Datasets“

  2. Wählen Sie das Dataset aus, das den Datenspeicher enthält, den Sie löschen möchten.
  3. Wählen Sie in der Drop-down-Liste Aktionen für den Datenspeicher, den Sie löschen möchten, Löschen aus.
  4. Geben Sie zur Bestätigung den Namen des Datenspeichers ein und klicken Sie auf Löschen.

Führen Sie den gcloud healthcare consent-stores delete-Befehl aus, um einen Einwilligungsspeicher zu löschen:

Bevor Sie die folgenden Befehlsdaten verwenden, ersetzen Sie die folgenden Werte:

  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID

Führen Sie den folgenden Befehl aus:

Linux, macOS oder 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
Geben Sie zum Bestätigen Y ein. Sie sollten eine Antwort ähnlich der folgenden erhalten:
Deleted consentStore [CONSENT_STORE_ID].

Verwenden Sie zum Löschen eines Einwilligungsspeichers die Methode projects.locations.datasets.consentStores.delete.

Bevor Sie die Anfragedaten verwenden, ersetzen Sie die folgenden Werte:

  • PROJECT_ID ist die ID Ihres Google Cloud-Projekts
  • LOCATION ist der Standort des Datasets
  • DATASET_ID ist das übergeordnete Dataset des Einwilligungsspeichers
  • CONSENT_STORE_ID ist die Consent-Speicher-ID

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Führen Sie folgenden Befehl aus:

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

Führen Sie folgenden Befehl aus:

$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

Öffnen Sie die Methodenreferenzseite. Der API Explorer wird rechts auf der Seite geöffnet. Sie können mit diesem Tool interagieren, um Anfragen zu senden. Füllen Sie die Pflichtfelder aus und klicken Sie auf Ausführen.

Sie sollten in etwa folgende JSON-Antwort erhalten:

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const deleteConsentStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const consentStoreId = 'my-consent-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/consentStores/${consentStoreId}`;
  const request = {name};

  await healthcare.projects.locations.datasets.consentStores.delete(request);
  console.log(`Deleted consent store: ${consentStoreId}`);
};

deleteConsentStore();
def delete_consent_store(
    project_id: str, location: str, dataset_id: str, consent_store_id: str
):
    """Deletes the specified consent store.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/consent
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the consent store's parent dataset ID
    # consent_store_id = 'my-consent-store'  # replace with the consent store's ID
    consent_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    consent_store_name = "{}/consentStores/{}".format(
        consent_store_parent, consent_store_id
    )

    request = (
        client.projects()
        .locations()
        .datasets()
        .consentStores()
        .delete(name=consent_store_name)
    )

    response = request.execute()
    print(f"Deleted consent store: {consent_store_id}")
    return response

Audit-Logging

Die Consent Management API schreibt folgende Arten von Audit-Logs:

  • Administratoraktivität: Zeichnet Vorgänge auf, die zu Änderungen an der Konfiguration oder den Metadaten einer Ressource führen. Sie können Audit-Logs zu Administratoraktivitäten nicht deaktivieren.
  • Datenzugriff: Enthalten API-Aufrufe, die die Konfiguration oder Metadaten von Ressourcen lesen, sowie externe API-Aufrufe, die vom Kunden bereitgestellte Ressourcendaten erstellen, ändern oder lesen. Diese Logs müssen aktiviert sein. Beispiel: Audit-Logs für den Datenzugriff können verwendet werden, um zu protokollieren, welcher Dienst eine Zugriffsanforderungsanfrage gestellt hat, welche Informationen in dieser Anfrage bereitgestellt wurden und wie die API auf diese Anfrage reagiert hat. Weitere Informationen zu Audit-Logs zum Datenzugriff finden Sie unter Audit-Logs zum Datenzugriff konfigurieren. Weitere Informationen zu Audit-Logging in der Cloud Healthcare API finden Sie unter Cloud-Audit-Logs anzeigen.

Weitere Informationen zu den Audit-Logs für die Consent Management API finden Sie unter Cloud-Audit-Logs ansehen.