このページでは、ユーザーの同意の作成、更新、取り消しの方法について説明します。
アプリケーションは、同意アーティファクトと同意を別々に記録します。Consent Management API は、ユーザーの同意に関する機密データを ConsentArtifact として保存します。ConsentArtifact には、署名のタイムスタンプと署名の画像、または同意の「証拠」として機能するほかのドキュメントの画像を含めることができます。
Consent Management API は、機密情報ではない同意データを Consent オブジェクトとして保存します。Consent には、不透明なユーザー ID、ユーザーが付与した同意ポリシー、同意ポリシーのステータスが含まれます。
同意と同意アーティファクトに別々のリソースパスがあるため、同意アーティファクトの機密同意データへのアクセスを最小限に抑えるために、権限を個別に設定できます。
同意では、いつ同意の有効期限が切れて無効になるかを構成できる有効期限をサポートしています。有効期限には、特定の日付または期間(1 年など)を設定できます。
同意ストアの作成中に、同意ストアのデフォルトの有効期限を構成できます。同意の作成時に、同意の有効期限を構成できます。同意ストアに設定されているデフォルトの期間は、同意の作成中に設定された有効期限によってオーバーライドされます。
同意は、ACTIVE または DRAFT のいずれかの状態に作成できます。ACTIVE 状態の同意は、Consent Management API により、アクセス判定に使用されます。DRAFT 状態の同意は、アクセス判定リクエストで指定された場合に限り、アクセス判定に使用されます。同意を更新することで、状態を DRAFT から ACTIVE または REJECTED に変更できます。
ユーザーの同意を記録するには、projects.locations.datasets.consentStores.consentArtifacts.create メソッドを使用して、同意アーティファクトを作成し、projects.locations.datasets.consentStores.consents.create メソッドを使用して作成した同意に同意アーティファクトを関連付けます。
このページのサンプルは、Consent Store を作成して同意ポリシーを構成したことを前提としています。
同意アーティファクトの作成
同意アーティファクトには、ユーザーの同意に関する機密データが保存されます。同意アーティファクトには、ユーザーの連絡先情報、署名のタイムスタンプ、同意の「証拠」として機能する署名やその他のドキュメントの画像を含めることができます。
同意アーティファクトを作成するには、projects.locations.datasets.consentStores.consentArtifacts.create メソッドを使用します。POST リクエストを行い、リクエストで次の値を指定します。
- 親 Consent Store の名前。
- 同意を提供したユーザーを表す一意の不透明ユーザー ID。
- 必要に応じて署名画像、タイムスタンプ、その他のメタデータを含むユーザーの署名。このイメージは、Cloud Storage 内の画像のロケーションか、RAW バイト文字列として指定できます。
- 保護者または立会人の署名(省略可)。
- 署名画像や、モバイルの同意フローの画面をキャプチャした画像、署名付きの PDF ドキュメントなど、同意の「証拠」として機能する画像またはドキュメント(省略可)。これらの画像は、Cloud Storage 内のロケーションまたは RAW バイト文字列として指定できます。
- ユーザーに表示された同意情報の ID。
- ユーザーの同意に関するメタデータ(省略可)。
- アクセス トークン。
curl
次のサンプルは、curl を使用した POST リクエストを示しています。
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/consent+json; charset=utf-8" \ --data "{ 'user_id': 'USER_ID', 'user_signature' : { 'user_id': 'USER_ID', 'image': { 'gcs_uri': 'gs://IMG_URI' }, 'signature_time': { 'seconds': EPOCH_SECONDS }, }, 'consent_content_screenshots': [ { 'raw_bytes': 'BASE_64_IMAGE' }], 'consent_content_version': 'v1', 'metadata': {'client': 'mobile'} }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts"
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_RESOURCE_ID",
"userId": "USER_ID",
"userSignature": {
"userId": "USER_ID",
"signatureTime": "SIGNATURE_TIME"
},
"consentContentVersion": "v1",
"metadata": {
"client": "mobile"
}
}
PowerShell
次のサンプルは、Windows PowerShell を使用した POST リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/consent+json; charset=utf-8" ` -Body "{ 'user_id': 'USER_ID', 'user_signature' : { 'user_id': 'USER_ID', 'image': { 'gcs_uri': 'gs://IMG_URI' }, 'signature_time': { 'seconds': EPOCH_SECONDS } }, 'consent_content_screenshots': [ { 'raw_bytes': 'BASE_64_IMAGE' }], 'consent_content_version': 'v1', 'metadata': {'client': 'mobile'} }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式の次のレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_RESOURCE_ID",
"userId": "USER_ID",
"userSignature": {
"userId": "USER_ID",
"signatureTime": "SIGNATURE_TIME"
},
"consentContentVersion": "v1",
"metadata": {
"client": "mobile"
}
}
同意の作成
同意には、不透明なユーザー ID や、ユーザーが付与した同意ポリシー、同意ポリシーが現在有効か否かなど、機密情報ではないデータが格納されます。
同意を作成するには、projects.locations.datasets.consentStores.consents.create メソッドを使用します。POST リクエストを行い、リクエストで次の値を指定します。
- 親 Consent Store の名前。
- 同意を提供したユーザーを表す一意の不透明ユーザー ID。
- 同意ポリシーは最大 10 個で、各ポリシーには、
RESOURCE属性値のセットと、先ほど作成した属性の定義で使用したユーザーのインテントを記述する Common Expression Language(CEL)で表現される承認ルールが含まれます。CEL には次の制限が適用されます。- それぞれのポリシーに定義できる論理演算子は最大 10 個です。
- AND(&&)、OR(||)、IN の各演算子のみ使用できます。
- 対応する同意アーティファクトへの REST パス(同意アーティファクトの作成時に返されます)。
- 同意状態(
DRAFTまたはACTIVE。省略可)。状態を指定しない場合、同意はACTIVE状態に作成されます。 - 日付または期間として定義された同意の有効期間(省略可)。この値は秒単位で指定し、末尾に s を付ける必要があります(例:
86000s)。この値は、Consent Store に対し構成された有効期限よりも優先されます。有効期限を構成しなかった場合、リソースは、Consent Store からデフォルトの有効期限を継承します。リソースまたはストアのいずれかで有効期限が指定されていない場合、同意リソースは期限切れになりません。 - アクセス トークン。
curl
次のサンプルは、curl を使用した POST リクエストを示しています。
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/consent+json; charset=utf-8" \ --data "{ \"user_id\": \"USER_ID\", \"policies\": [{ \"resource_attributes\": [{ \"attribute_definition_id\": \"data_identifiable\", \"values\": [\"identifiable\"] }], \"authorization_rule\": { \"expression\": \"requester_identity == 'clinical-admin'\", } }, { \"resource_attributes\": [{ \"attribute_definition_id\": \"data_identifiable\", \"values\": [\"de-identified\"] }], \"authorization_rule\": { \"expression\": \"requester_identity in ['internal-researcher', 'external-researcher']\" } }], \"consent_artifact\": \"projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID\", \"ttl\": \"EXPIRATION_DURATION\" }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents"
リクエストが成功すると、サーバーは次の例のようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}
PowerShell
次のサンプルは、Windows PowerShell を使用した POST リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/consent+json; charset=utf-8" ` -Body "{ 'user_id': 'USER_ID', 'policies': [{ 'resource_attributes': [{ 'attribute_definition_id': 'data_identifiable', 'values': ['identifiable'] }], 'authorization_rule': { 'expression': 'requester_identity == \'clinical-admin\'', } },{ 'resource_attributes': [{ 'attribute_definition_id': 'data_identifiable', 'values': ['de-identified'] }], 'authorization_rule': { 'expression': 'requester_identity in [\'internal-researcher\', \'external-researcher\']' } }], 'consent_artifact': 'projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID', 'ttl': 'EXPIRATION_DURATION' }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents" | Select-Object -Expand Content
リクエストが成功すると、サーバーは次の例のようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}
同意の取得
以下のサンプルは、同意を取得する方法を示しています。詳細については、projects.locations.datasets.consentStores.consents.get をご覧ください。
同意を取得するには、GET リクエストを作成して、リクエストで次の情報を指定します。
- 親データセットの名前
- Consent Store の名前
- 同意の名前
- アクセス トークン
curl
次のサンプルは、curl を使用した GET リクエストを示しています。
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID"
リクエストが成功すると、サーバーは JSON 形式のレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
}
PowerShell
次のサンプルは、Windows PowerShell を使用した GET リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-RestMethod ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID" | ConvertTo-Json
リクエストが成功すると、サーバーは JSON 形式のレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": "",
"authorizationRule": "@{expression=requester_identity == 'clinical-admin'}"
},
{
"resourceAttributes": "",
"authorizationRule": "@{expression=requester_identity in ['internal-researcher', 'external-researcher']}"
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
}
Consent Store 内の同意の一覧表示
次のサンプルは、Consent Store で同意を一覧表示する方法を示しています。
Consent Store 内の同意を一覧表示するには、projects.locations.datasets.consentStores.consents.list メソッドを使用します。
curl
Consent Store 内の同意を一覧表示するには、GET リクエストを作成し、次の情報を指定します。
- 親 Consent Store の名前
- ユーザー ID、状態、作成日時、同意アーティファクトに基づいて同意を取得する検索フィルタ(省略可)
- アクセス トークン
次のサンプルは、curl を使用した GET リクエストを示しています。
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents"
リクエストが成功すると、サーバーは JSON 形式のレスポンスを返します。
{
"consents": [
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
},
{
...
}
]
}
PowerShell
Consent Store 内の同意を一覧表示するには、GET リクエストを作成し、次の情報を指定します。
- 親データセットの名前
- ユーザー ID、状態、作成日時、同意アーティファクトに基づいて同意を取得する検索フィルタ(省略可)
- アクセス トークン
次のサンプルは、Windows PowerShell を使用した GET リクエストを示しています。
$cred = gcloud auth application-default 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/consents" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式のレスポンスを返します。
{
"consents": [
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "CONSENT_STATE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
},
{
...
}
]
}
projects.locations.datasets.consentStores.consents.listRevisions メソッドを使用して、特定の同意のリビジョンを一覧表示することもできます。
同意の更新
場合によっては、時間の経過に伴い、同意の状態を更新する必要があります。これを行うには、同意の状態を変更します。状態が更新および変更されるたびに、同意の新たなリビジョンが生成されます。以前のリビジョンにアクセスするには、同意のリソース名に @{revision_id} を追加します。
同意の更新
アクティブ状態またはドラフト状態の同意の userId フィールド、policies フィールド、consentArtifact フィールド、または revokeConsentArtifact フィールドを更新するには、projects.locations.datasets.consentStores.consents.patch メソッドを使用します。新しいリビジョンの変更が commit され、最新の状態に設定されます。
同意を更新するには、PATCH リクエストを作成して、リクエストで次の情報を指定します。
- 更新する同意の REST パス
- 更新するフィールド
- 更新マスク
- アクセス トークン
curl
次のサンプルは、同意アーティファクトを更新する curl を使用した PATCH リクエストを示しています。
curl -X PATCH \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ -H "Content-Type: application/consent+json; charset=utf-8" \ --data "{ \"consentArtifact\": \"projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID\" }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID?updateMask=consentArtifact"
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "ACTIVE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
}
PowerShell
次のサンプルは、Windows PowerShell を使用し、同意アーティファクトを更新する PATCH リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Patch ` -Headers $headers ` -ContentType: "application/consent+json; charset=utf-8" ` -Body "{ 'consentArtifact': 'projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID' }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID?updateMask=consentArtifact" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "ACTIVE",
"stateChangeTime": "STATE_CHANGE_TIME",
"revisionCreateTime": "REVISION_CREATE_TIME",
"expireTime": "EXPIRE_TIME"
}
同意の有効化
ユーザーが同意した後に同意の状態を DRAFT から ACTIVE に変更するには、projects.locations.datasets.consentStores.consents.activateConsent メソッドを使用します。新しいリビジョンが状態 ACTIVE で commit されます。同意の状態が ACTIVE の場合は、アクセス判定リクエストにその同意が含まれます。
同意を有効化するには、POST リクエストを作成して、リクエストで次の情報を指定します。
- 有効化する同意の REST パス
- 同意が有効化された理由を記録するアーティファクト(省略可)への REST パス
- アクセス トークン
curl
次のサンプルは、curl を使用した POST リクエストを示しています。
curl -X POST \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ -H "Content-Type: application/consent+json; charset=utf-8" \ --data "{ 'consent_artifact': 'projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userConsentArtifacts/CONSENT_ARTIFACT_RESOURCE_ID' \ }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID:activate"
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "ACTIVE",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}
PowerShell
次のサンプルは、Windows PowerShell を使用した POST リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/consent+json; charset=utf-8" ` -Body "{ 'consent_artifact': '/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userConsentArtifacts/CONSENT_ARTIFACT_ID' }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID:activate" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "ACTIVE",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}
同意の取り消しと拒否
同意の状態を DRAFT から REJECTED に変更するには、たとえば、同意できなかったことをユーザーが指定した場合には、projects.locations.datasets.consentStores.consents.reject メソッドを使用します。同意の状態が REJECTED の場合、同意は、アクセス判定リクエストには含まれません。
同意状態を ACTIVE から REVOKED に変更するには、たとえば、事前に付与した同意を取り消す場合には、projects.locations.datasets.consentStores.consents.revoke を使用します。新しいリビジョンが状態 REVOKED で commit されます。アクセス判定リクエストには、状態が REVOKED の同意は含まれません。同意が取り消された理由を記録するため、同意に関連付けられたアーティファクトを必要に応じて作成できます。同意を取り消しても、同意は削除されません。
同意を取り消すには、POST リクエストを作成して、リクエストで次の情報を指定します。
- 取り消す同意の REST パス
- 同意が取り消された理由を記録するアーティファクト(省略可)への REST パス
- アクセス トークン
curl
次のサンプルは、curl を使用した POST リクエストを示しています。
curl -X POST \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ -H "Content-Type: application/consent+json; charset=utf-8" \ --data "{}" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID:revoke"
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "REVOKED",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}
PowerShell
次のサンプルは、Windows PowerShell を使用した POST リクエストを示しています。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/consent+json; charset=utf-8" ` -Body "{}" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID:revoke" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consents/CONSENT_ID",
"userId": "USER_ID",
"policies": [
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"identifiable"
]
}
],
"authorizationRule": {
"expression": "requester_identity == 'clinical-admin'"
}
},
{
"resourceAttributes": [
{
"attributeDefinitionId": "data_identifiable",
"values": [
"de-identified"
]
}
],
"authorizationRule": {
"expression": "requester_identity in ['internal-researcher', 'external-researcher']"
}
}
],
"consentArtifact": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/consentArtifacts/CONSENT_ARTIFACT_ID",
"state": "REVOKED",
"stateChangeTime": "STATE_CHANGE_TIME",
"expireTime": "EXPIRE_TIME"
}