diff --git a/healthcare/dicom/README.md b/healthcare/dicom/README.md index cadd6f61eb..959d25f09e 100644 --- a/healthcare/dicom/README.md +++ b/healthcare/dicom/README.md @@ -14,26 +14,26 @@ Run the following command to install the library dependencies for Node.js: ## DICOM stores - dicom_stores.js - Commands: - dicom_stores.js createDicomStore Creates a new DICOM store within the parent dataset. - dicom_stores.js deleteDicomStore Deletes the DICOM store and removes all resources that - are contained within it. - dicom_stores.js getDicomStore Gets the specified DICOM store or returns NOT_FOUND if - it doesn't exist. - dicom_stores.js listDicomStores Lists the DICOM stores in the given dataset. - dicom_stores.js patchDicomStore Updates the DICOM store. + node createDicomStore.js Creates a new DICOM store within the parent dataset. + node deleteDicomStore.js Deletes the DICOM store and removes all resources that + are contained within it. + node getDicomStore.js Gets the specified DICOM store or returns NOT_FOUND if + it doesn't exist. + node listDicomStores.js Lists the DICOM stores in the given dataset. + node patchDicomStore.js Updates the DICOM store. - dicom_stores.js importDicomObject Imports data into the DICOM store by copying it from the - specified source. - dicom_stores.js exportDicomInstanceGcs Exports data to a Cloud Storage bucket by copying it - from the DICOM store. + node importDicomInstance.js Imports data into the DICOM store by copying it from the + specified source. + node exportDicomInstanceGcs.js Exports data to a Cloud Storage bucket by copying it + from the DICOM store. + node getDicomStoreIamPolicy.js Gets the IAM policy for the HL7v2 store. + + node setDicomStoreIamPolicy.js Sets the IAM policy for the HL7v2store. + Options: --version Show version number [boolean] - --apiKey, -a The API key used for discovering the API. - [string] --cloudRegion, -c [string] [default: "us-central1"] --projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variables. [string] diff --git a/healthcare/dicom/getDicomStoreIamPolicy.js b/healthcare/dicom/getDicomStoreIamPolicy.js new file mode 100644 index 0000000000..625a6d1029 --- /dev/null +++ b/healthcare/dicom/getDicomStoreIamPolicy.js @@ -0,0 +1,58 @@ +/** + * Copyright 2019, Google, LLC + * Licensed under the Apache License, Version 2.0 (the `License`); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an `AS IS` BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable no-warning-comments */ + +'use strict'; + +function main( + projectId = process.env.GCLOUD_PROJECT, + cloudRegion = 'us-central1', + datasetId, + dicomStoreId +) { + // [START healthcare_dicom_store_get_iam_policy] + const {google} = require('googleapis'); + const healthcare = google.healthcare('v1beta1'); + + async function getDicomStoreIamPolicy() { + const auth = await google.auth.getClient({ + scopes: ['https://www.googleapis.com/auth/cloud-platform'], + }); + google.options({auth}); + + // TODO(developer): uncomment these lines before running the sample + // const cloudRegion = 'us-central1'; + // const projectId = 'adjective-noun-123'; + // const datasetId = 'my-dataset'; + // const dicomStoreId = 'my-dicom-store'; + const resource_ = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`; + const request = {resource_}; + + const dicomStore = await healthcare.projects.locations.datasets.dicomStores.getIamPolicy( + request + ); + console.log( + 'Got DICOM store IAM policy:', + JSON.stringify(dicomStore.data, null, 2) + ); + } + + getDicomStoreIamPolicy(); + // [END healthcare_dicom_store_get_iam_policy] +} + +// node getDicomStoreIamPolicy.js +main(...process.argv.slice(2)); diff --git a/healthcare/dicom/setDicomStoreIamPolicy.js b/healthcare/dicom/setDicomStoreIamPolicy.js new file mode 100644 index 0000000000..2d3680d975 --- /dev/null +++ b/healthcare/dicom/setDicomStoreIamPolicy.js @@ -0,0 +1,74 @@ +/** + * Copyright 2019, Google, LLC + * Licensed under the Apache License, Version 2.0 (the `License`); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an `AS IS` BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable no-warning-comments */ + +'use strict'; + +function main( + projectId = process.env.GCLOUD_PROJECT, + cloudRegion = 'us-central1', + datasetId, + dicomStoreId, + member, + role +) { + // [START healthcare_dicom_store_set_iam_policy] + const {google} = require('googleapis'); + const healthcare = google.healthcare('v1beta1'); + + async function setDicomStoreIamPolicy() { + const auth = await google.auth.getClient({ + scopes: ['https://www.googleapis.com/auth/cloud-platform'], + }); + google.options({auth}); + + // TODO(developer): uncomment these lines before running the sample + // const cloudRegion = 'us-central1'; + // const projectId = 'adjective-noun-123'; + // const datasetId = 'my-dataset'; + // const dicomStoreId = 'my-dicom-store'; + // const member = 'user:example@gmail.com'; + // const role = 'roles/healthcare.dicomStoreViewer'; + const resource_ = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`; + const request = { + resource_, + resource: { + policy: { + bindings: [ + { + members: member, + role: role, + }, + ], + }, + }, + }; + + const dicomStore = await healthcare.projects.locations.datasets.dicomStores.setIamPolicy( + request + ); + console.log( + 'Set DICOM store IAM policy:', + JSON.stringify(dicomStore.data, null, 2) + ); + } + + setDicomStoreIamPolicy(); + // [END healthcare_dicom_store_set_iam_policy] +} + +// node setDicomStoreIamPolicy.js +main(...process.argv.slice(2)); diff --git a/healthcare/dicom/system-test/dicom_stores.test.js b/healthcare/dicom/system-test/dicom_stores.test.js index d9fa7d5a3c..ca7f466f3c 100644 --- a/healthcare/dicom/system-test/dicom_stores.test.js +++ b/healthcare/dicom/system-test/dicom_stores.test.js @@ -108,6 +108,22 @@ it('should list DICOM stores', async () => { assert.ok(output.includes('dicomStores')); }); +it('should create and get a DICOM store IAM policy', async () => { + const localMember = 'group:dpebot@google.com'; + const localRole = 'roles/viewer'; + + let output = await tools.runAsync( + `node setDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${localMember} ${localRole}`, + cwd + ); + assert.ok(output.includes, 'ETAG'); + + output = await tools.runAsync( + `node getDicomStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId}` + ); + assert.ok(output.includes('dpebot')); +}); + it('should import a DICOM object from GCS', async () => { const output = await tools.runAsync( `node importDicomInstance.js ${projectId} ${cloudRegion} ${datasetId} ${dicomStoreId} ${gcsUri}`, diff --git a/healthcare/fhir/README.md b/healthcare/fhir/README.md index 6a1e41522c..06a70e8df2 100644 --- a/healthcare/fhir/README.md +++ b/healthcare/fhir/README.md @@ -23,8 +23,6 @@ Run the following command to install the library dependencies for Node.js: listFhirStores.js Lists the FHIR stores in the given dataset. patchFhirStore.js Updates the FHIR store. - getFhirStoreCapabilities.js Gets the capabilities statement for the FHIR store. - Options: --version Show version number [boolean] diff --git a/healthcare/hl7v2/README.md b/healthcare/hl7v2/README.md index e2b6db9872..2b8cd8144a 100644 --- a/healthcare/hl7v2/README.md +++ b/healthcare/hl7v2/README.md @@ -23,10 +23,10 @@ Run the following command to install the library dependencies for Node.js: node listHl7v2Stores.js Lists the HL7v2 stores in the given dataset. node patchHl7v2Store.js Updates the HL7v2 store. - getHl7v2StoreIamPolicy.js Gets the IAM policy for the HL7v2 store. - - setHl7v2StoreIamPolicy.js Sets the IAM policy for the HL7v2store. - + node getHl7v2StoreIamPolicy.js Gets the IAM policy for the HL7v2 store. + + node setHl7v2StoreIamPolicy.js Sets the IAM policy for the HL7v2store. + Options: --version Show version number [boolean]