יצירה וניהול של מאגרי הסכמה

בדף הזה מוסבר איך ליצור ולנהל מאגרי הסכמה.

Consent Management API הוא כלי לתיעוד הסכמות של המשתמשים, לניהול פעולות על סמך ההסכמות האלה ולשמירה של תיעוד ורשומות שקשורים אליהן.

הארגון שמשתמש ב-Consent Management API אחראי לקבלת ההסכמות הנדרשות ולשמירה שלהן, כדי לאפשר את עיבוד הנתונים באמצעות Consent Management API.

ממשק Consent Management API ממלא את התפקיד של נקודת החלטה לגבי הפרת מדיניות. צריך להטמיע את אכיפת המדיניות באפליקציה או באמצעות שרת proxy. מידע נוסף זמין במאמר בנושא בקרת גישה מבוססת-מאפיינים.

הגדרת ההרשאות

כדי להשתמש בתכונות שבמדריך הזה, צריך להיות לכם תפקיד עם ההרשאה roles/healthcare.consentStoreAdmin. עם זאת, כדי לבצע פעולות שימושיות נוספות באמצעות Consent Management API, יכול להיות שיידרשו הרשאות נוספות. פרטים נוספים מופיעים במאמר בנושא בקרת גישה.

מאגרי הסכמה הם משאבים ברמה העליונה שמכילים את כל המידע שקשור להגדרה ולתפעול של Consent Management API. מאגרי הסכמה שייכים למערך נתונים של Cloud Healthcare API, שמוקצה לו אזור כשהוא נוצר. האזור הזה הוא המיקום הגיאוגרפי שבו פועל מאגר ההסכמה שלכם.

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שבו רוצים ליצור מאגר הסכמה.

  3. לוחצים על יצירת מאגר נתונים.

  4. בוחרים באפשרות הסכמה כסוג מאגר הנתונים.

  5. בשדה ID (מזהה), מזינים שם לבחירתכם שיהיה ייחודי במערך הנתונים. אם השם לא ייחודי, יצירת החנות תיכשל.

  6. לוחצים על הבא.

  7. בקטע Configure your Consent Store (הגדרת מאגר ההסכמות), בוחרים באחת מהאפשרויות הבאות כדי לקבוע מתי ההסכמות במאגר יפוגו:

    • ללא זמן תפוגה שמוגדר כברירת מחדל – המשמעות היא שההסכמות לא יפוגו כברירת מחדל.
    • מועד התפוגה שמוגדר כברירת מחדל אומר שמועד התפוגה של הסכמות הוא אחרי מספר הימים שמוגדר בשדה מועד התפוגה.
  8. כדי לאפשר יצירה של משאבי הסכמה חדשים באמצעות consentStores.patch, לוחצים על Allow consent creation on update (אפשר יצירת הסכמה בעדכון).

  9. לוחצים על הבא.

  10. לוחצים על הוספת תווית כדי להגדיר תוויות אופציונליות של מפתח וערך לארגוןGoogle Cloud המשאבים.

  11. לוחצים על יצירה.

כדי ליצור מאגר הסכמה, מריצים את הפקודה gcloud healthcare consent-stores create.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה של מאגר ההסכמה. מזהה מאגר ההסכמה צריך לכלול את הפרטים הבאים:
    • מזהה ייחודי במערך הנתונים
    • מחרוזת Unicode באורך 1-256 תווים, שכוללת את הרכיבים הבאים:
      • Numbers
      • מכתבים
      • קווים תחתונים
      • מקפים
      • פרקי הזמן

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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

אמורים לקבל תגובה שדומה לזו:

תשובה

Created consentStore [CONSENT_STORE_ID].

כדי ליצור מאגר הסכמה, משתמשים בשיטה projects.locations.datasets.consentStores.create.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה של מאגר ההסכמה. מזהה מאגר ההסכמה צריך לכלול את הפרטים הבאים:
    • מזהה ייחודי במערך הנתונים
    • מחרוזת Unicode באורך 1-256 תווים, שכוללת את הרכיבים הבאים:
      • Numbers
      • מכתבים
      • קווים תחתונים
      • מקפים
      • פרקי הזמן
  • ‫DEFAULT_CONSENT_EXPIRATION_DURATION: זמן ברירת מחדל אופציונלי, שצוין בשניות, עד שתוקף ההסכמות שנוצרו בחנות הזו יפוג. משך המבצע חייב להיות 24 שעות לפחות (86,400 שניות) והוא צריך להיות בפורמט DEFAULT_CONSENT_EXPIRATION_DURATIONs.
  • ‫ENABLE_CONSENT_CREATE_ON_UPDATE: ערך בוליאני אופציונלי שקובע אם בקשות לתיקון משאב הסכמה שלא קיים באמצעות consentStores.patch צריכות ליצור את המשאב הזה. ברירת המחדל היא FALSE.

תוכן בקשת JSON:

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

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

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

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

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

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

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

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

$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

מעתיקים את גוף הבקשה ופותחים את דף העזר של השיטה. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. מדביקים את גוף הבקשה בכלי הזה, ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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

אחרי שיוצרים מאגר הסכמה, אפשר לעדכן אותו. לדוגמה, אתם יכולים להוסיף או להסיר תוויות כדי לארגן את חנויות ההסכמה.

בדוגמאות הבאות אפשר לראות איך לערוך מאגר הסכמה.

כדי לערוך מאגר הסכמה:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר ההסכמה שרוצים לערוך.
  3. ברשימה מאגרי נתונים, לוחצים על מאגר הנתונים שרוצים לערוך.
  4. כדי לערוך את ההגדרה של מאגר ההסכמות, לוחצים על סמל העריכה לצד Consent Store Configuration (הגדרת מאגר ההסכמות).

    מידע נוסף על אפשרויות ההגדרה של מאגר ההסכמות זמין במאמר בנושא יצירת מאגר הסכמות.
  5. כדי להוסיף תווית אחת או יותר לחנות, לוחצים על תוויות, לוחצים על הוספת תווית ומזינים את התווית של המפתח/הערך. מידע נוסף על תוויות משאבים זמין במאמר שימוש בתוויות משאבים.
  6. לוחצים על Save.

כדי לערוך את מאגר ההסכמה, מריצים את הפקודה gcloud healthcare consent-stores update.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה
  • ‫KEY: המפתח בצמד מפתח/ערך שמשמש לארגון מאגרי הסכמה. במאמר labels מפורטות הדרישות והמגבלות בנוגע לתוויות.
  • ‫VALUE: הערך בצמד מפתח/ערך שמשמש לארגון מאגרי הסכמה. במאמר labels מפורטות הדרישות והמגבלות בנוגע לתוויות.

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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

אמורים לקבל תגובה שדומה לזו:

תשובה

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

כדי לערוך מאגר הסכמה, משתמשים בשיטה projects.locations.datasets.consentStores.patch.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה
  • ‫KEY: המפתח בצמד מפתח/ערך שמשמש לארגון מאגרי הסכמה. במאמר labels מפורטות הדרישות והמגבלות בנוגע לתוויות.
  • ‫VALUE: הערך בצמד מפתח/ערך שמשמש לארגון מאגרי הסכמה. במאמר labels מפורטות הדרישות והמגבלות בנוגע לתוויות.

תוכן בקשת JSON:

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

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

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

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

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

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

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

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

$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

מעתיקים את גוף הבקשה ופותחים את דף העזר של השיטה. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. מדביקים את גוף הבקשה בכלי הזה, ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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

בדוגמאות הבאות אפשר לראות איך מקבלים פרטים על מאגר הסכמה.

כדי לראות את הפרטים של מאגר הסכמה:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר ההסכמות שרוצים להציג.
  3. לוחצים על השם של מאגר ההסכמה.
  4. בדף Data store details מוצגים הפרטים של מאגר ההסכמה שנבחר.

כדי לקבל פרטים על מאגר הסכמה, מריצים את הפקודה gcloud healthcare consent-stores describe.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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, הם יופיעו גם בתגובה.

תשובה

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

כדי לקבל פרטים על מאגר הסכמה, משתמשים בשיטה projects.locations.datasets.consentStores.get

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

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

מריצים את הפקודה הבאה:

$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

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אם הגדרתם שדות כלשהם במשאב ConsentStore, הם יופיעו גם בתשובה.
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

בדוגמאות הבאות אפשר לראות איך מציגים רשימה של מאגרי ההסכמה במערך נתונים.

כדי לראות את מאגרי הנתונים במערך נתונים:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר הנתונים שרוצים להציג.

כדי להציג רשימה של מאגרי הסכמה במערך נתונים, מריצים את הפקודה gcloud healthcare consent-stores list.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫LOCATION: המיקום של מערך הנתונים

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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, הם יופיעו גם בתגובה.
ID               LABELS  LOCATION
CONSENT_STORE_ID           LOCATION

כדי להציג רשימה של מאגרי ההסכמה במערך נתונים, משתמשים בשיטה projects.locations.datasets.consentStores.list.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫LOCATION: המיקום של מערך הנתונים

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

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

מריצים את הפקודה הבאה:

$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

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אם הגדרתם שדות כלשהם במשאב ConsentStore, הם יופיעו גם בתשובה.
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

בדוגמאות הבאות אפשר לראות איך מוחקים מאגר הסכמה.

כדי למחוק מאגר נתונים:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר הנתונים שרוצים למחוק.
  3. ברשימה הנפתחת פעולות, בוחרים באפשרות מחיקה של מאגר הנתונים שרוצים למחוק.
  4. כדי לאשר, מקלידים את השם של מאגר הנתונים ולוחצים על מחיקה.

כדי למחוק מאגר הסכמה, מריצים את הפקודה gcloud healthcare consent-stores delete.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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
כדי לאשר, מקלידים Y. אמורה להתקבל תגובה שדומה לזו:
Deleted consentStore [CONSENT_STORE_ID].

כדי למחוק מאגר הסכמה, משתמשים בשיטה projects.locations.datasets.consentStores.delete.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של מאגר ההסכמה
  • ‫CONSENT_STORE_ID: מזהה חנות ההסכמה

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

מריצים את הפקודה הבאה:

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

מריצים את הפקודה הבאה:

$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

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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

רישום ביומן ביקורת

ה-API לניהול הסכמה כותב את סוגי יומני הביקורת הבאים:

  • Admin Activity: רישום פעולות שמשנות את ההגדרות או את המטא-נתונים של משאב. לא ניתן להשבית את יומני הביקורת Admin Activity.
  • Data Access: מכילים קריאות ל-API שקוראות את ההגדרות או את המטא-נתונים של משאבים, וגם קריאות ל-API חיצוניות שיוצרות, משנות או קוראות נתוני משאבים שסופקו על ידי הלקוח. צריך להפעיל את היומנים האלה. לדוגמה, אפשר להשתמש ביומני ביקורת של Data Access כדי לתעד איזה שירות הגיש בקשה לקביעת גישה, איזה מידע נכלל בבקשה הזו ואיך ה-API הגיב לבקשה. מידע נוסף על יומני ביקורת Data Access זמין במאמר הגדרת יומני ביקורת Data Access. מידע נוסף על רישום ביומן ביקורת ב-Cloud Healthcare API זמין במאמר צפייה ביומני ביקורת של Cloud.

מידע נוסף על יומני ביקורת של Consent Management API