Questa pagina descrive come creare, aggiornare e revocare i consensi degli utenti.
La tua applicazione registra gli artefatti di consenso e i consensi separatamente.
L'API Consent Management archivia i dati sensibili relativi al consenso di un utente come
ConsentArtifact.
Un ConsentArtifact può includere timestamp della firma e immagini di firme o altri documenti che fungono da "prova" del consenso.
L'API Consent Management archivia i dati sul consenso non sensibili come oggetti Consent. Un Consent include un ID utente opaco, le norme relative al consenso concesse dall'utente e lo stato delle norme relative al consenso.
Poiché i consensi e gli artefatti di consenso hanno percorsi delle risorse distinti, le relative autorizzazioni possono essere impostate in modo indipendente per ridurre al minimo l'accesso ai dati per i quali è stato dato il consenso negli artefatti di consenso.
I consensi supportano una durata di scadenza che ti consente di configurare quando un consenso scade e non è più valido. La durata della scadenza può essere impostata su una data specifica o su un periodo di tempo, ad esempio un anno.
Durante la creazione del datastore di consensi, puoi configurare una durata di scadenza predefinita per il datastore di consensi. Durante la creazione del consenso, puoi configurare una durata di scadenza per il consenso. La durata della scadenza impostata durante la creazione del consenso esegue l'override della durata predefinita impostata per il datastore dei consensi.
I consensi possono essere creati negli stati ACTIVE o DRAFT. I consensi nello stato ACTIVE vengono utilizzati dall'API di gestione del consenso per determinare l'accesso. I consensi nello stato DRAFT vengono utilizzati nelle determinazioni di accesso solo se specificati in una richiesta di determinazione di accesso. Puoi modificare
lo stato da DRAFT a ACTIVE o REJECTED
aggiornando il consenso.
Per registrare un consenso dell'utente, crea un artefatto di consenso utilizzando il metodo projects.locations.datasets.consentStores.consentArtifacts.create, quindi collegalo a un consenso creato utilizzando il metodo projects.locations.datasets.consentStores.consents.create.
Gli esempi in questa pagina presuppongono che tu abbia creato un archivio dei consensi e configurato le policy relative ai consensi.
Creazione di un artefatto di consenso
Un artefatto di consenso memorizza dati sensibili relativi al consenso di un utente. Un artefatto di consenso può includere i dati di contatto di un utente, i timestamp delle firme e le immagini delle firme o di altri documenti che fungono da "prova" del consenso.
Per creare un artefatto di consenso, utilizza il metodo projects.locations.datasets.consentStores.consentArtifacts.create. Invia una richiesta POST e specifica le seguenti informazioni nella richiesta:
- Il nome del datastore di consenso parentale.
- Un ID utente univoco e opaco che rappresenta l'utente che ha fornito il consenso.
- La firma dell'utente, che include facoltativamente l'immagine della firma, il timestamp e altri metadati. Questa immagine può essere specificata come posizione dell'immagine in Cloud Storage o come stringa di byte non elaborati.
- La firma facoltativa di un tutore o di un testimone.
- Immagini o documenti facoltativi che fungono da "prova" del consenso, ad esempio un'immagine della firma, immagini che acquisiscono le schermate di un flusso di consenso mobile o un documento PDF firmato. Queste immagini possono essere specificate come posizione in Cloud Storage o come stringa di byte non elaborati.
- Un identificatore per le informazioni sul consenso mostrate all'utente.
- Metadati facoltativi relativi al consenso dell'utente.
- Un token di accesso.
curl
L'esempio seguente mostra una richiesta POST utilizzando curl:
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"
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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
L'esempio seguente mostra una richiesta POST utilizzando Windows PowerShell:
$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
Se la richiesta ha esito positivo, il server restituisce la seguente risposta in formato 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"
}
}
Creazione di un consenso
Un consenso memorizza dati non sensibili, inclusi ID utente opachi, le norme relative al consenso concesse dagli utenti e se le norme relative al consenso sono attualmente valide.
Per creare un consenso, utilizza il metodo projects.locations.datasets.consentStores.consents.create. Invia una richiesta POST e specifica le seguenti informazioni nella richiesta:
- Il nome del datastore di consenso parentale.
- Un ID utente univoco e opaco che rappresenta l'utente che ha fornito il consenso.
- Fino a 10 policy di consenso, ciascuna con un insieme di valori dell'attributo
RESOURCEe una regola di autorizzazione espressa in Common Expression Language (CEL) che descrivono l'intento dell'utente con le definizioni degli attributi create in precedenza. Si applicano le seguenti limitazioni al CEL:- Puoi definire un massimo di 10 operatori logici per policy.
- Puoi utilizzare solo gli operatori AND (&&), OR (||) e IN.
- Il percorso REST dell'artefatto di consenso corrispondente (restituito al momento della creazione dell'artefatto di consenso).
- Uno stato del consenso facoltativo,
DRAFToACTIVE. Se non specifichi lo stato, il consenso viene creato nello statoACTIVE. - Una durata di scadenza facoltativa per il consenso, definita come data o periodo di tempo. Questo valore deve essere fornito in secondi e seguito dalla lettera s. Ad esempio,
86000s. Questo valore sostituisce la durata della scadenza configurata per il datastore dei consensi. Se non configuri una scadenza, la risorsa eredita la durata di scadenza predefinita dal datastore dei consensi. Se non viene specificata una durata di scadenza per la risorsa o per l'archivio, la risorsa di consenso non scade. - Un token di accesso.
curl
L'esempio seguente mostra una richiesta POST utilizzando curl:
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"
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio:
{
"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
L'esempio seguente mostra una richiesta POST utilizzando Windows PowerShell:
$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
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio:
{
"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"
}
Ottenere il consenso
I seguenti esempi mostrano come ottenere un consenso. Per saperne di più, vedi projects.locations.datasets.consentStores.consents.get.
Per ottenere un consenso, invia una richiesta GET e specifica le seguenti informazioni nella richiesta:
- Il nome del set di dati principale
- Il nome del datastore dei consensi
- Il nome del consenso
- Un token di accesso
curl
L'esempio seguente mostra una richiesta GET utilizzando curl:
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"
Se la richiesta ha esito positivo, il server restituisce la risposta in formato 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
L'esempio seguente mostra una richiesta GET utilizzando Windows PowerShell:
$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
Se la richiesta ha esito positivo, il server restituisce la risposta in formato 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"
}
Elenco dei consensi in un archivio di consensi
I seguenti esempi mostrano come elencare i consensi in un archivio dei consensi.
Per elencare i consensi in un archivio dei consensi, utilizza il metodo projects.locations.datasets.consentStores.consents.list.
curl
Per elencare i consensi in un archivio di consensi, invia una richiesta GET e specifica le seguenti informazioni:
- Il nome del datastore del consenso principale
- Un filtro di ricerca facoltativo per recuperare i consensi in base all'ID utente, allo stato, all'ora di creazione o all'artefatto del consenso
- Un token di accesso
L'esempio seguente mostra una richiesta GET che utilizza curl.
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"
Se la richiesta ha esito positivo, il server restituisce la risposta in formato 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
Per elencare i consensi in un archivio di consensi, invia una richiesta GET e specifica le seguenti informazioni:
- Il nome del set di dati principale
- Un filtro di ricerca facoltativo per recuperare i consensi in base all'ID utente, allo stato, all'ora di creazione o all'artefatto del consenso
- Un token di accesso
L'esempio seguente mostra una richiesta GET utilizzando Windows PowerShell.
$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
Se la richiesta ha esito positivo, il server restituisce la risposta in formato 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"
},
{
...
}
]
}
Puoi anche elencare le revisioni di un consenso specifico utilizzando il metodo projects.locations.datasets.consentStores.consents.listRevisions.
Aggiornamento dei consensi
Potresti dover aggiornare lo stato dei consensi nel tempo. Puoi farlo modificando lo stato del consenso. Ogni aggiornamento e modifica dello stato genera una nuova revisione del consenso. Le revisioni precedenti sono accessibili aggiungendo @{revision_id} al nome della risorsa del consenso.
Aggiornamento dei consensi
Per aggiornare i campi userId, policies, consentArtifact o revokeConsentArtifact di un consenso attivo o in bozza, utilizza il metodo projects.locations.datasets.consentStores.consents.patch. Viene eseguito il commit di una nuova revisione con le modifiche e viene impostato lo stato attuale.
Per aggiornare un consenso, invia una richiesta PATCH e specifica le seguenti informazioni nella richiesta:
- Il percorso REST del consenso da aggiornare
- I campi da aggiornare
- Una maschera di aggiornamento
- Un token di accesso
curl
L'esempio seguente mostra una richiesta PATCH che utilizza curl per aggiornare l'artefatto di consenso:
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"
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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
L'esempio seguente mostra una richiesta PATCH che utilizza Windows PowerShell per aggiornare l'artefatto di consenso:
$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
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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"
}
Attivazione dei consensi
Per modificare lo stato di un consenso da DRAFT a ACTIVE dopo che l'utente ha accettato il consenso, utilizza il metodo projects.locations.datasets.consentStores.consents.activateConsent. Viene eseguito il commit di una nuova revisione con lo stato ACTIVE. Quando lo stato del consenso è ACTIVE, il consenso viene incluso nelle richieste di determinazione dell'accesso.
Per attivare un consenso, effettua una richiesta POST e specifica le seguenti informazioni nella richiesta:
- Il percorso REST del consenso da attivare
- Il percorso REST di un artefatto facoltativo per documentare il motivo per cui il consenso è stato attivato
- Un token di accesso
curl
L'esempio seguente mostra una richiesta POST utilizzando curl:
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"
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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
L'esempio seguente mostra una richiesta POST utilizzando Windows PowerShell:
$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
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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"
}
Revoca e rifiuto dei consensi
Per modificare lo stato di un consenso da DRAFT a REJECTED, ad esempio se l'utente indica che il consenso non è accettabile, utilizza il metodo projects.locations.datasets.consentStores.consents.reject. Quando lo stato di un consenso è REJECTED, il consenso non è incluso nelle richieste di determinazione dell'accesso.
Per modificare lo stato di un consenso da ACTIVE a REVOKED, ad esempio se un utente richiede di annullare un consenso concesso in precedenza, utilizza il metodo projects.locations.datasets.consentStores.consents.revoke. Viene eseguito il commit di una nuova revisione con lo stato REVOKED. I consensi con uno stato REVOKED non sono inclusi nelle richieste di determinazione dell'accesso. Puoi creare un artefatto facoltativo associato al consenso per documentare il motivo della revoca del consenso. La revoca di un consenso non comporta l'eliminazione del consenso.
Per revocare un consenso, invia una richiesta POST e specifica le seguenti informazioni:
- Il percorso REST del consenso da revocare
- Il percorso REST di un artefatto facoltativo per documentare il motivo della revoca del consenso
- Un token di accesso
curl
L'esempio seguente mostra una richiesta POST utilizzando curl:
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"
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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
L'esempio seguente mostra una richiesta POST utilizzando Windows PowerShell:
$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
Se la richiesta ha esito positivo, il server restituisce una risposta simile al seguente esempio in formato 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"
}