동의 저장소 만들기 및 관리

이 페이지에서는 동의 저장소를 만들고 관리하는 방법을 보여줍니다.

Consent Management API는 사용자 동의를 기록하고, 이러한 동의를 바탕으로 작업을 관리하고, 관련 문서 및 레코드를 유지보수하기 위한 도구입니다.

Consent Management API를 사용하는 조직은 Consent Management API를 통해 데이터 처리를 허용하는 데 필요한 동의를 얻고 유지할 책임이 있습니다.

Consent Management API는 정책 결정 지점의 역할을 이행합니다. 정책 적용은 애플리케이션 또는 프록시를 통해 구현되어야 합니다. 자세한 내용은 속성 기반 액세스 제어를 참조하세요.

권한 설정

이 가이드의 기능을 사용하려면 roles/healthcare.consentStoreAdmin 역할이 있어야 합니다. 하지만 Consent Management API를 사용하여 유용한 추가 작업을 수행하려면 추가 권한이 필요할 수 있습니다. 자세한 내용은 액세스 제어를 참조하세요.

동의 저장소는 Consent Management API의 구성 및 작업과 관련된 모든 정보가 포함된 최상위 리소스입니다. 동의 저장소는 Cloud Healthcare API 데이터 세트에 속하며, 생성될 때 리전에 할당됩니다. 이 리전은 동의 저장소가 작동하는 지리적 위치입니다.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 동의 저장소를 만들 데이터 세트를 선택합니다.

  3. 데이터 저장소 만들기를 클릭합니다.

  4. 동의를 데이터 저장소 유형으로 선택합니다.

  5. ID 필드에 데이터 세트의 고유한 선택 이름을 입력합니다. 이름이 고유하지 않으면 저장소 만들기가 실패합니다.

  6. 다음을 클릭합니다.

  7. 동의 저장소 구성에서 다음 옵션 중 하나를 선택하여 저장소의 동의가 만료되는 시점을 결정합니다.

    • 기본 만료 시간 없음은 기본적으로 동의가 만료되지 않음을 의미합니다.
    • 기본 만료 시간은 기본적으로 동의가 만료 시간 필드에 정의된 일 수 후에 만료됨을 의미합니다.
  8. consentStores.patch를 사용하여 새 동의 리소스를 생성하도록 허용하려면 업데이트 시 동의 생성 허용을 클릭합니다.

  9. 다음을 클릭합니다.

  10. 라벨 추가를 클릭하여 Google Cloud 리소스를 구성하기 위한 선택적 키 및 값 라벨을 정의합니다.

  11. 만들기를 클릭합니다.

동의 저장소를 만들려면 gcloud healthcare consent-stores create 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소의 식별자입니다. 동의 저장소 ID는 다음을 포함해야 합니다.
    • 데이터 세트의 고유 ID
    • 다음으로 구성된 1~256자의 유니코드 문자열:
      • 숫자
      • 문자
      • 밑줄
      • 대시
      • 마침표

다음 명령어를 실행합니다.

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 프로젝트의 ID
  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소의 식별자입니다. 동의 저장소 ID는 다음을 포함해야 합니다.
    • 데이터 세트의 고유 ID
    • 다음으로 구성된 1~256자의 유니코드 문자열:
      • 숫자
      • 문자
      • 밑줄
      • 대시
      • 마침표
  • 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

API 탐색기

요청 본문을 복사하고 메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 요청 본문을 이 도구에 붙여넣고 다른 필수 필드를 입력한 후 실행을 클릭합니다.

다음과 비슷한 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. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 수정하려는 동의 저장소가 포함된 데이터 세트를 선택합니다.
  3. 데이터 저장소 목록에서 수정할 데이터 저장소를 클릭합니다.
  4. 동의 저장소 구성을 수정하려면 동의 저장소 구성 옆에 있는 수정 아이콘을 클릭합니다.

    동의 저장소 구성 옵션에 대한 자세한 내용은 동의 저장소 만들기를 참조하세요.
  5. 저장소에 라벨을 하나 이상 추가하려면 라벨, 라벨 추가를 차례로 클릭하고 키/값 라벨을 입력합니다. 리소스 라벨에 대한 자세한 내용은 리소스 라벨 사용을 참조하세요.
  6. 저장을 클릭합니다.

동의 저장소를 삭제하려면 gcloud healthcare consent-stores update 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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 프로젝트의 ID
  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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

API 탐색기

요청 본문을 복사하고 메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 요청 본문을 이 도구에 붙여넣고 다른 필수 필드를 입력한 후 실행을 클릭합니다.

다음과 비슷한 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. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 보려는 동의 저장소가 포함된 데이터 세트를 선택합니다.
  3. 동의 저장소 이름을 클릭합니다.
  4. Datastore 세부정보 페이지에 선택한 동의 저장소의 세부정보가 표시됩니다.

동의 저장소에 대한 세부정보를 가져오려면 gcloud healthcare consent-stores describe 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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 프로젝트의 ID
  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

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. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  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 프로젝트의 ID
  • 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

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

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. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 삭제할 데이터 스토어가 포함된 데이터 세트를 선택합니다.
  3. 삭제할 데이터 스토어의 작업 드롭다운 목록에서 삭제를 선택합니다.
  4. 확인하려면 데이터 저장소 이름을 입력한 다음 삭제를 클릭합니다.

동의 저장소를 삭제하려면 gcloud healthcare consent-stores delete 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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 프로젝트의 ID
  • LOCATION: 데이터 세트 위치입니다.
  • DATASET_ID: 동의 저장소의 상위 데이터 세트입니다.
  • CONSENT_STORE_ID: 동의 저장소 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

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

다음과 비슷한 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

감사 로깅

Consent Management API는 다음 유형의 감사 로그를 작성합니다.

  • 관리자 활동: 리소스의 구성 또는 메타데이터를 수정하는 작업을 기록합니다. 관리자 활동 감사 로그는 사용 중지할 수 없습니다.
  • 데이터 액세스: 리소스의 구성 또는 메타데이터를 읽는 API 호출뿐만 아니라 고객이 제공한 리소스 데이터를 생성 및 수정하거나 읽는 외부 API 호출도 포함됩니다. 이러한 로그를 사용 설정해야 합니다. 예를 들어 데이터 액세스 감사 로그는 액세스 결정 요청을 작성한 서비스, 요청에 제공된 정보, 해당 요청에 대한 API의 응답 방식을 로깅하는 데 사용될 수 있습니다. 데이터 액세스 감사 로그에 대한 자세한 내용은 데이터 액세스 감사 로그 구성을 참조하세요. Cloud Healthcare API의 감사 로깅에 대한 자세한 내용은 Cloud 감사 로그 보기를 참조하세요.

Consent Management API의 감사 로그에 대한 자세한 내용은 Cloud 감사 로그 보기를 참조하세요.