本頁面說明如何使用 Identity and Access Management (IAM) 權限控管 Cloud Healthcare API 資料集和資料儲存庫的存取權。您可以使用 IAM 控管哪些使用者能存取您的資料集和資料儲存庫。如要進一步瞭解 Cloud Healthcare API 的 IAM,請參閱「存取權控管」一文。
IAM 政策總覽
資源的存取權可透過 IAM 政策進行管理。政策包含名為 bindings
的陣列。這個陣列包含一組繫結,這些繫結是主體 (例如使用者帳戶或服務帳戶) 與角色之間的關聯。政策可使用 JSON 或 YAML 來表示。
以下政策範例顯示 user-1@example.com
已獲授予 roles/healthcare.datasetAdmin
角色,而 user-2@example.com
和 service-account-13@appspot.gserviceaccount.com
則已獲授予 roles/healthcare.datasetViewer
角色:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
如要更新資源的政策,請使用讀取-修改-寫入模式。沒有專門用於建立、修改和撤銷使用者存取權的方法。
如要更新政策,請完成下列步驟:
- 呼叫資源的
getIamPolicy()
方法,讀取目前的政策。舉例來說,如要讀取資料集目前的政策,請呼叫projects.locations.datasets.getIamPolicy
。 - 使用文字編輯器或透過程式來編輯傳回的政策,藉此新增或移除任何適用的主體及其授予的角色。
- 呼叫資源的
setIamPolicy()
方法,寫入更新的政策。舉例來說,如要寫入資料集的更新政策,請呼叫projects.locations.datasets.setIamPolicy
。
搭配同意聲明儲存庫使用 IAM
以下各節說明如何取得、修改及設定同意聲明儲存庫的政策。這些章節會以下列範例政策做為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.consentStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
取得政策
下列範例說明如何讀取同意聲明儲存庫層級的 IAM 政策。詳情請參閱 projects.locations.datasets.consentStores.getIamPolicy
。
控制台
如要查看同意聲明儲存庫的 IAM 政策,請按照下列步驟操作:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含同意聲明儲存庫的資料集 ID,然後選取要取得政策的同意聲明儲存庫。
- 按一下「顯示資訊面板」。
- 如要查看指派給角色的主體,請展開該角色。
gcloud
如要查看同意儲存庫的 IAM 政策,請執行 gcloud healthcare consent-stores get-iam-policy
指令。指定同意事項儲存庫名稱、資料集名稱和位置。
gcloud healthcare consent-stores get-iam-policy CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
如果要求成功,系統就會顯示繫結。
bindings: - members: - user:user-1@example.com role: roles/healthcare.consentStoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.consentReader etag: bytes version: VERSION_NUMBER
Node.js
Python
curl
如要讀取同意聲明儲存庫的 IAM 政策,請發出 GET
要求,並指定資料集名稱、同意聲明儲存庫名稱和存取權存證。
以下範例顯示使用 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:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.consentStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
PowerShell
如要讀取同意聲明儲存庫的 IAM 政策,請發出 GET
要求,並指定資料集名稱、同意聲明儲存庫名稱和存取權存證。
以下範例顯示使用 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:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.consentStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
修改政策
以下範例會將 roles/healthcare.consentReader
角色授予新使用者。詳情請參閱 projects.locations.datasets.consentStores.setIamPolicy
。
設定政策
控制台
如要設定同意聲明儲存庫層級的 IAM 政策,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含同意聲明儲存庫的資料集 ID,然後選取要設定政策的同意聲明儲存庫。
- 按一下「顯示資訊面板」。
- 按一下「新增主體」。
- 在「New principals」(新增主體) 欄位中,輸入需要存取同意聲明儲存庫的一或多個身分。
- 在「Select a role」(請選擇角色) 清單的「Cloud Healthcare」(Cloud Healthcare) 下方,選取要授予的權限。例如 Healthcare 同意聲明存放區檢視器。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.consentReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除該主體的電子郵件地址。如要撤銷擁有角色的最後一個主體存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行適當的 set-iam-policy
指令來進行變更。如要設定同意聲明儲存層級政策,請執行 gcloud healthcare consent-stores set-iam-policy
指令。指定同意事項儲存庫名稱、資料集名稱、位置,以及您建立的政策檔案路徑。
gcloud healthcare consent-stores set-iam-policy CONSENT_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION \ POLICY_FILE_NAME
如果要求成功,系統就會顯示同意存放區名稱和繫結項目。
Updated IAM policy for consentStore [CONSENT_STORE_ID]. bindings: - members: - user:user-1@example.com role: roles/healthcare.consentStoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com - user:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.consentReader etag: bytes version: VERSION_NUMBER
Node.js
Python
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.consentReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.consentStores.setIamPolicy
進行更新。
如要設定同意聲明儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、同意聲明儲存庫名稱、政策和存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.consentReader
角色:
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.consentStoreAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role':'roles/healthcare.consentReader', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.consentStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.consentReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.consentStores.setIamPolicy
進行更新。
如要設定同意聲明儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、同意聲明儲存庫名稱、政策和存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求,將現有 roles/healthcare.consentReader
角色授予新使用者:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.consentStoreAdmin', 'members': [ 'user:user-1@example.com', ] }, { 'role': 'roles/healthcare.consentReader', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/consentStores/CONSENT_STORE_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.consentStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.consentReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
針對資料集使用 IAM
以下各節說明如何取得、修改及設定資料集的政策。這些章節會以下列範例政策做為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
取得政策
下列範例說明如何讀取資料集層級的 IAM 政策。詳情請參閱 projects.locations.datasets.getIamPolicy
。
curl
如要讀取資料集的 IAM 政策,請提出 GET
要求,並指定資料集名稱和存取權杖。
以下範例顯示使用 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:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
PowerShell
如要查看資料集的身分與存取權管理政策,請建立 GET
要求,並指定資料集名稱和存取權杖。
以下範例顯示使用 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:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
控制台
如要查看資料集的身分與存取權管理政策,請按照下列步驟操作:- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 選取資料集,然後按一下「Show info panel」。
- 如要查看指派給角色的主體,請展開該角色。
gcloud
如要查看資料集的 IAM 政策,請執行 gcloud healthcare datasets get-iam-policy
指令。指定資料集名稱和位置。
gcloud healthcare datasets get-iam-policy DATASET_ID \ --location=LOCATION
如果要求成功,系統就會顯示繫結。
bindings: - members: - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.datasetViewer etag: bytes version: VERSION_NUMBER
Go
Java
Node.js
Python
修改政策
以下範例會將 roles/healthcare.datasetViewer
角色授予新使用者:
設定政策
控制台
如要設定資料集層級的 IAM 政策,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 選取要設定政策的資料集,然後點選「顯示資訊面板」。
- 按一下「新增主體」。
- 在「New principals」欄位中,輸入需要存取資料集的一或多個身分。
- 在「Select a role」(請選擇角色) 清單的「Cloud Healthcare」(雲端健康照護) 下方,選取要授予的權限。例如 Healthcare 資料集檢視器。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.datasetViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除該主體的電子郵件地址。如要撤銷擁有角色的最後一個主體存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行適當的 set-iam-policy
指令來進行變更。如要設定資料集層級政策,請執行 gcloud healthcare datasets set-iam-policy
指令。指定資料集名稱、位置和您建立的政策檔案路徑。
gcloud healthcare datasets set-iam-policy DATASET_ID \ --location=LOCATION \ POLICY_FILE_NAME
如果要求成功,系統就會顯示資料集名稱和繫結。
Updated IAM policy for dataset [DATASET_ID]. bindings: - members: - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.datasetAdmin - user:user-1@example.com - user:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.datasetViewer etag: bytes version: VERSION_NUMBER
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.datasetViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.setIamPolicy
進行更新。
如要設定資料集層級的 IAM 政策,請提出 POST
要求,並指定資料集名稱、政策和存取權存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.datasetViewer
角色:
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.datasetAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role':'roles/healthcare.datasetViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.datasetViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.setIamPolicy
進行更新。
如要設定資料集層級的 IAM 政策,請提出 POST
要求,並指定資料集名稱、政策和存取權存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求,將現有 roles/healthcare.datasetViewer
角色授予新使用者:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.datasetAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role': 'roles/healthcare.datasetViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.datasetAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.datasetViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
Go
Java
Node.js
Python
搭配 DICOM 儲存庫使用 IAM
以下各節說明如何取得、修改及設定 DICOM 儲存庫的政策。這些章節會以下列範例政策做為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.dicomStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
取得政策
下列範例說明如何讀取 DICOM 儲存庫層級的 IAM 政策。詳情請參閱 projects.locations.datasets.dicomStores.getIamPolicy
。
控制台
如要查看 DICOM 儲存庫的身分與存取權管理政策,請按照下列步驟操作:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下含有 DICOM 儲存庫的資料集 ID,然後選取要取得政策的 DICOM 儲存庫。
- 按一下「顯示資訊面板」。
- 如要查看指派給角色的主體,請展開該角色。
gcloud
如要查看 DICOM 儲存庫的 IAM 政策,請執行 gcloud healthcare dicom-stores get-iam-policy
指令。指定 DICOM 儲存庫名稱、資料集名稱和位置。
gcloud healthcare dicom-stores get-iam-policy DICOM_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
如果要求成功,系統就會顯示繫結。
bindings: - members: - user:user-1@example.com role: roles/healthcare.dicomStoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.dicomViewer etag: bytes version: VERSION_NUMBER
Go
Java
Node.js
Python
curl
如要讀取 DICOM 儲存庫的 IAM 政策,請建立 GET
要求,並指定資料集名稱、DICOM 儲存庫名稱和存取權存證。
以下範例顯示使用 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/dicomStores/DICOM_STORE_ID:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.dicomStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
PowerShell
如要讀取 DICOM 儲存庫的 IAM 政策,請建立 GET
要求,並指定資料集名稱、DICOM 儲存庫名稱和存取權存證。
以下範例顯示使用 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/dicomStores/DICOM_STORE_ID:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.dicomStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
修改政策
以下範例會將 roles/healthcare.dicomViewer
角色授予新使用者。詳情請參閱 projects.locations.datasets.dicomStores.setIamPolicy
。
設定政策
控制台
如要設定 DICOM 儲存庫層級的 IAM 政策,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下含有 DICOM 儲存庫的資料集 ID,然後選取要設定政策的 DICOM 儲存庫。
- 按一下「顯示資訊面板」。
- 按一下「新增主體」。
- 在「New principals」欄位中,輸入需要存取 DICOM 存放區的一或多個身分。
- 在「Select a role」(請選擇角色) 清單的「Cloud Healthcare」(Cloud Healthcare) 下方,選取要授予的權限。例如 Healthcare DICOM 存放區檢視器。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.dicomViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行適當的 set-iam-policy
指令來進行變更。如要設定 DICOM 儲存層級政策,請執行 gcloud healthcare dicom-stores set-iam-policy
指令。指定 DICOM 儲存庫名稱、資料集名稱、位置,以及您建立的政策檔案路徑。
gcloud healthcare dicom-stores set-iam-policy DICOM_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION \ POLICY_FILE_NAME
如果要求成功,系統就會顯示 DICOM 儲存庫名稱和繫結。
Updated IAM policy for dicomStore [DICOM_STORE_ID]. bindings: - members: - user:user-1@example.com role: roles/healthcare.dicomStoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com - user:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.dicomViewer etag: bytes version: VERSION_NUMBER
Go
Java
Node.js
Python
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.dicomViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除該主體的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.dicomStores.setIamPolicy
進行更新。
如要設定 DICOM 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、DICOM 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.dicomViewer
角色:
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.dicomStoreAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role':'roles/healthcare.dicomViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.dicomStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新使用者,請將使用者的電子郵件地址附加到 roles/healthcare.dicomViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.dicomStores.setIamPolicy
進行更新。
如要設定 DICOM 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、DICOM 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求,將現有 roles/healthcare.dicomViewer
角色授予新使用者:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.dicomStoreAdmin', 'members': [ 'user:user-1@example.com', ] }, { 'role': 'roles/healthcare.dicomViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.dicomStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.dicomViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
搭配 FHIR 儲存庫使用 IAM
以下各節說明如何取得、修改及設定 FHIR 儲存庫的政策。這些章節會以下列範例政策做為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.fhirStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
取得政策
下列範例說明如何讀取 FHIR 儲存庫層級的 IAM 政策。詳情請參閱 projects.locations.datasets.fhirStores.getIamPolicy
。
控制台
如要查看 FHIR 儲存庫的身分與存取權管理政策,請按照下列步驟操作:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含 FHIR 儲存庫的資料集 ID,然後選取要取得政策的 FHIR 儲存庫。
- 按一下「顯示資訊面板」。
- 如要查看指派給角色的主體,請展開該角色。
gcloud
如要查看 FHIR 儲存庫的 IAM 政策,請執行 gcloud healthcare fhir-stores get-iam-policy
指令。指定 FHIR 儲存庫名稱、資料集名稱和位置。
gcloud healthcare fhir-stores get-iam-policy FHIR_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
如果要求成功,系統就會顯示繫結。
bindings: - members: - user:user-1@example.com role: roles/healthcare.fhirStoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.fhirResourceReader etag: bytes version: VERSION_NUMBER
Go
Java
Node.js
Python
curl
如要讀取 FHIR 儲存庫的 IAM 政策,請建立 POST
要求,並指定資料集名稱、FHIR 儲存庫名稱和存取權存證。
以下範例顯示使用 curl
的 POST
要求:
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/fhirStores/FHIR_STORE_ID:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.fhirStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
PowerShell
如要讀取 FHIR 儲存庫的 IAM 政策,請提出 POST
要求,並指定資料集名稱、FHIR 儲存庫名稱和存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求:
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.fhirStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
修改政策
以下範例會將 roles/healthcare.fhirResourceReader
角色授予新使用者。詳情請參閱 projects.locations.datasets.fhirStores.setIamPolicy
。
設定政策
控制台
如要設定 FHIR 儲存庫層級的 IAM 政策,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含 FHIR 儲存庫的資料集 ID,然後選取要設定政策的 FHIR 儲存庫。
- 按一下「顯示資訊面板」。
- 按一下「新增主體」。
- 在「New principals」欄位中,輸入需要存取 FHIR 儲存庫的一或多個身分。
- 在「Select a role」(請選擇角色) 清單的「Cloud Healthcare」(Cloud Healthcare) 下方,選取要授予的權限。例如 Healthcare FHIR 資源讀取器。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.fhirResourceReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除該主體的電子郵件地址。如要撤銷擁有角色的最後一個主體存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行適當的 set-iam-policy
指令來進行變更。如要設定 FHIR 儲存庫層級政策,請執行 gcloud healthcare fhir-stores set-iam-policy
指令。指定 FHIR 儲存庫名稱、資料集名稱、位置,以及您建立的政策檔案路徑。
gcloud healthcare fhir-stores set-iam-policy FHIR_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION \ POLICY_FILE_NAME
如果要求成功,系統會顯示 FHIR 儲存庫名稱和繫結。
Updated IAM policy for fhirStore [FHIR_STORE_ID]. bindings: - members: - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com - user:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.fhirResourceReader etag: bytes version: VERSION_NUMBER
Go
Java
Node.js
Python
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.fhirResourceReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.fhirStores.setIamPolicy
進行更新。
如要設定 FHIR 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、FHIR 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.fhirResourceReader
角色:
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.fhirStoreAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role':'roles/healthcare.fhirResourceReader', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.fhirStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.fhirResourceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.fhirResourceReader
繫結下的 members
陣列:
{ "role":"roles/healthcare.fhirResourceReader", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.fhirStores.setIamPolicy
進行更新。
如要設定 FHIR 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、FHIR 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求,將現有 roles/healthcare.fhirResourceReader
角色授予新使用者:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.fhirStoreAdmin', 'members': [ 'user:user-1@example.com', ] }, { 'role': 'roles/healthcare.fhirResourceReader', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.fhirStoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.fhirResourceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
搭配 HL7v2 儲存庫使用 IAM
以下各節說明如何取得、修改及設定 HL7v2 儲存庫的政策。這些章節會以下列範例政策做為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.hl7V2StoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
取得政策
下列範例說明如何讀取 HL7v2 儲存庫層級 IAM 政策。詳情請參閱 projects.locations.datasets.hl7V2Stores.getIamPolicy
。
控制台
如要查看 HL7v2 儲存庫的身分與存取權管理政策,請按照下列步驟操作:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含 HL7v2 儲存庫的資料集 ID,然後選取要取得政策的 HL7v2 儲存庫。
- 按一下「顯示資訊面板」。
- 如要查看指派給角色的主體,請展開該角色。
gcloud
如要查看 HL7v2 儲存庫的 IAM 政策,請執行 hl7v2-stores get-iam-policy
指令。指定 HL7v2 儲存庫名稱、資料集名稱和位置。
gcloud healthcare hl7v2-stores get-iam-policy HL7V2_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION
如果要求成功,系統就會顯示繫結。
bindings: - members: - user:user-1@example.com role: roles/healthcare.hl7v2StoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com role: roles/healthcare.hl7v2Consumer etag: bytes version: VERSION_NUMBER
curl
如要讀取 HL7v2 儲存庫的 IAM 政策,請建立 GET
要求,並指定資料集名稱、HL7v2 儲存庫名稱和存取權存證。
以下範例顯示使用 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/hl7V2Stores/HL7V2_STORE_ID:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.hl7V2StoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
PowerShell
如要讀取 HL7v2 儲存庫的 IAM 政策,請建立 GET
要求,並指定資料集名稱、HL7v2 儲存庫名稱和存取權存證。
以下範例顯示使用 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/hl7V2Stores/HL7V2_STORE_ID:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.hl7V2StoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com" ] } ] }
Go
Java
Node.js
Python
修改政策
以下範例會將 roles/healthcare.hl7V2Consumer
角色授予新使用者。詳情請參閱 projects.locations.datasets.hl7V2Stores.setIamPolicy
。
設定政策
控制台
如要設定 HL7v2 儲存庫層級身分與存取權管理政策,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「Datasets」(資料集) 頁面。
- 按一下包含 HL7v2 儲存庫的資料集 ID,然後選取要設定政策的 HL7v2 儲存庫。
- 按一下「顯示資訊面板」。
- 按一下「新增主體」。
- 在「New principals」欄位中,輸入需要存取 HL7v2 儲存庫的一或多個身分。
- 在「Select a role」(請選擇角色) 清單的「Cloud Healthcare」(Cloud Healthcare) 下方,選取要授予的權限。例如 Healthcare HL7v2 訊息使用者。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.hl7V2Consumer
繫結下的 members
陣列:
{ "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行適當的 set-iam-policy
指令來進行變更。如要設定 HL7v2 儲存庫層級政策,請執行 gcloud healthcare hl7v2-stores set-iam-policy
指令。指定 HL7v2 儲存庫名稱、資料集名稱、位置,以及您建立的政策檔案路徑。
gcloud healthcare hl7v2-stores set-iam-policy HL7V2_STORE_ID \ --dataset=DATASET_ID \ --location=LOCATION \ POLICY_FILE_NAME
如果要求成功,系統就會顯示 HL7v2 儲存名稱和繫結。
Updated IAM policy for hl7v2Store [HL7V2_STORE_ID]. bindings: - members: - user:user-1@example.com role: roles/healthcare.hl7v2StoreAdmin - serviceAccount:service-account-13@appspot.gserviceaccount.com - user:user-2@example.com - user:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.hl7v2Consumer etag: bytes version: VERSION_NUMBER
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.hl7V2Consumer
繫結下的 members
陣列:
{ "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.hl7V2Stores.setIamPolicy
進行更新。
如要設定 HL7v2 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、HL7v2 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.hl7V2Consumer
角色。
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.hl7V2StoreAdmin', 'members': [ 'user:user-1@example.com' ] }, { 'role':'roles/healthcare.hl7V2Consumer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.hl7V2StoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要授予新使用者角色,請將使用者的電子郵件地址附加到 roles/healthcare.hl7V2Consumer
繫結下的 members
陣列:
{ "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.locations.datasets.hl7V2Stores.setIamPolicy
進行更新。
如要設定 HL7v2 儲存庫層級的 IAM 政策,請建立 POST
要求,並指定資料集名稱、HL7v2 儲存庫名稱、政策和存取權杖。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.hl7V2Consumer
角色:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.hl7V2StoreAdmin', 'members': [ 'user:user-1@example.com', ] }, { 'role': 'roles/healthcare.hl7V2Consumer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'user:user-2@example.com', 'user:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.hl7V2StoreAdmin", "members": [ "user:user-1@example.com" ] }, { "role":"roles/healthcare.hl7V2Consumer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "user:user-2@example.com", "user:NEW_USER_EMAIL_ADDRESS" ] } ] }
Go
Java
Node.js
Python
搭配使用 IAM 和 Healthcare Natural Language API
以下各節說明如何取得、修改及設定 Healthcare Natural Language API 的政策。這些章節會以下列範例政策為起點:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com" ] } ] }
取得政策
以下範例說明如何讀取專案層級的 IAM 政策。詳情請參閱 projects.getIamPolicy
方法。
curl
如要讀取專案的 IAM 政策,請提出 POST
要求,並指定專案名稱和存取權杖。
以下範例顯示使用 curl
的 POST
要求:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://cloudresourcemanager.googleapis.com/v1/projects/PROJECT_ID:getIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com" ] } ] }
PowerShell
如要查看專案的 IAM 政策,請提出 POST
要求,並指定專案名稱和存取權杖。
以下範例顯示使用 Windows PowerShell 的 POST
要求:
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method POST ` -Headers $headers ` -Uri "https://cloudresourcemanager.googleapis.com/v1/projects/PROJECT_ID:getIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com" ] } ] }
控制台
如要查看專案的 IAM 政策,請完成下列步驟:
- 前往 Google Cloud 控制台的「IAM」頁面。
- 如要查看指派給角色的主體,請按一下「角色」,然後展開角色。
gcloud
如要查看專案的 IAM 政策,請執行 gcloud projects get-iam-policy
指令。請在要求中指定專案名稱。
gcloud projects get-iam-policy PROJECT_ID
如果要求成功,系統就會顯示繫結。
bindings: - members: - serviceAccount:service-account-13@appspot.gserviceaccount.com role: roles/healthcare.nlpServiceViewer etag: bytes version: VERSION_NUMBER
修改政策
以下範例會將 roles/healthcare.nlpServiceViewer
角色授予服務。詳情請參閱 projects.setIamPolicy
的說明。
設定政策
控制台
如要設定專案層級的 IAM 政策,請完成下列步驟:
- 前往 Google Cloud 控制台的「IAM」頁面。
- 按一下主體旁的「編輯」按鈕,或按一下「新增主體」,然後在「新主體」欄位中輸入需要存取專案的一或多個身分。
- 在「Select a role」(選取角色) 清單的「Cloud Healthcare」下方,選取「Healthcare Natural Language Service Viewer」(Healthcare Natural Language Service Viewer)。
- 按一下 [儲存]。
gcloud
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新服務帳戶,請將服務帳戶的電子郵件地址新增至 roles/healthcare.nlpServiceViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "serviceAccount:NEW_SERVICE_ACCOUNT_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請執行 gcloud projects set-iam-policy
指令進行變更。指定專案和您建立的政策檔案路徑。
gcloud projects set-iam-policy PROJECT_STORE_ID \ POLICY_FILE_NAME
如果要求成功,系統就會顯示專案名稱和繫結。
Updated IAM policy for project [PROJECT_ID]. bindings: - members: - serviceAccount:service-account-13@appspot.gserviceaccount.com - serviceAccount:NEW_USER_EMAIL_ADDRESS role: roles/healthcare.nlpServiceViewer etag: bytes version: VERSION_NUMBER
curl
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新服務帳戶,請將服務帳戶的電子郵件地址新增至 roles/healthcare.nlpServiceViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "serviceAccount:NEW_SERVICE_ACCOUNT_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.setIamPolicy
進行更新。
如要設定專案層級的 IAM 政策,請建立 POST
要求,並指定專案名稱、政策和存取權存證。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.nlpServiceViewer
角色:
Policy
。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ 'policy': { 'bindings': [ { 'role':'roles/healthcare.nlpServiceViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com' ] } ] } }" "https://cloudresourcemanager.googleapis.com/v1/projects/PROJECT_ID:setIamPolicy"
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com" ] } ] }
PowerShell
透過程式或使用文字編輯器修改您擷取的政策,將角色授予使用者或撤銷其角色。政策變更時,etag
值也會變更,因此您必須指定目前的值。
如要將角色授予新服務帳戶,請將服務帳戶的電子郵件地址新增至 roles/healthcare.nlpServiceViewer
繫結下的 members
陣列:
{ "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "serviceAccount:NEW_SERVICE_ACCOUNT_EMAIL_ADDRESS" ] }
members
陣列中刪除對方的電子郵件地址。如要撤銷擁有角色的最後一個主體的存取權,請刪除該角色的 bindings
陣列。政策中不得包含空白 bindings
陣列。
修改政策以授予適用的角色後,請呼叫 projects.setIamPolicy
進行更新。
如要設定專案層級的 IAM 政策,請建立 POST
要求,並指定專案名稱、政策和存取權存證。
以下範例顯示使用 curl
的 POST
要求,可為新使用者授予現有的 roles/healthcare.nlpServiceViewer
角色:
Policy
。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body "{ 'policy': { 'bindings': [ { 'role': 'roles/healthcare.nlpServiceViewer', 'members': [ 'serviceAccount:service-account-13@appspot.gserviceaccount.com', 'serviceAccount:NEW_USER_EMAIL_ADDRESS' ] } ] } }" ` -Uri "https://cloudresourcemanager.googleapis.com/v1/projects/PROJECT_ID:setIamPolicy" | Select-Object -Expand Content
回應如下:
{ "etag":"bytes", "bindings": [ { "role":"roles/healthcare.nlpServiceViewer", "members": [ "serviceAccount:service-account-13@appspot.gserviceaccount.com", "serviceAccount:NEW_USER_EMAIL_ADDRESS" ] } ] }