このページでは、Consent Management API にユーザーデータを登録する方法について説明します。
データ要素は Consent Management API に登録され、ユーザーデータのマッピングを使用して同意に関連付けられます。ユーザーデータは Consent Management API には保存されません。
UserDataMappings
リソースとして表現されるユーザーデータのマッピングには、次の要素が含まれます。
- ユーザーを識別するユーザー ID。この ID は、同意の登録時にアプリケーションが Consent Management API に提供した ID と一致します。
- Google Cloud やオンプレミスなど、他の場所に格納されているユーザーデータを識別するデータ ID。データ ID には、不透明 ID や URL などの識別子を使用できます。
- リソース属性。属性定義を使用して Consent Store 用に構成されたリソース属性値を使用して、ユーザーデータの特性を記述します。たとえば、データには、
de-identified
の値を持つattribute_definition_id
data_identifiable
を含めることができます。
次の図は、データ マッピングを作成するためのデータフローを示しています。
ユーザーデータのマッピングの登録
ユーザー データ マッピングを作成するには、projects.locations.datasets.consentStores.userDataMappings.create
メソッドを使用します。POST
リクエストを行い、リクエストで次の値を指定します。
- 親 Consent Store の名前
- データ要素が関連付けられているユーザーを表す、一意の不透明
userID
- 一意のリソースへの REST パスなど、ユーザーデータ リソースの識別子
- データ要素を記述する
RESOURCE
属性のセット - アクセス トークン
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', 'data_id' : 'DATA_ID', 'resource_attributes': [{ 'attribute_definition_id': 'data_identifiable', 'values': ['de-identified'] }] }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings"
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings/USER_DATA_MAPPING_ID", "dataId": "DATA_ID", "userId": "USER_ID", "resourceAttributes": [ { "attributeDefinitionId": "data_identifiable", "values": [ "de-identified" ] } ] }
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', 'data_id' : 'DATA_ID', 'resource_attributes': [{ 'attribute_definition_id': 'data_identifiable', 'values': ['de-identified'] }] }" ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings" | Select-Object -Expand Content
リクエストが成功すると、サーバーは JSON 形式の次のサンプルのようなレスポンスを返します。
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID/userDataMappings/USER_DATA_MAPPING_ID", "dataId": "DATA_ID", "userId": "USER_ID", "resourceAttributes": [ { "attributeDefinitionId": "data_identifiable", "values": [ "de-identified" ] } ] }