Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HC API READMEs and add IAM samples for DICOM #1382

Merged
merged 4 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions healthcare/dicom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ Run the following command to install the library dependencies for Node.js:

## DICOM stores

dicom_stores.js <command>

Commands:
dicom_stores.js createDicomStore <datasetId> <dicomStoreId> Creates a new DICOM store within the parent dataset.
dicom_stores.js deleteDicomStore <datasetId> <dicomStoreId> Deletes the DICOM store and removes all resources that
are contained within it.
dicom_stores.js getDicomStore <datasetId> <dicomStoreId> Gets the specified DICOM store or returns NOT_FOUND if
it doesn't exist.
dicom_stores.js listDicomStores <datasetId> Lists the DICOM stores in the given dataset.
dicom_stores.js patchDicomStore <datasetId> <dicomStoreId> Updates the DICOM store.
node createDicomStore.js <projectId> <cloudRegion> <datasetId> <dicomStoreId> Creates a new DICOM store within the parent dataset.
node deleteDicomStore.js <projectId> <cloudRegion> <datasetId> <dicomStoreId> Deletes the DICOM store and removes all resources that
are contained within it.
node getDicomStore.js <projectId> <cloudRegion> <datasetId> <dicomStoreId> Gets the specified DICOM store or returns NOT_FOUND if
it doesn't exist.
node listDicomStores.js <projectId> <cloudRegion> <datasetId> Lists the DICOM stores in the given dataset.
node patchDicomStore.js <projectId> <cloudRegion> <datasetId> <dicomStoreId> Updates the DICOM store.
<pubsubTopic>
dicom_stores.js importDicomObject <datasetId> <dicomStoreId> Imports data into the DICOM store by copying it from the
<contentUri> specified source.
dicom_stores.js exportDicomInstanceGcs <datasetId> Exports data to a Cloud Storage bucket by copying it
<dicomStoreId> <uriPrefix> from the DICOM store.
node importDicomInstance.js <projectId> <cloudRegion> <datasetId> Imports data into the DICOM store by copying it from the
<dicomStoreId> <gcsUri> specified source.
node exportDicomInstanceGcs.js <projectId> <cloudRegion> <datasetId> Exports data to a Cloud Storage bucket by copying it
<dicomStoreId> <uriPrefix> from the DICOM store.
node getDicomStoreIamPolicy.js <projectId> Gets the IAM policy for the HL7v2 store.
<cloudRegion> <datasetId> <dicomStoreId>
node setDicomStoreIamPolicy.js <projectId> Sets the IAM policy for the HL7v2store.
<cloudRegion> <datasetId> <dicomStoreId> <member> <role>

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]
Expand Down
58 changes: 58 additions & 0 deletions healthcare/dicom/getDicomStoreIamPolicy.js
Original file line number Diff line number Diff line change
@@ -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 <projectId> <cloudRegion> <datasetId> <dicomStoreId>
main(...process.argv.slice(2));
74 changes: 74 additions & 0 deletions healthcare/dicom/setDicomStoreIamPolicy.js
Original file line number Diff line number Diff line change
@@ -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 <projectId> <cloudRegion> <datasetId> <dicomStoreId> <member> <role>
main(...process.argv.slice(2));
16 changes: 16 additions & 0 deletions healthcare/dicom/system-test/dicom_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
2 changes: 0 additions & 2 deletions healthcare/fhir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Run the following command to install the library dependencies for Node.js:
listFhirStores.js <projectId> <cloudRegion> <datasetId> Lists the FHIR stores in the given dataset.
patchFhirStore.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> Updates the FHIR store.
<pubsubTopic>
getFhirStoreCapabilities.js <projectId> <cloudRegion> <datasetId> Gets the capabilities statement for the FHIR store.
<fhirStoreId>

Options:
--version Show version number [boolean]
Expand Down
8 changes: 4 additions & 4 deletions healthcare/hl7v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Run the following command to install the library dependencies for Node.js:
node listHl7v2Stores.js <datasetId> Lists the HL7v2 stores in the given dataset.
node patchHl7v2Store.js <datasetId> <hl7v2StoreId> Updates the HL7v2 store.
<pubsubTopic>
getHl7v2StoreIamPolicy.js <projectId> <cloudRegion> <datasetId> Gets the IAM policy for the HL7v2 store.
<hl7v2StoreId>
setHl7v2StoreIamPolicy.js <projectId> <cloudRegion> <datasetId> Sets the IAM policy for the HL7v2store.
<hl7v2StoreId> <member> <role>
node getHl7v2StoreIamPolicy.js <projectId> Gets the IAM policy for the HL7v2 store.
<cloudRegion> <datasetId> <hl7v2StoreId>
node setHl7v2StoreIamPolicy.js <projectId> Sets the IAM policy for the HL7v2store.
<cloudRegion> <datasetId> <hl7v2StoreId> <member> <role>

Options:
--version Show version number [boolean]
Expand Down