From 668a417fbaea568ccaa3c7334514b1343e4136d7 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:30:28 -0400 Subject: [PATCH 01/31] added GetImageFrame --- .../actions/get-image-frame.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 javascriptv3/example_code/medical-imaging/actions/get-image-frame.js diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js new file mode 100644 index 00000000000..b5c8977ecb8 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -0,0 +1,66 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; +self.importScripts(".js/openjphjs.js") +import { writeFileSync } from "fs"; + +// snippet-start:[medical-imaging.JavaScript.datastore.getDatastoreV3] +import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +let decoder; +// eslint-disable-next-line no-undef +Module.onRuntimeInitialized = () => { + // eslint-disable-next-line no-undef + decoder = new Module.HTJ2KDecoder(); + isWorkerReady.resolve(null); +}; + +/** + * @param {string} datastoreID - The ID of the datastore to retrieve properties for. + */ +export const getImageFrame = async (datastoreID = "DATASTORE_ID", + imageSetID = "IMAGE_SET_ID", + imageFrameID = "IMAGE_FRAME_ID") => { + const response = await medicalImagingClient.send( + new GetImageFrameCommand({datastoreId: datastoreID, + imageSetId: imageSetID, + imageFrameInformation: {imageFrameId : imageFrameID}}) + ); + + + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '55ea7d2e-222c-4a6a-871e-4f591f40cadb', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreProperties: { + // createdAt: 2023-08-04T18:50:36.239Z, + // datastoreArn: 'arn:aws:medical-imaging:us-east-1:123456789:datastore/1234567890abcdef01234567890abcde', + // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreName: 'my_datastore', + // datastoreStatus: 'ACTIVE', + // updatedAt: 2023-08-04T18:50:36.239Z + // } + // } + return response +}; +// snippet-end:[medical-imaging.JavaScript.datastore.getDatastoreV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + const response = await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "11290736aa3544da28a3afad02ec128a", "8560ba4972a0244e11fd2459835dd67a"); + + // const buffer = await response.arrayBuffer(); + //writeFileSync("image.jph", buffer); + +} From cb408632a462422fab778bce80c200fd9b1e24c9 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:22:26 -0400 Subject: [PATCH 02/31] initial commit --- .../actions/create-datastore.js | 2 +- .../medical-imaging/actions/get-datastore.js | 1 - .../actions/get-dicom-import-job.js | 41 +++++++++++++ .../actions/start-dicom-import-job.js | 59 +++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js diff --git a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js index 0521120dfad..fc625b84064 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -35,5 +35,5 @@ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await createDatastore("test-result"); + await createDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index 8ac9f8641ce..72f1a16cf1c 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -28,7 +28,6 @@ export const getDatastore = async (datastoreID = "DATASTORE_ID") => { // }, // datastoreProperties: { // createdAt: 2023-08-04T18:50:36.239Z, - // datastoreArn: 'arn:aws:medical-imaging:us-east-1:123456789:datastore/1234567890abcdef01234567890abcde', // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // datastoreName: 'my_datastore', diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js new file mode 100644 index 00000000000..68e6de87099 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -0,0 +1,41 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.getDICONImportJobV3] +import {GetDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreName - The name of the datastore to create. + */ +export const getDICOMImportJob = async (datastoreId = "DATASTORE_NAME", jobId = "JOB_ID") => {= async (datastoreName = "DATASTORE_NAME") => { + const response = await medicalImagingClient.send( + new CreateDatastoreCommand({datastoreName: datastoreName}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobStatus: 'SUBMITTED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await createDatastore("test-result"); + } diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js new file mode 100644 index 00000000000..c91277c6188 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -0,0 +1,59 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.startDicomImportJobV3] +import {StartDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} jobName - The name of the job. + * @param {string} datastoreId - The ID of the data store. + * @param {string} dataAccessRoleArn - The Amazon Resource Name (ARN) of the role that grants permission. + * @param {string} inputS3Uri - The URI of the S3 bucket containing the input files. + * @param {string} outputS3Uri - The URI of the S3 bucket where the output files are stored. + */ +export const startDicomImportJob = async (jobName = "test-1", + datastoreId = "12345678901234567890123456789012", + dataAccessRoleArn = "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", + inputS3Uri = "s3://medical-imaging-dicom-input/dicom_input/", + outputS3Uri = "s3://medical-imaging-output/job_output/") => { + const response = await medicalImagingClient.send( + new StartDICOMImportJobCommand({ + jobName: jobName, + datastoreId: datastoreId, + dataAccessRoleArn: dataAccessRoleArn, + inputS3Uri: inputS3Uri, + outputS3Uri: outputS3Uri + }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobStatus: 'SUBMITTED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await startDicomImportJob("test-1", + "728f13a131f748bf8d87a55d5ef6c5af", + "arn:aws:iam::123502194722:role/dicom_import", + "s3://healthimaging-source-37eyet88/CRStudy/", + "s3://health-imaging-dest-ier9e86w/ouput_cr/"); +} From 79ac451b4a13b23cc9a4f570a7853ea827c4efdb Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:15:41 -0400 Subject: [PATCH 03/31] added 3 actions --- .../actions/get-dicom-import-job.js | 30 ++++++++---- .../actions/list-dicom-import-jobs.js | 48 +++++++++++++++++++ .../actions/start-dicom-import-job.js | 8 +--- 3 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index 68e6de87099..7f9ff5cd827 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -10,32 +10,42 @@ import {GetDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreName - The name of the datastore to create. + * @param {string} datastoreId - The ID of the datastore. + * @param {string} jobId - The ID of the job. */ -export const getDICOMImportJob = async (datastoreId = "DATASTORE_NAME", jobId = "JOB_ID") => {= async (datastoreName = "DATASTORE_NAME") => { +export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", + jobId = "xxxxxxxxxxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new CreateDatastoreCommand({datastoreName: datastoreName}) + new GetDICOMImportJobCommand({datastoreId : datastoreId, jobId : jobId}) ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, - // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // requestId: 'a2637936-78ea-44e7-98b8-7a87d95dfaee', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobStatus: 'SUBMITTED', - // submittedAt: 2023-09-22T14:48:45.767Z + // jobProperties: { + // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // endedAt: 2023-09-19T17:29:21.753Z, + // inputS3Uri: 's3://healthimaging-source/CTStudy/', + // jobId: ''xxxxxxxxxxxxxxxxxxxxxxxxx'', + // jobName: 'job_1', + // jobStatus: 'COMPLETED', + // outputS3Uri: 's3://health-imaging-dest/ouput_ct/'xxxxxxxxxxxxxxxxxxxxxxxxx'-DicomImport-'xxxxxxxxxxxxxxxxxxxxxxxxx'/', + // submittedAt: 2023-09-19T17:27:25.143Z + // } // } + return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] +// snippet-end:[medical-imaging.JavaScript.datastore.getDICONImportJobV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await createDatastore("test-result"); + await getDICOMImportJob(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js new file mode 100644 index 00000000000..c8eaaa516dc --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -0,0 +1,48 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.listDICOMImportJobsV3] +import {ListDICOMImportJobsCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The ID of the datastore. + */ +export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => { + const response = await medicalImagingClient.send( + new ListDICOMImportJobsCommand({datastoreId : datastoreId}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '3c20c66e-0797-446a-a1d8-91b742fd15a0', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // jobSummaries: [ + // { + // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // endedAt: 2023-09-22T14:49:51.351Z, + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // jobName: 'test-1', + // jobStatus: 'COMPLETED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + // ]} + + return response; +}; +// snippet-end:[medical-imaging.JavaScript.datastore.listDICOMImportJobsV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await listDICOMImportJobs(); + } diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js index c91277c6188..f4e9fedea63 100644 --- a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -47,13 +47,9 @@ export const startDicomImportJob = async (jobName = "test-1", // } return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] +// snippet-end:[medical-imaging.JavaScript.datastore.startDicomImportJobV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await startDicomImportJob("test-1", - "728f13a131f748bf8d87a55d5ef6c5af", - "arn:aws:iam::123502194722:role/dicom_import", - "s3://healthimaging-source-37eyet88/CRStudy/", - "s3://health-imaging-dest-ier9e86w/ouput_cr/"); + await startDicomImportJob(); } From 7645e2ba0040678119a0cf5f11f74022942fcfff Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:53:57 -0400 Subject: [PATCH 04/31] added 3 more actions --- .../actions/get-image-set-metadata.js | 51 +++++++++++++++++ .../medical-imaging/actions/get-image-set.js | 55 +++++++++++++++++++ .../actions/list-image-set-versions.js | 39 +++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/get-image-set.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js new file mode 100644 index 00000000000..834c55bf855 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -0,0 +1,51 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] +import {GetImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import {writeFileSync} from "fs"; + +/** + * @param {string} datastoreId - The ID of the datastore to create. + * @param {string} imagesetId - The ID of the imageset to create. + * @param {string} metadataFileName - The name of the file for gzipped metadata. + */ +export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", + imagesetId = "xxxxxxxxxxxxxx", + metadataFileName = "metadata.json.gzip") => { + const response = await medicalImagingClient.send( + new GetImageSetMetadataCommand({datastoreId: datastoreId, imageSetId: imagesetId}) + ); + const buffer = await response.imageSetMetadataBlob.transformToByteArray(); + writeFileSync(metadataFileName, buffer); + + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '5219b274-30ff-4986-8cab-48753de3a599', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // contentType: 'application/json', + // contentEncoding: 'gzip', + // imageSetMetadataBlob: IncomingMessage {} + // } + + return response; +} + +// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await getImageSetMetadata("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0"); +} + diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js new file mode 100644 index 00000000000..b2689d07678 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -0,0 +1,55 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.getImageSetV3] +import {GetImageSetCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The ID of the data store. + * @param {string} imageSetId - The ID of the image set. + * @param {string} imageSetVersion - The optional version of the image set. + * + */ +export const getImageSet = async (datastoreId= "xxxxxxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxxxxx", + imageSetVersion = "") => { + let params = {datastoreId: datastoreId, imageSetId: imageSetId }; + if (imageSetVersion != "") { + params.imageSetVersion = imageSetVersion; + } + const response = await medicalImagingClient.send( + new GetImageSetCommand(params)); + console.log( response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '0615c161-410d-4d06-9d8c-6e1241bb0a5a', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // createdAt: 2023-09-22T14:49:26.427Z, + // datastoreId: 'xxxxxxxxxxxxxxx', + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'ACTIVE', + // imageSetWorkflowStatus: 'CREATED', + // updatedAt: 2023-09-22T14:49:26.427Z, + // versionId: '1' + // } + + return response; +} + +// snippet-end:[medical-imaging.JavaScript.datastore.getImageSetV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await getImageSet(); + } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js new file mode 100644 index 00000000000..dff0d9cd481 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -0,0 +1,39 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] +import {CreateDatastoreCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreName - The name of the datastore to create. + */ +export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { + const response = await medicalImagingClient.send( + new CreateDatastoreCommand({datastoreName: datastoreName}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreStatus: 'CREATING' + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await createDatastore("test-result"); + } From 4df652b185f0032ac63d1775971adca80e4c1f4d Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:48:11 -0400 Subject: [PATCH 05/31] adding actions --- .../actions/list-image-set-versions.js | 41 +++++++----- .../actions/update-image-set-metadata.js | 64 +++++++++++++++++++ 2 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index dff0d9cd481..fb860e70724 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -5,35 +5,42 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] -import {CreateDatastoreCommand} from "@aws-sdk/client-medical-imaging"; +// snippet-start:[medical-imaging.JavaScript.datastore.listImageSetVersionsV3] +import {ListImageSetVersionsCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreName - The name of the datastore to create. + * @param {string} datastoreId - The ID of the datastore. + * @param {string} imageSetId - The ID of the image set. */ -export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { +export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new CreateDatastoreCommand({datastoreName: datastoreName}) + new ListImageSetVersionsCommand({datastoreId : datastoreId, imageSetId : imageSetId}) ); console.log(response); // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreStatus: 'CREATING' + // '$metadata': { + // httpStatusCode: 200, + // requestId: '74590b37-a002-4827-83f2-3c590279c742', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // imageSetPropertiesList: [ + // { + // ImageSetWorkflowStatus: 'CREATED', + // createdAt: 2023-09-22T14:49:26.427Z, + // imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxx', + // imageSetState: 'ACTIVE', + // versionId: '1' + // }] // } return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] +// snippet-end:[medical-imaging.JavaScript.datastore.listImageSetVersionsV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await createDatastore("test-result"); + await listImageSetVersions("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js new file mode 100644 index 00000000000..39dace80f20 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -0,0 +1,64 @@ +/* +* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +* SPDX-License-Identifier: Apache-2.0 +*/ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] +import {UpdateImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; +import {MedicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreID - The ID of the medical imaging data store. + * @param {string} imageSetID - The ID of the medical imaging image set. + * @param {string} latestVersionID - The ID of the medical imaging image set version. + * @param {{}} updateMetadata - The metadata to update. + * - Example metadata: + * { + * DICOMUpdates: { + * updatableAttributes: "{ + * \"SchemaVersion\": 1.1, + * \"Patient\": { + * \"DICOM\": { + * \"PatientName\": \"Garcia^Gloria\" + * } + * } + * }" + * } + * } + */ +export const updateImageSetMetadata = async (datastoreID = "xxxxxxxxxx", + imageSetID = "xxxxxxxxxx", + latestVersionID = "1", + updateMetadata = {}) => { + const response = await medicalImagingClient.send( + new UpdateImageSetMetadataCommand({ datastoreID : datastoreID, + imageSetID : imageSetID, + latestVersionID : latestVersionID, + updateMetadata : updateMetadata}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobStatus: 'SUBMITTED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await updateImageSetMetadata(); +} + From a426c6d154fa76998a22a5a682857d6531f79f4a Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:41:01 -0400 Subject: [PATCH 06/31] text fixes and update image set --- .../actions/get-dicom-import-job.js | 2 +- .../actions/get-image-frame.js | 2 +- .../actions/get-image-set-metadata.js | 4 +- .../actions/list-dicom-import-jobs.js | 2 +- .../actions/list-image-set-versions.js | 2 +- .../actions/update-image-set-metadata.js | 75 +++++++++++-------- 6 files changed, 50 insertions(+), 37 deletions(-) diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index 7f9ff5cd827..b4c5fdf320f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -10,7 +10,7 @@ import {GetDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreId - The ID of the datastore. + * @param {string} datastoreId - The ID of the data store. * @param {string} jobId - The ID of the job. */ export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index b5c8977ecb8..1cd41277aa8 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -20,7 +20,7 @@ Module.onRuntimeInitialized = () => { }; /** - * @param {string} datastoreID - The ID of the datastore to retrieve properties for. + * @param {string} datastoreID - The ID of the data store to retrieve properties for. */ export const getImageFrame = async (datastoreID = "DATASTORE_ID", imageSetID = "IMAGE_SET_ID", diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index 834c55bf855..b3bc51def7c 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -11,8 +11,8 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; import {writeFileSync} from "fs"; /** - * @param {string} datastoreId - The ID of the datastore to create. - * @param {string} imagesetId - The ID of the imageset to create. + * @param {string} datastoreId - The ID of the data store. + * @param {string} imagesetId - The ID of the image set. * @param {string} metadataFileName - The name of the file for gzipped metadata. */ export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index c8eaaa516dc..11cd61c32cc 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -10,7 +10,7 @@ import {ListDICOMImportJobsCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreId - The ID of the datastore. + * @param {string} datastoreId - The ID of the data store. */ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => { const response = await medicalImagingClient.send( diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index fb860e70724..6c13129e192 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -10,7 +10,7 @@ import {ListImageSetVersionsCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreId - The ID of the datastore. + * @param {string} datastoreId - The ID of the data store. * @param {string} imageSetId - The ID of the image set. */ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx") => { diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js index 39dace80f20..dfcb2dc18b9 100644 --- a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -7,58 +7,71 @@ import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] import {UpdateImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; -import {MedicalImagingClient} from "../libs/medicalImagingClient.js"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreID - The ID of the medical imaging data store. - * @param {string} imageSetID - The ID of the medical imaging image set. - * @param {string} latestVersionID - The ID of the medical imaging image set version. + * @param {string} datastoreId - The ID of the HealthImaging data store. + * @param {string} imageSetId - The ID of the HealthImaging image set. + * @param {string} latestVersionId - The ID of the HealthImaging image set version. * @param {{}} updateMetadata - The metadata to update. - * - Example metadata: - * { - * DICOMUpdates: { - * updatableAttributes: "{ - * \"SchemaVersion\": 1.1, - * \"Patient\": { - * \"DICOM\": { - * \"PatientName\": \"Garcia^Gloria\" - * } - * } - * }" - * } - * } */ -export const updateImageSetMetadata = async (datastoreID = "xxxxxxxxxx", - imageSetID = "xxxxxxxxxx", - latestVersionID = "1", - updateMetadata = {}) => { +export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", + imageSetId = "xxxxxxxxxx", + latestVersionId = "1", + updateMetadata = '{}') => { const response = await medicalImagingClient.send( - new UpdateImageSetMetadataCommand({ datastoreID : datastoreID, - imageSetID : imageSetID, - latestVersionID : latestVersionID, - updateMetadata : updateMetadata}) + new UpdateImageSetMetadataCommand({ + datastoreId: datastoreId, + imageSetId: imageSetId, + latestVersionId: latestVersionId, + updateImageSetMetadataUpdates: updateMetadata + }) ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, - // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // requestId: '7966e869-e311-4bff-92ec-56a61d3003ea', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobStatus: 'SUBMITTED', - // submittedAt: 2023-09-22T14:48:45.767Z + // createdAt: 2023-09-22T14:49:26.427Z, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'UPDATING', + // latestVersionId: '4', + // updatedAt: 2023-09-27T19:41:43.494Z // } return response; }; // snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] // Invoke main function if this file was run directly. + if (process.argv[1] === fileURLToPath(import.meta.url)) { - await updateImageSetMetadata(); +// snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] + const updatableAttributes = + '{' + + ' "SchemaVersion": 1.1,' + + ' "Patient": {' + + ' "DICOM": {' + + ' "PatientName": "Garcia^Gloria"' + + ' }' + + ' }' + + '}'; + + const updateMetadata = { + "DICOMUpdates": { + "updatableAttributes": + new TextEncoder().encode(updatableAttributes) + } + }; + + await updateImageSetMetadata("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", + "3", updateMetadata); +// snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] } From 9d73418f020f0f79f37b57eba9faec0c6f0a4bd3 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:20:29 -0400 Subject: [PATCH 07/31] all actions complete --- .../medical-imaging/actions/copy-image-set.js | 76 +++++++++++++++++++ .../actions/delete-image-set.js | 42 ++++++++++ .../actions/get-dicom-import-job.js | 4 +- .../actions/get-image-frame.js | 4 +- .../actions/get-image-set-metadata.js | 4 +- .../medical-imaging/actions/get-image-set.js | 4 +- .../actions/list-dicom-import-jobs.js | 4 +- .../actions/list-image-set-versions.js | 4 +- .../actions/list-tags-for-resource.js | 39 ++++++++++ .../actions/start-dicom-import-job.js | 4 +- .../medical-imaging/actions/tag-resource.js | 42 ++++++++++ .../medical-imaging/actions/untag-resource.js | 41 ++++++++++ .../tests/start-dicom-import-job.unit.test.js | 47 ++++++++++++ 13 files changed, 301 insertions(+), 14 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/actions/copy-image-set.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/delete-image-set.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/tag-resource.js create mode 100644 javascriptv3/example_code/medical-imaging/actions/untag-resource.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js diff --git a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js new file mode 100644 index 00000000000..4173977e11c --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -0,0 +1,76 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3] +import {CopyImageSetCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The ID of the data store. + * @param {string} imageSetId - The source image set ID. + * @param {string} sourceVersionID - The source version ID. + * @param {string} destinationImageSetId - The optional ID of the destination image set. + * @param {string} destinationVersionId - The optional version ID of the destination image set. + */ +export const copyImageSet = async (datastoreId = "xxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx", + sourceVersionID = "1", destinationImageSetId = "", + destinationVersionId = "") => { + let params = { + datastoreId: datastoreId, + sourceImageSetId: imageSetId, + copyImageSetInformation: { + sourceImageSet: {latestVersionId: sourceVersionID} + } + }; + if (destinationImageSetId !== "" && destinationVersionId !== "") { + params.copyImageSetInformation.destinationImageSet = { + imageSetId: destinationImageSetId, + latestVersionId: destinationVersionId + }; + } + + const response = await medicalImagingClient.send( + new CopyImageSetCommand(params) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxx', + // destinationImageSetProperties: { + // createdAt: 2023-09-27T19:46:21.824Z, + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'COPYING', + // latestVersionId: '1', + // updatedAt: 2023-09-27T19:46:21.824Z + // }, + // sourceImageSetProperties: { + // createdAt: 2023-09-22T14:49:26.427Z, + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', + // latestVersionId: '4', + // updatedAt: 2023-09-27T19:46:21.824Z + // } + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await copyImageSet(); +} diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js new file mode 100644 index 00000000000..789666af2f9 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js @@ -0,0 +1,42 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.imageset.deleteImageSetV3] +import {DeleteImageSetCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The data store ID. + * @param {string} imageSetId - The image set ID. + */ +export const deleteImageSet = async (datastoreId = "xxxxxxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxxxxxx") => { + const response = await medicalImagingClient.send( + new DeleteImageSetCommand({datastoreId : datastoreId, imageSetId : imageSetId}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'DELETING' + // } + return response; +}; +// snippet-end:[medical-imaging.JavaScript.imageset.deleteImageSetV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await deleteImageSet("728f13a131f748bf8d87a55d5ef6c5af", "906e1c0ff5e9c69a14a9e4d36e0cea1e"); + } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index b4c5fdf320f..94a1bbe7b4d 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.getDICONImportJobV3] +// snippet-start:[medical-imaging.JavaScript.dicom.getDICOMImportJobV3] import {GetDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -43,7 +43,7 @@ export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.getDICONImportJobV3] +// snippet-end:[medical-imaging.JavaScript.dicom.getDICOMImportJobV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index 1cd41277aa8..69e434ffc03 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -7,7 +7,7 @@ import {fileURLToPath} from "url"; self.importScripts(".js/openjphjs.js") import { writeFileSync } from "fs"; -// snippet-start:[medical-imaging.JavaScript.datastore.getDatastoreV3] +// snippet-start:[medical-imaging.JavaScript.imageset.getImageFrameV3] import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -54,7 +54,7 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", // } return response }; -// snippet-end:[medical-imaging.JavaScript.datastore.getDatastoreV3] +// snippet-end:[medical-imaging.JavaScript.imageset.getImageFrameV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index b3bc51def7c..e2ba24ef83b 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] +// snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3] import {GetImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; import {writeFileSync} from "fs"; @@ -42,7 +42,7 @@ export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", return response; } -// snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] +// snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js index b2689d07678..0b70af0cf97 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.getImageSetV3] +// snippet-start:[medical-imaging.JavaScript.imageset.getImageSetV3] import {GetImageSetCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -47,7 +47,7 @@ export const getImageSet = async (datastoreId= "xxxxxxxxxxxxxxx", return response; } -// snippet-end:[medical-imaging.JavaScript.datastore.getImageSetV3] +// snippet-end:[medical-imaging.JavaScript.imageset.getImageSetV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index 11cd61c32cc..a1b72bcb74e 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.listDICOMImportJobsV3] +// snippet-start:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] import {ListDICOMImportJobsCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -40,7 +40,7 @@ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.listDICOMImportJobsV3] +// snippet-end:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index 6c13129e192..41d161edfcb 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.listImageSetVersionsV3] +// snippet-start:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] import {ListImageSetVersionsCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -38,7 +38,7 @@ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSe // } return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.listImageSetVersionsV3] +// snippet-end:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js new file mode 100644 index 00000000000..918e67f6392 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js @@ -0,0 +1,39 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.resource.listTagsForResourceV3] +import {ListTagsForResourceCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. + */ +export const listTagsForResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxx:datastore/xxx/imageset/xxx") => { + const response = await medicalImagingClient.send( + new ListTagsForResourceCommand({resourceArn : resourceArn}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // tags: { Deployment: 'Development' } + // } + + return response; +}; +// snippet-end:[medical-imaging.JavaScript.resource.listTagsForResourceV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await listTagsForResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af"); +} diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js index f4e9fedea63..d1c8c9504ed 100644 --- a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -5,7 +5,7 @@ import {fileURLToPath} from "url"; -// snippet-start:[medical-imaging.JavaScript.datastore.startDicomImportJobV3] +// snippet-start:[medical-imaging.JavaScript.dicom.startDicomImportJobV3] import {StartDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; @@ -47,7 +47,7 @@ export const startDicomImportJob = async (jobName = "test-1", // } return response; }; -// snippet-end:[medical-imaging.JavaScript.datastore.startDicomImportJobV3] +// snippet-end:[medical-imaging.JavaScript.dicom.startDicomImportJobV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { diff --git a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js new file mode 100644 index 00000000000..1c46a8eebba --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -0,0 +1,42 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.resource.tagResourceV3] +import {TagResourceCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. + * @param {{}} tags - The tag to add to the resource as JSON. + * - For example: {"Deployment" : "Development"} + */ +export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", + tags = {}) => { + const response = await medicalImagingClient.send( + new TagResourceCommand({resourceArn : resourceArn, tags : tags}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 204, + // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // } + // } + + return response; +}; +// snippet-end:[medical-imaging.JavaScript.resource.tagResourceV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await tagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", + {"Deployment" : "Development"}); + } diff --git a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js new file mode 100644 index 00000000000..a3c070e1ab6 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js @@ -0,0 +1,41 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.resource.unTagResourceV3] +import {UntagResourceCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. + * @param {{}} tagKeys - The keys of the tags to remove. + */ +export const untagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", + tagKeys= []) => { + const response = await medicalImagingClient.send( + new UntagResourceCommand({resourceArn : resourceArn, tagKeys : tagKeys}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 204, + // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // } + // } + + return response; +}; +// snippet-end:[medical-imaging.JavaScript.resource.unTagResourceV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + await untagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", + ["Deployment"]); +} diff --git a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js new file mode 100644 index 00000000000..4aa9f1d60fd --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js @@ -0,0 +1,47 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-ec2", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + EC2Client: class { + send = send; + }, + }; +}); + +const { main } = await import("../actions/start-dicom-import-job.js"); + +describe("start-dicom-import-job", () => { + it("should log id of the created address and the address itself", async () => { + const logSpy = vi.spyOn(console, "log"); + const response = { + PublicIp: "foo", + AllocationId: "bar", + }; + + send.mockResolvedValueOnce(response); + + await main(); + + expect(logSpy).toHaveBeenNthCalledWith(2, `ID: bar Public IP: foo`); + }); + + it("should log the error message", async () => { + const logSpy = vi.spyOn(console, "error"); + send.mockRejectedValueOnce(new Error("Failed to allocate address")); + + await main(); + + expect(logSpy).toHaveBeenCalledWith( + new Error("Failed to allocate address") + ); + }); +}); From e4834abb5226ab60cb659e7ae0f9ac8ee8c2d90e Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:06:14 -0400 Subject: [PATCH 08/31] adding tests --- .../tests/get-dicom-import-job.unit.test.js | 40 +++++++++++ .../tests/get-image-set-metadata.unit.test.js | 55 +++++++++++++++ .../tests/get-image-set.unit.test.js | 69 +++++++++++++++++++ .../tests/list-dicom-import-jobs.unit.test.js | 45 ++++++++++++ .../tests/start-dicom-import-job.unit.test.js | 35 +++++----- 5 files changed, 225 insertions(+), 19 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js diff --git a/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js new file mode 100644 index 00000000000..27f2f9d51c2 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js @@ -0,0 +1,40 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const { getDICOMImportJob } = await import("../actions/get-dicom-import-job.js"); + +describe("get-dicom-import-job", () => { + const jobId = "12345678901234567890123456789012"; + const datastoreId = "12345678901234567890123456789012"; + it("Should accept arguments and reponse", async () => { + const logSpy = vi.spyOn(console, "log"); + const response = { + jobId: jobId, + datastoreId: datastoreId, + jobStatus: 'TESTING', + submittedAt: '2019-01-01T00:00:00.000Z' + }; + + send.mockResolvedValueOnce(response); + + await getDICOMImportJob(datastoreId, jobId); + + expect(logSpy).toHaveBeenCalledWith(response) + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js new file mode 100644 index 00000000000..e073ad6a104 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -0,0 +1,55 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +class StreamMock { + constructor(dataArray) { + this.dataArray = dataArray; + } + + transformToByteArray(){ + return this.dataArray; + } +} + +const { getImageSetMetadata } = await import("../actions/get-image-set-metadata.js"); + +describe("get-image-set-metadata", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + + const response = {jobSummaries: [ + { + dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + datastoreId: datastoreId, + endedAt: '2023-09-22T14:49:51.351Z', + jobId: '12345678901234567890123456789012', + jobName: 'test-1', + jobStatus: 'COMPLETED', + submittedAt: '2023-09-22T14:48:45.767Z' + } + ]}; + + send.mockResolvedValueOnce(response); + + await listDICOMImportJobs(datastoreId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js new file mode 100644 index 00000000000..1b4de64d3d2 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const { getImageSet } = await import("../actions/get-image-set.js"); + +describe("get-image-set", () => { + it("should log the response running without version ID", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + + const response = { + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: datastoreId, + imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', + imageSetId: imageSetId, + imageSetState: 'ACTIVE', + imageSetWorkflowStatus: 'CREATED', + updatedAt: "2023-09-22T14:49:26.427Z", + versionId: '1' + }; + + send.mockResolvedValueOnce(response); + + await getImageSet(datastoreId, imageSetId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); + + it("should log the response running with version ID", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const versionId = "1"; + + const response = { + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: datastoreId, + imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', + imageSetId: imageSetId, + imageSetState: 'ACTIVE', + imageSetWorkflowStatus: 'CREATED', + updatedAt: "2023-09-22T14:49:26.427Z", + versionId: versionId + }; + + send.mockResolvedValueOnce(response); + + await getImageSet(datastoreId, imageSetId, versionId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js new file mode 100644 index 00000000000..7693d711daf --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -0,0 +1,45 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const { listDICOMImportJobs } = await import("../actions/list-dicom-import-jobs.js"); + +describe("list-dicom-import-job", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + + const response = {jobSummaries: [ + { + dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + datastoreId: datastoreId, + endedAt: '2023-09-22T14:49:51.351Z', + jobId: '12345678901234567890123456789012', + jobName: 'test-1', + jobStatus: 'COMPLETED', + submittedAt: '2023-09-22T14:48:45.767Z' + } + ]}; + + send.mockResolvedValueOnce(response); + + await listDICOMImportJobs(datastoreId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js index 4aa9f1d60fd..8b48f5b8922 100644 --- a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js @@ -7,41 +7,38 @@ import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); -vi.doMock("@aws-sdk/client-ec2", async () => { +vi.doMock("@aws-sdk/client-medical-imaging", async () => { const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); return { ...actual, - EC2Client: class { + MedicalImagingClient: class { send = send; }, }; }); -const { main } = await import("../actions/start-dicom-import-job.js"); +const { startDicomImportJob } = await import("../actions/start-dicom-import-job.js"); describe("start-dicom-import-job", () => { - it("should log id of the created address and the address itself", async () => { + it("should log the response", async () => { const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const response = { - PublicIp: "foo", - AllocationId: "bar", + jobId: "12345678901234567890123456789012", + datastoreId: datastoreId, + jobStatus: 'CREATING', + submittedAt: '2019-01-01T00:00:00.000Z' }; send.mockResolvedValueOnce(response); - await main(); - - expect(logSpy).toHaveBeenNthCalledWith(2, `ID: bar Public IP: foo`); - }); - - it("should log the error message", async () => { - const logSpy = vi.spyOn(console, "error"); - send.mockRejectedValueOnce(new Error("Failed to allocate address")); - - await main(); + await startDicomImportJob("test-1", + datastoreId, + "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", + "s3://medical-imaging-dicom-input/dicom_input/", + "s3://medical-imaging-output/job_output/"); - expect(logSpy).toHaveBeenCalledWith( - new Error("Failed to allocate address") - ); + expect(logSpy).toHaveBeenCalledWith(response); }); }); From ea863a9028aa42bc5d8e8dbb98e3393d90bfd961 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:14:13 -0400 Subject: [PATCH 09/31] added action and more tests --- .../actions/get-image-frame.js | 54 ++++------ .../actions/search-image-sets.js | 100 ++++++++++++++++++ .../tests/get-image-frame.unit.test.js | 61 +++++++++++ .../tests/get-image-set-metadata.unit.test.js | 32 +++--- 4 files changed, 200 insertions(+), 47 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/actions/search-image-sets.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index 69e434ffc03..ce9e5a51edc 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -4,53 +4,42 @@ */ import {fileURLToPath} from "url"; -self.importScripts(".js/openjphjs.js") import { writeFileSync } from "fs"; // snippet-start:[medical-imaging.JavaScript.imageset.getImageFrameV3] import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; -let decoder; -// eslint-disable-next-line no-undef -Module.onRuntimeInitialized = () => { - // eslint-disable-next-line no-undef - decoder = new Module.HTJ2KDecoder(); - isWorkerReady.resolve(null); -}; - /** - * @param {string} datastoreID - The ID of the data store to retrieve properties for. + * @param {string} datastoreID - The data store's ID. + * @param {string} imageSetID - The image set's ID. + * @param {string} imageFrameID - The image frame's ID. + * @param {string} imageFrameFileName - File path to write the image frame. */ export const getImageFrame = async (datastoreID = "DATASTORE_ID", imageSetID = "IMAGE_SET_ID", - imageFrameID = "IMAGE_FRAME_ID") => { + imageFrameID = "IMAGE_FRAME_ID", + imageFrameFileName = "image.jph") => { const response = await medicalImagingClient.send( new GetImageFrameCommand({datastoreId: datastoreID, imageSetId: imageSetID, imageFrameInformation: {imageFrameId : imageFrameID}}) ); - + const buffer = await response.imageFrameBlob.transformToByteArray(); + writeFileSync(imageFrameFileName, buffer); console.log(response); // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '55ea7d2e-222c-4a6a-871e-4f591f40cadb', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreProperties: { - // createdAt: 2023-08-04T18:50:36.239Z, - // datastoreArn: 'arn:aws:medical-imaging:us-east-1:123456789:datastore/1234567890abcdef01234567890abcde', - // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreName: 'my_datastore', - // datastoreStatus: 'ACTIVE', - // updatedAt: 2023-08-04T18:50:36.239Z - // } + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'e4ab42a5-25a3-4377-873f-374ecf4380e1', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // contentType: 'application/octet-stream', + // imageFrameBlob: IncomingMessage {} // } return response }; @@ -58,9 +47,6 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - const response = await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "11290736aa3544da28a3afad02ec128a", "8560ba4972a0244e11fd2459835dd67a"); - - // const buffer = await response.arrayBuffer(); - //writeFileSync("image.jph", buffer); - + const response = await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", "110c71bce27b5bee669d1141a2fdb022", + "test.jph"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js new file mode 100644 index 00000000000..29e96fb036d --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -0,0 +1,100 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3] +import {SearchImageSetsCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The data store's ID. + * @param {[]} filters - The search criteria filters. + */ +export const searchImageSets = async (datastoreId = "xxxxxxxx", filters = []) => { + const response = await medicalImagingClient.send( + new SearchImageSetsCommand({datastoreId : datastoreId, + searchCriteria: { + filters: filters + }}) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // tags: { Deployment: 'Development' } + // } + + return response["imageSetsMetadataSummaries"]; +}; +// snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] + const datastoreId = "12345678901234567890123456789012"; + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] + // Search using EQUAL operator. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] + try { + const filters = [{ + values: [{DICOMPatientId: "9227465"}], + operator: "EQUAL" + }]; + + await searchImageSets(datastoreId, filters); + } + catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] + + // Search with BETWEEN operator using DICOMStudyDate and DICOMStudyTime. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] + try { + const filters = [{ + values: [{DICOMStudyDateAndTime: { + DICOMStudyDate: '19900101', + DICOMStudyTime: '000000' + }}, + {DICOMStudyDateAndTime: { + DICOMStudyDate: '20230901', + DICOMStudyTime: '000000' + }}], + operator: "BETWEEN" + }]; + + await searchImageSets(datastoreId, filters); + } + catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] + + // Search with BETWEEN operator and createdAt date. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] + try { + const filters = [{ + values: [ + {createdAt: new Date("1985-04-12T23:20:50.52Z")}, + {createdAt: new Date("2023-09-12T23:20:50.52Z")}, + ], + operator: "BETWEEN" + }]; + + await searchImageSets(datastoreId, filters); + } + catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] +} +`` \ No newline at end of file diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js new file mode 100644 index 00000000000..9b05ba974cf --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js @@ -0,0 +1,61 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; +import * as fs from 'fs'; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +class StreamMock { + constructor(dataArray) { + this.dataArray = dataArray; + } + + transformToByteArray(){ + return this.dataArray; + } +} + +const { getImageFrame } = await import("../actions/get-image-frame.js"); + +describe("get-image-set-metadata", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const imageFrameID = "12345678901234567890123456789012"; + const metadataFileName = "med_image_frame_test.jph"; + + const response = { metadata: { + httpStatusCode: 200, + requestId: '5219b274-30ff-4986-8cab-48753de3a599', + extendedRequestId: "undefined", + cfId: "undefined", + attempts: 1, + totalRetryDelay: 0 + }, + contentType: 'text/plain', + imageFrameBlob: new StreamMock(new Uint8Array(256)) + }; + + send.mockResolvedValueOnce(response); + + await getImageFrame(datastoreId, imageSetId, imageFrameID, metadataFileName); + + expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js index e073ad6a104..76870d1096d 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -4,6 +4,7 @@ */ import { describe, it, expect, vi } from "vitest"; +import * as fs from 'fs'; const send = vi.fn(); @@ -33,23 +34,28 @@ describe("get-image-set-metadata", () => { it("should log the response", async () => { const logSpy = vi.spyOn(console, "log"); const datastoreId = "12345678901234567890123456789012"; - - const response = {jobSummaries: [ - { - dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', - datastoreId: datastoreId, - endedAt: '2023-09-22T14:49:51.351Z', - jobId: '12345678901234567890123456789012', - jobName: 'test-1', - jobStatus: 'COMPLETED', - submittedAt: '2023-09-22T14:48:45.767Z' - } - ]}; + const imageSetId = "12345678901234567890123456789012"; + const metadataFileName = "med_image_test.gzip"; + + const response = { metadata: { + httpStatusCode: 200, + requestId: '5219b274-30ff-4986-8cab-48753de3a599', + extendedRequestId: "undefined", + cfId: "undefined", + attempts: 1, + totalRetryDelay: 0 + }, + contentType: 'application/json', + contentEncoding: 'gzip', + imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) + }; send.mockResolvedValueOnce(response); - await listDICOMImportJobs(datastoreId); + await getImageSetMetadata(datastoreId, imageSetId, metadataFileName); expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); }); }); From f694680b075a2d98161582982c983c64854e3c28 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:22:30 -0400 Subject: [PATCH 10/31] tests done --- .../actions/create-datastore.js | 2 +- .../actions/delete-datastore.js | 2 +- .../actions/delete-image-set.js | 32 +++---- .../medical-imaging/actions/get-datastore.js | 4 +- .../actions/get-dicom-import-job.js | 6 +- .../actions/get-image-frame.js | 12 +-- .../medical-imaging/actions/get-image-set.js | 14 ++-- .../actions/list-datastores.js | 6 +- .../actions/list-dicom-import-jobs.js | 6 +- .../actions/list-image-set-versions.js | 6 +- .../actions/list-tags-for-resource.js | 2 +- .../actions/search-image-sets.js | 56 ++++++++----- .../medical-imaging/actions/tag-resource.js | 6 +- .../medical-imaging/actions/untag-resource.js | 4 +- .../tests/copy-image-set.unit.test.js | 83 +++++++++++++++++++ ...reate-delete-datastore.integration.test.js | 2 +- .../tests/delete-image-set.unit.test.js | 51 ++++++++++++ .../tests/get-datastore.integration.test.js | 5 ++ .../tests/get-dicom-import-job.unit.test.js | 6 +- .../tests/get-image-frame.unit.test.js | 13 +-- .../tests/get-image-set-metadata.unit.test.js | 31 +++---- .../tests/get-image-set.unit.test.js | 22 ++--- .../tests/list-dicom-import-jobs.unit.test.js | 20 +++-- .../list-image-set-versions.unit.test.js | 54 ++++++++++++ .../tests/list-tags-for-resource.unit.test.js | 47 +++++++++++ .../tests/search-image-set.unit.test.js | 60 ++++++++++++++ .../tests/start-dicom-import-job.unit.test.js | 6 +- .../tests/tag-resource.unit.test.js | 49 +++++++++++ .../tests/untag-resource.unit.test.js | 47 +++++++++++ .../update-image-set-metadata.unit.test.js | 69 +++++++++++++++ 30 files changed, 602 insertions(+), 121 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js create mode 100644 javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js diff --git a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js index fc625b84064..8ed6bdb845b 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -36,4 +36,4 @@ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await createDatastore(); - } +} diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js index 5974edbd132..675edabec8d 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js @@ -36,5 +36,5 @@ export const deleteDatastore = async (datastoreID = "DATASTORE_ID") => { // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - deleteDatastore(); + await deleteDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js index 789666af2f9..f0ea5ef81e3 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js @@ -15,23 +15,23 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; */ export const deleteImageSet = async (datastoreId = "xxxxxxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new DeleteImageSetCommand({datastoreId : datastoreId, imageSetId : imageSetId}) + new DeleteImageSetCommand({datastoreId: datastoreId, imageSetId: imageSetId}) ); console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxx', - // imageSetId: 'xxxxxxxxxxxxxxx', - // imageSetState: 'LOCKED', - // imageSetWorkflowStatus: 'DELETING' - // } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'DELETING' + // } return response; }; // snippet-end:[medical-imaging.JavaScript.imageset.deleteImageSetV3] @@ -39,4 +39,4 @@ export const deleteImageSet = async (datastoreId = "xxxxxxxxxxxxxxxx", imageSetI // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await deleteImageSet("728f13a131f748bf8d87a55d5ef6c5af", "906e1c0ff5e9c69a14a9e4d36e0cea1e"); - } +} diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index 72f1a16cf1c..dc795ca783f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -35,11 +35,11 @@ export const getDatastore = async (datastoreID = "DATASTORE_ID") => { // updatedAt: 2023-08-04T18:50:36.239Z // } // } - return response.datastoreProperties; + return response["datastoreProperties"]; }; // snippet-end:[medical-imaging.JavaScript.datastore.getDatastoreV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - getDatastore(); + await getDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index 94a1bbe7b4d..1920a380ff9 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -13,10 +13,10 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} datastoreId - The ID of the data store. * @param {string} jobId - The ID of the job. */ -export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", +export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", jobId = "xxxxxxxxxxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new GetDICOMImportJobCommand({datastoreId : datastoreId, jobId : jobId}) + new GetDICOMImportJobCommand({datastoreId: datastoreId, jobId: jobId}) ); console.log(response); // { @@ -48,4 +48,4 @@ export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getDICOMImportJob(); - } +} diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index ce9e5a51edc..6e52db4b323 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -4,7 +4,7 @@ */ import {fileURLToPath} from "url"; -import { writeFileSync } from "fs"; +import {writeFileSync} from "fs"; // snippet-start:[medical-imaging.JavaScript.imageset.getImageFrameV3] import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; @@ -21,9 +21,11 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", imageFrameID = "IMAGE_FRAME_ID", imageFrameFileName = "image.jph") => { const response = await medicalImagingClient.send( - new GetImageFrameCommand({datastoreId: datastoreID, - imageSetId: imageSetID, - imageFrameInformation: {imageFrameId : imageFrameID}}) + new GetImageFrameCommand({ + datastoreId: datastoreID, + imageSetId: imageSetID, + imageFrameInformation: {imageFrameId: imageFrameID} + }) ); const buffer = await response.imageFrameBlob.transformToByteArray(); writeFileSync(imageFrameFileName, buffer); @@ -47,6 +49,6 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - const response = await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", "110c71bce27b5bee669d1141a2fdb022", + await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", "110c71bce27b5bee669d1141a2fdb022", "test.jph"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js index 0b70af0cf97..2a97e7c0076 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -15,16 +15,16 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} imageSetVersion - The optional version of the image set. * */ -export const getImageSet = async (datastoreId= "xxxxxxxxxxxxxxx", - imageSetId = "xxxxxxxxxxxxxxx", - imageSetVersion = "") => { - let params = {datastoreId: datastoreId, imageSetId: imageSetId }; - if (imageSetVersion != "") { +export const getImageSet = async (datastoreId = "xxxxxxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxxxxx", + imageSetVersion = "") => { + let params = {datastoreId: datastoreId, imageSetId: imageSetId}; + if (imageSetVersion !== "") { params.imageSetVersion = imageSetVersion; } const response = await medicalImagingClient.send( new GetImageSetCommand(params)); - console.log( response); + console.log(response); // { // '$metadata': { // httpStatusCode: 200, @@ -52,4 +52,4 @@ export const getImageSet = async (datastoreId= "xxxxxxxxxxxxxxx", // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getImageSet(); - } +} diff --git a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js index 7506f46ce7a..c26861a1008 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -18,10 +18,10 @@ export const listDatastores = async () => { const commandParams = {}; const paginator = paginateListDatastores(paginatorConfig, commandParams); - const datastoreSummaries = []; + let datastoreSummaries = []; for await (const page of paginator) { // page contains a single paginated output. - datastoreSummaries.push(...page.datastoreSummaries); + datastoreSummaries.push(...page["datastoreSummaries"]); console.log(page); } // { @@ -52,5 +52,5 @@ export const listDatastores = async () => { // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - listDatastores(); + await listDatastores(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index a1b72bcb74e..5e3dd177d1a 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -14,7 +14,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; */ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new ListDICOMImportJobsCommand({datastoreId : datastoreId}) + new ListDICOMImportJobsCommand({datastoreId: datastoreId}) ); console.log(response); // { @@ -38,11 +38,11 @@ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => // } // ]} - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await listDICOMImportJobs(); - } +} diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index 41d161edfcb..de2447b0cd4 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -15,7 +15,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; */ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx") => { const response = await medicalImagingClient.send( - new ListImageSetVersionsCommand({datastoreId : datastoreId, imageSetId : imageSetId}) + new ListImageSetVersionsCommand({datastoreId: datastoreId, imageSetId: imageSetId}) ); console.log(response); // { @@ -42,5 +42,5 @@ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSe // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listImageSetVersions("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0"); - } + await listImageSetVersions(); +} diff --git a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js index 918e67f6392..9d467e3de19 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js @@ -14,7 +14,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; */ export const listTagsForResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxx:datastore/xxx/imageset/xxx") => { const response = await medicalImagingClient.send( - new ListTagsForResourceCommand({resourceArn : resourceArn}) + new ListTagsForResourceCommand({resourceArn: resourceArn}) ); console.log(response); // { diff --git a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js index 29e96fb036d..bcea1da44eb 100644 --- a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -15,23 +15,32 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; */ export const searchImageSets = async (datastoreId = "xxxxxxxx", filters = []) => { const response = await medicalImagingClient.send( - new SearchImageSetsCommand({datastoreId : datastoreId, + new SearchImageSetsCommand({ + datastoreId: datastoreId, searchCriteria: { filters: filters - }}) + } + }) ); console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // tags: { Deployment: 'Development' } - // } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // imageSetsMetadataSummaries: [ + // { + // DICOMTags: [Object], + // createdAt: "2023-09-19T16:59:40.551Z", + // imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', + // updatedAt: "2023-09-19T16:59:40.551Z", + // version: 1 + // }] + // } return response["imageSetsMetadataSummaries"]; }; @@ -51,8 +60,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { }]; await searchImageSets(datastoreId, filters); - } - catch (err) { + } catch (err) { console.error(err); } // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] @@ -61,20 +69,23 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] try { const filters = [{ - values: [{DICOMStudyDateAndTime: { + values: [{ + DICOMStudyDateAndTime: { DICOMStudyDate: '19900101', DICOMStudyTime: '000000' - }}, - {DICOMStudyDateAndTime: { + } + }, + { + DICOMStudyDateAndTime: { DICOMStudyDate: '20230901', DICOMStudyTime: '000000' - }}], + } + }], operator: "BETWEEN" }]; await searchImageSets(datastoreId, filters); - } - catch (err) { + } catch (err) { console.error(err); } // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] @@ -91,8 +102,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { }]; await searchImageSets(datastoreId, filters); - } - catch (err) { + } catch (err) { console.error(err); } // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] diff --git a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js index 1c46a8eebba..da4e260b0ec 100644 --- a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -17,7 +17,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", tags = {}) => { const response = await medicalImagingClient.send( - new TagResourceCommand({resourceArn : resourceArn, tags : tags}) + new TagResourceCommand({resourceArn: resourceArn, tags: tags}) ); console.log(response); // { @@ -38,5 +38,5 @@ export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await tagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", - {"Deployment" : "Development"}); - } + {"Deployment": "Development"}); +} diff --git a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js index a3c070e1ab6..6f3615448de 100644 --- a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js @@ -14,9 +14,9 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {{}} tagKeys - The keys of the tags to remove. */ export const untagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", - tagKeys= []) => { + tagKeys = []) => { const response = await medicalImagingClient.send( - new UntagResourceCommand({resourceArn : resourceArn, tagKeys : tagKeys}) + new UntagResourceCommand({resourceArn: resourceArn, tagKeys: tagKeys}) ); console.log(response); // { diff --git a/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js new file mode 100644 index 00000000000..75ffb97d7be --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js @@ -0,0 +1,83 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {copyImageSet} = await import("../actions/copy-image-set.js"); + +describe("copy-image-set", () => { + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + datastoreId: 'xxxxxxxxxxxxxx', + destinationImageSetProperties: { + createdAt: "2023-09-27T19:46:21.824Z", + imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', + imageSetId: 'xxxxxxxxxxxxxxx', + imageSetState: 'LOCKED', + imageSetWorkflowStatus: 'COPYING', + latestVersionId: '1', + updatedAt: "2023-09-27T19:46:21.824Z" + }, + sourceImageSetProperties: { + createdAt: "2023-09-22T14:49:26.427Z", + imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', + imageSetId: 'xxxxxxxxxxxxxxxx', + imageSetState: 'LOCKED', + imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', + latestVersionId: '4', + updatedAt: "2023-09-27T19:46:21.824Z" + } + }; + + it("should log the response without destination", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + const sourceVersionId = "1"; + + + send.mockResolvedValueOnce(response); + + await copyImageSet(datastoreId, imageSetID, sourceVersionId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); + + it("should log the response with destination", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + const sourceVersionId = "1"; + const destinationImageSetID = "12345678901234567890123456789012"; + const destinationVersionId = "1"; + + + send.mockResolvedValueOnce(response); + + await copyImageSet(datastoreId, imageSetID, sourceVersionId, destinationImageSetID, destinationVersionId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js index 7cf755dadcf..2ce71160488 100644 --- a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js @@ -23,7 +23,7 @@ describe("createDatastore/deleteDatastore", () => { while ((counter < 20) && (status !== "ACTIVE")) { // Redundant check with test timeout. await wait(1); const getDatastoreCommandOutput = await getDatastore(datastoreID); - status = getDatastoreCommandOutput.datastoreStatus; // eslint-disable-line + status = getDatastoreCommandOutput["datastoreStatus"]; // eslint-disable-line counter++; } diff --git a/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js new file mode 100644 index 00000000000..19b2f31370f --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js @@ -0,0 +1,51 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {deleteImageSet} = await import("../actions/delete-image-set.js"); + +describe("delete-image-set", () => { + + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + datastoreId: 'xxxxxxxxxxxxxxxx', + imageSetId: 'xxxxxxxxxxxxxxx', + imageSetState: 'LOCKED', + imageSetWorkflowStatus: 'DELETING' + }; + + send.mockResolvedValueOnce(response); + + await deleteImageSet(datastoreId, imageSetID); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js index 9168d53a4e5..49cfea4569b 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js @@ -1,3 +1,8 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + import {describe, it, expect} from "vitest"; import {getDatastore} from "../actions/get-datastore.js"; diff --git a/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js index 27f2f9d51c2..ca1f454b56f 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; const send = vi.fn(); @@ -17,12 +17,12 @@ vi.doMock("@aws-sdk/client-medical-imaging", async () => { }; }); -const { getDICOMImportJob } = await import("../actions/get-dicom-import-job.js"); +const {getDICOMImportJob} = await import("../actions/get-dicom-import-job.js"); describe("get-dicom-import-job", () => { const jobId = "12345678901234567890123456789012"; const datastoreId = "12345678901234567890123456789012"; - it("Should accept arguments and reponse", async () => { + it("Should accept arguments and response", async () => { const logSpy = vi.spyOn(console, "log"); const response = { jobId: jobId, diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js index 9b05ba974cf..1d57adf5357 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; import * as fs from 'fs'; const send = vi.fn(); @@ -23,12 +23,12 @@ class StreamMock { this.dataArray = dataArray; } - transformToByteArray(){ + transformToByteArray() { return this.dataArray; } } -const { getImageFrame } = await import("../actions/get-image-frame.js"); +const {getImageFrame} = await import("../actions/get-image-frame.js"); describe("get-image-set-metadata", () => { it("should log the response", async () => { @@ -38,11 +38,12 @@ describe("get-image-set-metadata", () => { const imageFrameID = "12345678901234567890123456789012"; const metadataFileName = "med_image_frame_test.jph"; - const response = { metadata: { + const response = { + metadata: { httpStatusCode: 200, requestId: '5219b274-30ff-4986-8cab-48753de3a599', - extendedRequestId: "undefined", - cfId: "undefined", + extendedRequestId: undefined, + cfId: undefined, attempts: 1, totalRetryDelay: 0 }, diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js index 76870d1096d..cfc2e38bfb2 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; import * as fs from 'fs'; const send = vi.fn(); @@ -23,12 +23,12 @@ class StreamMock { this.dataArray = dataArray; } - transformToByteArray(){ + transformToByteArray() { return this.dataArray; } } -const { getImageSetMetadata } = await import("../actions/get-image-set-metadata.js"); +const {getImageSetMetadata} = await import("../actions/get-image-set-metadata.js"); describe("get-image-set-metadata", () => { it("should log the response", async () => { @@ -37,18 +37,19 @@ describe("get-image-set-metadata", () => { const imageSetId = "12345678901234567890123456789012"; const metadataFileName = "med_image_test.gzip"; - const response = { metadata: { - httpStatusCode: 200, - requestId: '5219b274-30ff-4986-8cab-48753de3a599', - extendedRequestId: "undefined", - cfId: "undefined", - attempts: 1, - totalRetryDelay: 0 - }, - contentType: 'application/json', - contentEncoding: 'gzip', - imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) - }; + const response = { + metadata: { + httpStatusCode: 200, + requestId: '5219b274-30ff-4986-8cab-48753de3a599', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + contentType: 'application/json', + contentEncoding: 'gzip', + imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) + }; send.mockResolvedValueOnce(response); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js index 1b4de64d3d2..23254d8cdc5 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; const send = vi.fn(); @@ -17,7 +17,7 @@ vi.doMock("@aws-sdk/client-medical-imaging", async () => { }; }); -const { getImageSet } = await import("../actions/get-image-set.js"); +const {getImageSet} = await import("../actions/get-image-set.js"); describe("get-image-set", () => { it("should log the response running without version ID", async () => { @@ -26,15 +26,15 @@ describe("get-image-set", () => { const imageSetId = "12345678901234567890123456789012"; const response = { - createdAt: "2023-09-22T14:49:26.427Z", - datastoreId: datastoreId, - imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', - imageSetId: imageSetId, - imageSetState: 'ACTIVE', - imageSetWorkflowStatus: 'CREATED', - updatedAt: "2023-09-22T14:49:26.427Z", - versionId: '1' - }; + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: datastoreId, + imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', + imageSetId: imageSetId, + imageSetState: 'ACTIVE', + imageSetWorkflowStatus: 'CREATED', + updatedAt: "2023-09-22T14:49:26.427Z", + versionId: '1' + }; send.mockResolvedValueOnce(response); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js index 7693d711daf..900fe750e81 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; const send = vi.fn(); @@ -17,24 +17,26 @@ vi.doMock("@aws-sdk/client-medical-imaging", async () => { }; }); -const { listDICOMImportJobs } = await import("../actions/list-dicom-import-jobs.js"); +const {listDICOMImportJobs} = await import("../actions/list-dicom-import-jobs.js"); describe("list-dicom-import-job", () => { it("should log the response", async () => { const logSpy = vi.spyOn(console, "log"); const datastoreId = "12345678901234567890123456789012"; - const response = {jobSummaries: [ + const response = { + jobSummaries: [ { dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', datastoreId: datastoreId, endedAt: '2023-09-22T14:49:51.351Z', - jobId: '12345678901234567890123456789012', - jobName: 'test-1', - jobStatus: 'COMPLETED', - submittedAt: '2023-09-22T14:48:45.767Z' - } - ]}; + jobId: '12345678901234567890123456789012', + jobName: 'test-1', + jobStatus: 'COMPLETED', + submittedAt: '2023-09-22T14:48:45.767Z' + } + ] + }; send.mockResolvedValueOnce(response); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js new file mode 100644 index 00000000000..533d6f8170e --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js @@ -0,0 +1,54 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {listImageSetVersions} = await import("../actions/list-image-set-versions.js"); + +describe("list-image-set-versions", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: '74590b37-a002-4827-83f2-3c590279c742', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + imageSetPropertiesList: [ + { + ImageSetWorkflowStatus: 'CREATED', + createdAt: "2023-09-22T14:49:26.427Z", + imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxx', + imageSetState: 'ACTIVE', + versionId: '1' + }] + }; + + send.mockResolvedValueOnce(response); + + await listImageSetVersions(datastoreId, imageSetID); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js new file mode 100644 index 00000000000..a8261f1f1cb --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js @@ -0,0 +1,47 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); + +describe("list-tags-for-resource", () => { + + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: '008fc6d3-abec-4870-a155-20fa3631e645', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + tags: { Deployment: 'Development' } + }; + + send.mockResolvedValueOnce(response); + + await listTagsForResource(resourceArn); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js new file mode 100644 index 00000000000..18b193b3475 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js @@ -0,0 +1,60 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {searchImageSets} = await import("../actions/search-image-sets.js"); + +describe("search-image-sets", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const filters = [{ + values: [ + {createdAt: new Date("1985-04-12T23:20:50.52Z")}, + {createdAt: new Date("2023-09-12T23:20:50.52Z")}, + ], + operator: "BETWEEN" + }]; + + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + imageSetsMetadataSummaries: [ + { + DICOMTags: [Object], + createdAt: "2023-09-19T16:59:40.551Z", + imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', + updatedAt: "2023-09-19T16:59:40.551Z", + version: 1 + }] + }; + + send.mockResolvedValueOnce(response); + + await searchImageSets(datastoreId, filters); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js index 8b48f5b8922..d18ef6c96af 100644 --- a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi } from "vitest"; +import {describe, it, expect, vi} from "vitest"; const send = vi.fn(); @@ -17,7 +17,7 @@ vi.doMock("@aws-sdk/client-medical-imaging", async () => { }; }); -const { startDicomImportJob } = await import("../actions/start-dicom-import-job.js"); +const {startDicomImportJob} = await import("../actions/start-dicom-import-job.js"); describe("start-dicom-import-job", () => { it("should log the response", async () => { @@ -36,7 +36,7 @@ describe("start-dicom-import-job", () => { await startDicomImportJob("test-1", datastoreId, "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", - "s3://medical-imaging-dicom-input/dicom_input/", + "s3://medical-imaging-dicom-input/dicom_input/", "s3://medical-imaging-output/job_output/"); expect(logSpy).toHaveBeenCalledWith(response); diff --git a/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js new file mode 100644 index 00000000000..6976308e995 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js @@ -0,0 +1,49 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {tagResource} = await import("../actions/tag-resource.js"); + +describe("resource", () => { + + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + const tags = { + "Deployment" : "Development" + } + + const response = + { + '$metadata': { + httpStatusCode: 204, + requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + } + }; + + send.mockResolvedValueOnce(response); + + await tagResource(resourceArn, tags); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js new file mode 100644 index 00000000000..35d9a6e0fb7 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js @@ -0,0 +1,47 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {untagResource} = await import("../actions/untag-resource.js"); + +describe("untag-resource", () => { + + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + const keys = ["Deployment"]; + + const response = + { + '$metadata': { + httpStatusCode: 204, + requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + } + }; + + send.mockResolvedValueOnce(response); + + await untagResource(resourceArn, keys); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); diff --git a/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js new file mode 100644 index 00000000000..cd9664c282d --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {describe, it, expect, vi} from "vitest"; + +const send = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; +}); + +const {updateImageSetMetadata} = await import("../actions/update-image-set-metadata.js"); + +describe("update-image-set-metadata", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const versionID = "1"; + const updatableAttributes = + '{' + + ' "SchemaVersion": 1.1,' + + ' "Patient": {' + + ' "DICOM": {' + + ' "PatientName": "Garcia^Gloria"' + + ' }' + + ' }' + + '}'; + + const updateMetadata = { + "DICOMUpdates": { + "updatableAttributes": + new TextEncoder().encode(updatableAttributes) + } + }; + const response = + { + '$metadata': { + httpStatusCode: 200, + requestId: '7966e869-e311-4bff-92ec-56a61d3003ea', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + imageSetState: 'LOCKED', + imageSetWorkflowStatus: 'UPDATING', + latestVersionId: '4', + updatedAt: "2023-09-27T19:41:43.494Z" + }; + + send.mockResolvedValueOnce(response); + + await updateImageSetMetadata(datastoreId, imageSetId, versionID, updateMetadata); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +}); From 5f31458f02f44f19cf80ad9d57005684281da08a Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:34:19 -0400 Subject: [PATCH 11/31] some cleanup and linting --- .../medical-imaging/actions/copy-image-set.js | 2 +- .../actions/create-datastore.js | 2 +- .../actions/delete-datastore.js | 2 +- .../actions/delete-image-set.js | 2 +- .../medical-imaging/actions/get-datastore.js | 2 +- .../actions/get-dicom-import-job.js | 2 +- .../actions/get-image-frame.js | 2 +- .../actions/get-image-set-metadata.js | 2 +- .../medical-imaging/actions/get-image-set.js | 2 +- .../actions/list-datastores.js | 2 +- .../actions/list-dicom-import-jobs.js | 2 +- .../actions/list-image-set-versions.js | 2 +- .../actions/list-tags-for-resource.js | 2 +- .../actions/search-image-sets.js | 2 +- .../actions/start-dicom-import-job.js | 2 +- .../medical-imaging/actions/tag-resource.js | 2 +- .../medical-imaging/actions/untag-resource.js | 2 +- .../actions/update-image-set-metadata.js | 2 +- .../scenarios/tagging-datastores.js | 42 +++++++++++++++++++ 19 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js diff --git a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js index 4173977e11c..d0e8467fd3e 100644 --- a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -70,7 +70,7 @@ export const copyImageSet = async (datastoreId = "xxxxxxxxxxx", imageSetId = "xx }; // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await copyImageSet(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js index 8ed6bdb845b..da3b2b8f52f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -33,7 +33,7 @@ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { }; // snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await createDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js index 675edabec8d..cd6e87cce45 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js @@ -34,7 +34,7 @@ export const deleteDatastore = async (datastoreID = "DATASTORE_ID") => { }; // snippet-end:[medical-imaging.JavaScript.datastore.deleteDatastoreV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await deleteDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js index f0ea5ef81e3..7b979a1e661 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js @@ -36,7 +36,7 @@ export const deleteImageSet = async (datastoreId = "xxxxxxxxxxxxxxxx", imageSetI }; // snippet-end:[medical-imaging.JavaScript.imageset.deleteImageSetV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await deleteImageSet("728f13a131f748bf8d87a55d5ef6c5af", "906e1c0ff5e9c69a14a9e4d36e0cea1e"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index dc795ca783f..d103ec1e4a6 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -39,7 +39,7 @@ export const getDatastore = async (datastoreID = "DATASTORE_ID") => { }; // snippet-end:[medical-imaging.JavaScript.datastore.getDatastoreV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index 1920a380ff9..30995eebf92 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -45,7 +45,7 @@ export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", }; // snippet-end:[medical-imaging.JavaScript.dicom.getDICOMImportJobV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getDICOMImportJob(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index 6e52db4b323..d40a7b29075 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -47,7 +47,7 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", }; // snippet-end:[medical-imaging.JavaScript.imageset.getImageFrameV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", "110c71bce27b5bee669d1141a2fdb022", "test.jph"); diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index e2ba24ef83b..b9477343ba6 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -44,7 +44,7 @@ export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getImageSetMetadata("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js index 2a97e7c0076..b101802693b 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -49,7 +49,7 @@ export const getImageSet = async (datastoreId = "xxxxxxxxxxxxxxx", // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await getImageSet(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js index c26861a1008..7b348ca3e36 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -50,7 +50,7 @@ export const listDatastores = async () => { }; // snippet-end:[medical-imaging.JavaScript.datastore.listDatastoresV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await listDatastores(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index 5e3dd177d1a..798bb7d296e 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -42,7 +42,7 @@ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => }; // snippet-end:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await listDICOMImportJobs(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index de2447b0cd4..482530b8ba0 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -40,7 +40,7 @@ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSe }; // snippet-end:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await listImageSetVersions(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js index 9d467e3de19..8841ac78d89 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js @@ -33,7 +33,7 @@ export const listTagsForResource = async (resourceArn = "arn:aws:medical-imaging }; // snippet-end:[medical-imaging.JavaScript.resource.listTagsForResourceV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await listTagsForResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js index bcea1da44eb..c20a71267cf 100644 --- a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -46,7 +46,7 @@ export const searchImageSets = async (datastoreId = "xxxxxxxx", filters = []) => }; // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] const datastoreId = "12345678901234567890123456789012"; diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js index d1c8c9504ed..e587a7dd639 100644 --- a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -49,7 +49,7 @@ export const startDicomImportJob = async (jobName = "test-1", }; // snippet-end:[medical-imaging.JavaScript.dicom.startDicomImportJobV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await startDicomImportJob(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js index da4e260b0ec..c0083ef251f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -35,7 +35,7 @@ export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east }; // snippet-end:[medical-imaging.JavaScript.resource.tagResourceV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await tagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", {"Deployment": "Development"}); diff --git a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js index 6f3615448de..a3f5a1d39e4 100644 --- a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js @@ -34,7 +34,7 @@ export const untagResource = async (resourceArn = "arn:aws:medical-imaging:us-ea }; // snippet-end:[medical-imaging.JavaScript.resource.unTagResourceV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { await untagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", ["Deployment"]); diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js index dfcb2dc18b9..e310bb4b323 100644 --- a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -49,7 +49,7 @@ export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", }; // snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] -// Invoke main function if this file was run directly. +// Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js new file mode 100644 index 00000000000..2a876f62270 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -0,0 +1,42 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; +import {copyImageSet} from "../actions/copy-image-set.js"; + +const __filename = fileURLToPath(import.meta.url); + +const {tagResource} = await import("../actions/tag-resource.js"); +const {untagResource} = await import("../actions/untag-resource.js"); +const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); + + +// Invoke the following code if this file is being run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + + // snippet-start:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; + const tags = { + "Deployment" : "Development" + }; + await tagResource(datastoreArn, tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + + // snippet-start:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; + const tags = { + "Deployment" : "Development" + }; + await tagResource(datastoreArn, tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.resource.tagging-datastores.V3] +} From 5d69cd35062e723d21963c3a10f9da682d33c853 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:48:28 -0400 Subject: [PATCH 12/31] Adding snippets --- .../metadata/medical-imaging_metadata.yaml | 139 ++++++++++++++++++ .../scenarios/tagging-datastores.js | 31 ++-- 2 files changed, 158 insertions(+), 12 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 1a973c606a5..36afceb3920 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -173,6 +173,14 @@ medical-imaging_StartDICOMImportJob: - description: snippet_tags: - python.example_code.medical-imaging.StartDICOMImportJob + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.dicom.startDicomImportJobV3 services: medical-imaging: {StartDICOMImportJob} medical-imaging_GetDICOMImportJob: @@ -189,6 +197,14 @@ medical-imaging_GetDICOMImportJob: - description: snippet_tags: - python.example_code.medical-imaging.GetDICOMImportJob + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.dicom.getDICOMImportJobV3 services: medical-imaging: {GetDICOMImportJob} medical-imaging_ListDICOMImportJobs: @@ -205,6 +221,14 @@ medical-imaging_ListDICOMImportJobs: - description: snippet_tags: - python.example_code.medical-imaging.ListDICOMImportJobs + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.dicom.listDICOMImportJobsV3 services: medical-imaging: {ListDICOMImportJobs} medical-imaging_SearchImageSets: @@ -221,6 +245,14 @@ medical-imaging_SearchImageSets: - description: snippet_tags: - python.example_code.medical-imaging.SearchImageSets + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.resource.searchImageSetV3 services: medical-imaging: {SearchImageSets} medical-imaging_GetImageSet: @@ -237,6 +269,14 @@ medical-imaging_GetImageSet: - description: snippet_tags: - python.example_code.medical-imaging.GetImageSet + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetV3 services: medical-imaging: {GetImageSet} medical-imaging_GetImageSetMetadata: @@ -253,6 +293,14 @@ medical-imaging_GetImageSetMetadata: - description: snippet_tags: - python.example_code.medical-imaging.GetImageSetMetadata + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3 services: medical-imaging: {GetImageSetMetadata} medical-imaging_GetImageFrame: @@ -269,6 +317,14 @@ medical-imaging_GetImageFrame: - description: snippet_tags: - python.example_code.medical-imaging.GetImageFrame + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageFrameV3 services: medical-imaging: {GetImageFrame} medical-imaging_ListImageSetVersions: @@ -285,6 +341,14 @@ medical-imaging_ListImageSetVersions: - description: snippet_tags: - python.example_code.medical-imaging.ListImageSetVersions + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.listImageSetVersionsV3 services: medical-imaging: {ListImageSetVersions} medical-imaging_UpdateImageSetMetadata: @@ -301,6 +365,14 @@ medical-imaging_UpdateImageSetMetadata: - description: snippet_tags: - python.example_code.medical-imaging.UpdateImageSetMetadata + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 services: medical-imaging: {UpdateImageSetMetadata} medical-imaging_CopyImageSet: @@ -317,6 +389,14 @@ medical-imaging_CopyImageSet: - description: snippet_tags: - python.example_code.medical-imaging.CopyImageSet + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.copyImageSetV3 services: medical-imaging: {CopyImageSet} medical-imaging_DeleteImageSet: @@ -333,6 +413,14 @@ medical-imaging_DeleteImageSet: - description: snippet_tags: - python.example_code.medical-imaging.DeleteImageSet + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.imageset.deleteImageSetV3 services: medical-imaging: {DeleteImageSet} medical-imaging_TagResource: @@ -349,6 +437,14 @@ medical-imaging_TagResource: - description: snippet_tags: - python.example_code.medical-imaging.TagResource + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.resource.tagResourceV3 services: medical-imaging: {TagResource} medical-imaging_UntagResource: @@ -365,6 +461,14 @@ medical-imaging_UntagResource: - description: snippet_tags: - python.example_code.medical-imaging.UntagResource + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.resource.unTagResourceV3 services: medical-imaging: {UntagResource} medical-imaging_ListTagsForResource: @@ -381,5 +485,40 @@ medical-imaging_ListTagsForResource: - description: snippet_tags: - python.example_code.medical-imaging.ListTagsForResource + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.resource.listTagsForResourceV3 services: medical-imaging: {ListTagsForResource} +medical-imaging_tagging_datastores: + title: Tagging a &AHI; data store using an &AWS; SDK + title_abbrev: Tagging a data store + synopsis: tagging a &AHI; data store. + category: + languages: + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: The following code examples use the &JSBlong; (v2) to tag, list tags, and untag a data store + - description: To tag a data store + snippet_tags: + - medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3 + - medical-imaging.JavaScript.resource.tagResourceV3 + - medical-imaging.JavaScript.datastore.tagging.V3 + - description: To list tags for a data store + snippet_tags: + - medical-imaging.JavaScript.resource.listTagsForResourceV3 + - medical-imaging.JavaScript.datastore.list-tags.V3 + - description: To untag a data store + snippet_tags: + - medical-imaging.JavaScript.resource.unTagResourceV3 + - medical-imaging.JavaScript.datastore.untag.V3 + services: + medical-imaging: {TagResource, UntagResource, ListTagsForResource} diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js index 2a876f62270..9c9cdbb18e8 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -3,20 +3,20 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; -import {copyImageSet} from "../actions/copy-image-set.js"; + // Snippet for README link. + // snippet-start:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] + // snippet-end:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] -const __filename = fileURLToPath(import.meta.url); +import {fileURLToPath} from "url"; const {tagResource} = await import("../actions/tag-resource.js"); const {untagResource} = await import("../actions/untag-resource.js"); const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); - // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - // snippet-start:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.tagging.V3] try { const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; const tags = { @@ -26,17 +26,24 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { } catch (e) { console.log(e); } - // snippet-end:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + // snippet-end:[medical-imaging.JavaScript.datastore.tagging.V3] - // snippet-start:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.list-tags.V3] try { const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; - const tags = { - "Deployment" : "Development" - }; - await tagResource(datastoreArn, tags); + const tags = await listTagsForResource(datastoreArn); + console.log(tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.datastore.list_tags.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.untag.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; + const keys = ["Deployment"]; + await untagResource(datastoreArn, keys); } catch (e) { console.log(e); } - // snippet-end:[medical-imaging.JavaScript.resource.tagging-datastores.V3] + // snippet-end:[medical-imaging.JavaScript.datastore.untag.V3] } From 5a1fe0f139f63f44c6203998b69d93a13cea89eb Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:25:10 -0400 Subject: [PATCH 13/31] yaml fix --- .../medical-imaging/scenarios/tagging-datastores.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js index 9c9cdbb18e8..e2cb08d98c3 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -28,7 +28,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { } // snippet-end:[medical-imaging.JavaScript.datastore.tagging.V3] - // snippet-start:[medical-imaging.JavaScript.datastore.list-tags.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.list_tags.V3] try { const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; const tags = await listTagsForResource(datastoreArn); From 0ca388895eee58aa3157bac68d10efc896a28fe3 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:28:53 -0400 Subject: [PATCH 14/31] yaml fix --- .doc_gen/metadata/medical-imaging_metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 36afceb3920..6b3c5fd1225 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -515,7 +515,7 @@ medical-imaging_tagging_datastores: - description: To list tags for a data store snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - - medical-imaging.JavaScript.datastore.list-tags.V3 + - medical-imaging.JavaScript.datastore.list_tags.V3 - description: To untag a data store snippet_tags: - medical-imaging.JavaScript.resource.unTagResourceV3 From d4df6ca47b5ffa5a9d5a2f40b123abb95ca5ed6a Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:54:02 -0400 Subject: [PATCH 15/31] snippet tweaks --- .../metadata/medical-imaging_metadata.yaml | 20 ++++++---- .../example_code/medical-imaging/README.md | 39 +++++++++++++++++-- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 6b3c5fd1225..336036e6920 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -498,27 +498,31 @@ medical-imaging_ListTagsForResource: medical-imaging_tagging_datastores: title: Tagging a &AHI; data store using an &AWS; SDK title_abbrev: Tagging a data store - synopsis: tagging a &AHI; data store. - category: + synopsis: tag a &AHI; data store. + category: Scenarios languages: JavaScript: versions: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: The following code examples use the &JSBlong; (v2) to tag, list tags, and untag a data store - description: To tag a data store snippet_tags: - - medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3 - - medical-imaging.JavaScript.resource.tagResourceV3 - medical-imaging.JavaScript.datastore.tagging.V3 + - description: The utility function for tagging a resource + snippet_tags: + - medical-imaging.JavaScript.resource.tagResourceV3 - description: To list tags for a data store snippet_tags: - - medical-imaging.JavaScript.resource.listTagsForResourceV3 - - medical-imaging.JavaScript.datastore.list_tags.V3 + - medical-imaging.JavaScript.datastore.list_tags.V3 + - description: The utility function for listing a resource's tags + snippet_tags: + - medical-imaging.JavaScript.resource.listTagsForResourceV3 - description: To untag a data store snippet_tags: - - medical-imaging.JavaScript.resource.unTagResourceV3 - medical-imaging.JavaScript.datastore.untag.V3 + - description: The utility function for untagging a resource + snippet_tags: + - medical-imaging.JavaScript.resource.unTagResourceV3 services: medical-imaging: {TagResource, UntagResource, ListTagsForResource} diff --git a/javascriptv3/example_code/medical-imaging/README.md b/javascriptv3/example_code/medical-imaging/README.md index 449a03b119c..fd74b80dbc1 100644 --- a/javascriptv3/example_code/medical-imaging/README.md +++ b/javascriptv3/example_code/medical-imaging/README.md @@ -1,4 +1,4 @@ - + # HealthImaging code examples for the SDK for JavaScript (v3) ## Overview @@ -12,7 +12,7 @@ Shows how to use the AWS SDK for JavaScript (v3) to work with AWS HealthImaging. ## âš  Important -* Running this code might result in charges to your AWS account. +* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/?aws-products-pricing.sort-by=item.additionalFields.productNameLowercase&aws-products-pricing.sort-order=asc&awsf.Free%20Tier%20Type=*all&awsf.tech-category=*all) and [Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). * Running the tests might result in charges to your AWS account. * We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). * This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). @@ -34,10 +34,31 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas Code excerpts that show you how to call individual service functions. +* [Add a tag to a resource](actions/tag-resource.js#L8) (`TagResource`) +* [Copy an image set](actions/copy-image-set.js#L8) (`CopyImageSet`) * [Create a data store](actions/create-datastore.js#L8) (`CreateDatastore`) -* [Delete a data store](actions/delete-datastore.js#L35) (`DeleteDatastore`) +* [Delete a data store](actions/delete-datastore.js#L8) (`DeleteDatastore`) +* [Delete an image set](actions/delete-image-set.js#L8) (`DeleteImageSet`) +* [Get an image frame](actions/get-image-frame.js#L9) (`GetImageFrame`) * [Get data store properties](actions/get-datastore.js#L8) (`GetDatastore`) +* [Get image set properties](actions/get-image-set.js#L8) (`GetImageSet`) +* [Get import job properties](actions/get-dicom-import-job.js#L8) (`GetDICOMImportJob`) +* [Get metadata for an image set](actions/get-image-set-metadata.js#L8) (`GetImageSetMetadata`) +* [Import bulk data into a data store](actions/start-dicom-import-job.js#L8) (`StartDICOMImportJob`) * [List data stores](actions/list-datastores.js#L8) (`ListDatastores`) +* [List image set versions](actions/list-image-set-versions.js#L8) (`ListImageSetVersions`) +* [List import jobs for a data store](actions/list-dicom-import-jobs.js#L8) (`ListDICOMImportJobs`) +* [List tags for a resource](actions/list-tags-for-resource.js#L8) (`ListTagsForResource`) +* [Remove a tag from a resource](actions/untag-resource.js#L8) (`UntagResource`) +* [Search image sets](actions/search-image-sets.js#L8) (`SearchImageSets`) +* [Update image set metadata](actions/update-image-set-metadata.js#L8) (`UpdateImageSetMetadata`) + +### Scenarios + +Code examples that show you how to accomplish a specific task by calling multiple +functions within the same service. + +* [Tagging a data store](scenarios/tagging-datastores.js) ## Run the examples @@ -63,6 +84,18 @@ node ./scenarios/ +#### Tagging a data store + +This example shows you how to tag a HealthImaging data store. + + + + + + + + + ### Tests âš  Running tests might result in charges to your AWS account. From 9728799d8a48f79af78b45fb84cb372ad93fc4f6 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:41:28 -0400 Subject: [PATCH 16/31] Nearly done --- .../metadata/medical-imaging_metadata.yaml | 69 ++++++++++++++++++- .../actions/get-image-set-metadata.js | 34 +++++++-- .../example_code/medical-imaging/hello.js | 28 ++++++++ .../scenarios/tagging-datastores.js | 10 +-- .../scenarios/tagging-imagesets.js | 45 ++++++++++++ 5 files changed, 173 insertions(+), 13 deletions(-) create mode 100644 javascriptv3/example_code/medical-imaging/hello.js create mode 100644 javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 336036e6920..fa012a673fc 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -1,4 +1,18 @@ # zexi 0.4.0 +medical-imaging_Hello: + title: Hello &S3; + title_abbrev: Hello &S3; + synopsis: get started using &S3;. + category: Hello + languages: + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.datastore.createDatastoreV3 medical-imaging_CreateDatastore: title: Create a &AHI; data store using an &AWS; SDK title_abbrev: Create a data store @@ -250,10 +264,22 @@ medical-imaging_SearchImageSets: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: + - description: The utility function for searching image sets snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3 - services: + - description: "Use case #1: EQUAL operator" + snippet_tags: + - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID + - medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter + - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime" + snippet_tags: + - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID + - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1 + - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)" + snippet_tags: + - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID + - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 + services: medical-imaging: {SearchImageSets} medical-imaging_GetImageSet: title: Get &AHI; image set properties using an &AWS; SDK @@ -298,9 +324,15 @@ medical-imaging_GetImageSetMetadata: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: + - description: Utility function to get image set metadata snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3 + - description: Without version + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion + - description: With version + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion services: medical-imaging: {GetImageSetMetadata} medical-imaging_GetImageFrame: @@ -526,3 +558,34 @@ medical-imaging_tagging_datastores: - medical-imaging.JavaScript.resource.unTagResourceV3 services: medical-imaging: {TagResource, UntagResource, ListTagsForResource} +medical-imaging_tagging_imagesets: + title: Tagging a &AHI; image set using an &AWS; SDK + title_abbrev: Tagging an image set + synopsis: tag a &AHI; image set. + category: Scenarios + languages: + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: To tag an image set + snippet_tags: + - medical-imaging.JavaScript.imageset.tagging.V3 + - description: The utility function for tagging a resource + snippet_tags: + - medical-imaging.JavaScript.resource.tagResourceV3 + - description: To list tags for an image set + snippet_tags: + - medical-imaging.JavaScript.imageset.list_tags.V3 + - description: The utility function for listing a resource's tags + snippet_tags: + - medical-imaging.JavaScript.resource.listTagsForResourceV3 + - description: To untag an image set + snippet_tags: + - medical-imaging.JavaScript.imageset.untag.V3 + - description: The utility function for untagging a resource + snippet_tags: + - medical-imaging.JavaScript.resource.unTagResourceV3 + services: + medical-imaging: {TagResource, UntagResource, ListTagsForResource} diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index b9477343ba6..4cc94f1e6b1 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -11,15 +11,23 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; import {writeFileSync} from "fs"; /** + * @param {string} metadataFileName - The name of the file for gzipped metadata. * @param {string} datastoreId - The ID of the data store. * @param {string} imagesetId - The ID of the image set. - * @param {string} metadataFileName - The name of the file for gzipped metadata. + * @param {string} versionID - The optional version ID of the image set. */ -export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", +export const getImageSetMetadata = async (metadataFileName = "metadata.json.gzip", + datastoreId = "xxxxxxxxxxxxxx", imagesetId = "xxxxxxxxxxxxxx", - metadataFileName = "metadata.json.gzip") => { + versionID = "") => { + const commandArgs = {datastoreId: datastoreId, imageSetId: imagesetId}; + + if (versionID !== "") { + commandArgs.versionID = versionID; + } + const response = await medicalImagingClient.send( - new GetImageSetMetadataCommand({datastoreId: datastoreId, imageSetId: imagesetId}) + new GetImageSetMetadataCommand(commandArgs) ); const buffer = await response.imageSetMetadataBlob.transformToByteArray(); writeFileSync(metadataFileName, buffer); @@ -46,6 +54,22 @@ export const getImageSetMetadata = async (datastoreId = "xxxxxxxxxxxxxx", // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getImageSetMetadata("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0"); + // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] + try { + await getImageSetMetadata("metadata.json.gzip", "12345678901234567890123456789012", + "12345678901234567890123456789012"); + } catch (err) { + console.log("Error", err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] + + // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] + try { + await getImageSetMetadata("metadata2.json.gzip", "12345678901234567890123456789012", + "12345678901234567890123456789012", "1"); + } catch (err) { + console.log("Error", err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] } diff --git a/javascriptv3/example_code/medical-imaging/hello.js b/javascriptv3/example_code/medical-imaging/hello.js new file mode 100644 index 00000000000..a98b9438197 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/hello.js @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +// snippet-start:[javascript.v3.medical-imaging.hello] +import {ListDatastoresCommand, MedicalImagingClient} from "@aws-sdk/client-medical-imaging"; + +// When no region or credentials are provided, the SDK will use the +// region and credentials from the local AWS config. +const client = new MedicalImagingClient({}); + +export const helloMedicalImaging = async () => { + const command = new ListDatastoresCommand({}); + + const {datastoreSummaries} = await client.send(command); + console.log("Datastores: "); + console.log(datastoreSummaries.map(item => item.datastoreName).join("\n")); + return datastoreSummaries; +}; +// snippet-end:[javascript.v3.medical-imaging.hello] + +// Invoke main function if this file was run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + helloMedicalImaging(); +} diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js index e2cb08d98c3..6e91cab26ad 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ - // Snippet for README link. - // snippet-start:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] - // snippet-end:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] +// Snippet for README link. +// snippet-start:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] +// snippet-end:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] import {fileURLToPath} from "url"; @@ -20,7 +20,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { try { const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; const tags = { - "Deployment" : "Development" + "Deployment": "Development" }; await tagResource(datastoreArn, tags); } catch (e) { @@ -31,7 +31,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.datastore.list_tags.V3] try { const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; - const tags = await listTagsForResource(datastoreArn); + const {tags} = await listTagsForResource(datastoreArn); console.log(tags); } catch (e) { console.log(e); diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js new file mode 100644 index 00000000000..db79519a337 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js @@ -0,0 +1,45 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import {fileURLToPath} from "url"; + +const {tagResource} = await import("../actions/tag-resource.js"); +const {untagResource} = await import("../actions/untag-resource.js"); +const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); + +// Invoke the following code if this file is being run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + + // snippet-start:[medical-imaging.JavaScript.imageset.tagging.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const tags = { + "Deployment": "Development" + }; + await tagResource(datastoreArn, tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.tagging.V3] + + // snippet-start:[medical-imaging.JavaScript.imageset.list_tags.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const {tags} = await listTagsForResource(datastoreArn); + console.log(tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.list_tags.V3] + // snippet-start:[medical-imaging.JavaScript.imageset.untag.V3] + try { + const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const keys = ["Deployment"]; + await untagResource(datastoreArn, keys); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.untag.V3] +} From 69bf5f516a85e10f0ec3c470a9d3bfafa78f9b18 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:56:39 -0400 Subject: [PATCH 17/31] snippets and reformatting --- .../metadata/medical-imaging_metadata.yaml | 8 ++++- .../medical-imaging/actions/copy-image-set.js | 17 ++++++++- .../actions/get-image-frame.js | 12 +++---- .../actions/search-image-sets.js | 36 +++++++++---------- ...reate-delete-datastore.integration.test.js | 2 +- .../tests/delete-image-set.unit.test.js | 4 +-- .../tests/get-image-frame.unit.test.js | 2 +- .../tests/get-image-set-metadata.unit.test.js | 34 ++++++++++++++++-- .../tests/list-tags-for-resource.unit.test.js | 4 +-- .../tests/tag-resource.unit.test.js | 8 ++--- .../tests/untag-resource.unit.test.js | 4 +-- 11 files changed, 91 insertions(+), 40 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index fa012a673fc..cd60d268596 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -426,9 +426,15 @@ medical-imaging_CopyImageSet: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: + - description: Utility function to copy an image seet snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3 + - description: Without destination + snippet_tags: + - medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination + - description: With destination + snippet_tags: + - medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination services: medical-imaging: {CopyImageSet} medical-imaging_DeleteImageSet: diff --git a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js index d0e8467fd3e..f5185b35f65 100644 --- a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -72,5 +72,20 @@ export const copyImageSet = async (datastoreId = "xxxxxxxxxxx", imageSetId = "xx // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await copyImageSet(); + // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] + try { + await copyImageSet("12345678901234567890123456789012", "12345678901234567890123456789012", "1"); + } catch (err) { + console.log(err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] + + // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] + try { + await copyImageSet("12345678901234567890123456789012", "12345678901234567890123456789012", "4", + "12345678901234567890123456789012", "1"); + } catch (err) { + console.log(err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index d40a7b29075..5071c99d904 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -11,15 +11,15 @@ import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** + * @param {string} imageFrameFileName - File path to write the image frame. * @param {string} datastoreID - The data store's ID. * @param {string} imageSetID - The image set's ID. * @param {string} imageFrameID - The image frame's ID. - * @param {string} imageFrameFileName - File path to write the image frame. */ -export const getImageFrame = async (datastoreID = "DATASTORE_ID", +export const getImageFrame = async (imageFrameFileName = "image.jph", + datastoreID = "DATASTORE_ID", imageSetID = "IMAGE_SET_ID", - imageFrameID = "IMAGE_FRAME_ID", - imageFrameFileName = "image.jph") => { + imageFrameID = "IMAGE_FRAME_ID") => { const response = await medicalImagingClient.send( new GetImageFrameCommand({ datastoreId: datastoreID, @@ -49,6 +49,6 @@ export const getImageFrame = async (datastoreID = "DATASTORE_ID", // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getImageFrame("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", "110c71bce27b5bee669d1141a2fdb022", - "test.jph"); + await getImageFrame("test.jph", "12345678901234567890123456789012", "12345678901234567890123456789012", + "12345678901234567890123456789012"); } diff --git a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js index c20a71267cf..14e96572d76 100644 --- a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -23,24 +23,24 @@ export const searchImageSets = async (datastoreId = "xxxxxxxx", filters = []) => }) ); console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // imageSetsMetadataSummaries: [ - // { - // DICOMTags: [Object], - // createdAt: "2023-09-19T16:59:40.551Z", - // imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', - // updatedAt: "2023-09-19T16:59:40.551Z", - // version: 1 - // }] - // } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // imageSetsMetadataSummaries: [ + // { + // DICOMTags: [Object], + // createdAt: "2023-09-19T16:59:40.551Z", + // imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', + // updatedAt: "2023-09-19T16:59:40.551Z", + // version: 1 + // }] + // } return response["imageSetsMetadataSummaries"]; }; diff --git a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js index 2ce71160488..6ab79f0cde5 100644 --- a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js @@ -9,7 +9,7 @@ import {wait} from "../../libs/utils/util-timers.js"; describe("createDatastore/deleteDatastore", () => { let datastoreID = ""; - const datastoreName = "createDeleteDatastoreJSTest"; + const datastoreName = "jstest-" + Math.floor(Math.random() * 200000000); it("should create and delete a data store", async () => { // Create topic. diff --git a/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js index 19b2f31370f..6f3b91c27a2 100644 --- a/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js @@ -28,7 +28,7 @@ describe("delete-image-set", () => { const response = { - '$metadata': { + '$metadata': { httpStatusCode: 200, requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', extendedRequestId: undefined, @@ -42,7 +42,7 @@ describe("delete-image-set", () => { imageSetWorkflowStatus: 'DELETING' }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); await deleteImageSet(datastoreId, imageSetID); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js index 1d57adf5357..ed07b2eedee 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js @@ -53,7 +53,7 @@ describe("get-image-set-metadata", () => { send.mockResolvedValueOnce(response); - await getImageFrame(datastoreId, imageSetId, imageFrameID, metadataFileName); + await getImageFrame(metadataFileName, datastoreId, imageSetId, imageFrameID); expect(logSpy).toHaveBeenCalledWith(response); expect(fs.existsSync(metadataFileName)).toBeTruthy(); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js index cfc2e38bfb2..6ea2abb4bf1 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -31,7 +31,7 @@ class StreamMock { const {getImageSetMetadata} = await import("../actions/get-image-set-metadata.js"); describe("get-image-set-metadata", () => { - it("should log the response", async () => { + it("should log the response without version", async () => { const logSpy = vi.spyOn(console, "log"); const datastoreId = "12345678901234567890123456789012"; const imageSetId = "12345678901234567890123456789012"; @@ -53,7 +53,37 @@ describe("get-image-set-metadata", () => { send.mockResolvedValueOnce(response); - await getImageSetMetadata(datastoreId, imageSetId, metadataFileName); + await getImageSetMetadata(metadataFileName, datastoreId, imageSetId); + + expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); + }); + + it("should log the response with version", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const metadataFileName = "med_image_test.gzip"; + const versionID = "1"; + + const response = { + metadata: { + httpStatusCode: 200, + requestId: '5219b274-30ff-4986-8cab-48753de3a599', + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0 + }, + contentType: 'application/json', + contentEncoding: 'gzip', + imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) + }; + + send.mockResolvedValueOnce(response); + + await getImageSetMetadata(metadataFileName, datastoreId, imageSetId, versionID); expect(logSpy).toHaveBeenCalledWith(response); expect(fs.existsSync(metadataFileName)).toBeTruthy(); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js index a8261f1f1cb..24441b1b118 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js @@ -35,10 +35,10 @@ describe("list-tags-for-resource", () => { attempts: 1, totalRetryDelay: 0 }, - tags: { Deployment: 'Development' } + tags: {Deployment: 'Development'} }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); await listTagsForResource(resourceArn); diff --git a/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js index 6976308e995..a18b150cf6e 100644 --- a/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js @@ -25,22 +25,22 @@ describe("resource", () => { const logSpy = vi.spyOn(console, "log"); const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; const tags = { - "Deployment" : "Development" + "Deployment": "Development" } const response = { '$metadata': { - httpStatusCode: 204, + httpStatusCode: 204, requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', extendedRequestId: undefined, cfId: undefined, attempts: 1, totalRetryDelay: 0 - } + } }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); await tagResource(resourceArn, tags); diff --git a/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js index 35d9a6e0fb7..352a4b3dbc2 100644 --- a/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js @@ -29,13 +29,13 @@ describe("untag-resource", () => { const response = { '$metadata': { - httpStatusCode: 204, + httpStatusCode: 204, requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', extendedRequestId: undefined, cfId: undefined, attempts: 1, totalRetryDelay: 0 - } + } }; send.mockResolvedValueOnce(response); From 3879cf4d7c8a88411a70b1f6f9d1cd008c743862 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:02:25 -0400 Subject: [PATCH 18/31] yaml fixes --- .../metadata/medical-imaging_metadata.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index cd60d268596..1a7e0a0043b 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -5,14 +5,14 @@ medical-imaging_Hello: synopsis: get started using &S3;. category: Hello languages: - JavaScript: - versions: - - sdk_version: 3 - github: javascriptv3/example_code/medical-imaging - excerpts: - - description: - snippet_tags: - - medical-imaging.JavaScript.datastore.createDatastoreV3 + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: + snippet_tags: + - medical-imaging.JavaScript.datastore.createDatastoreV3 medical-imaging_CreateDatastore: title: Create a &AHI; data store using an &AWS; SDK title_abbrev: Create a data store @@ -279,7 +279,7 @@ medical-imaging_SearchImageSets: snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 - services: + services: medical-imaging: {SearchImageSets} medical-imaging_GetImageSet: title: Get &AHI; image set properties using an &AWS; SDK From 11abbb9e42c15a8858c096f706f908f77e0c6642 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:43:59 -0400 Subject: [PATCH 19/31] Add pagination minor fixes --- .../metadata/medical-imaging_metadata.yaml | 11 ++++---- .../medical-imaging/actions/copy-image-set.js | 2 +- .../medical-imaging/actions/get-datastore.js | 2 +- .../actions/get-dicom-import-job.js | 2 +- .../actions/get-image-frame.js | 2 +- .../actions/get-image-set-metadata.js | 8 +++--- .../actions/list-dicom-import-jobs.js | 22 +++++++++++----- .../actions/list-image-set-versions.js | 25 +++++++++++++------ .../actions/start-dicom-import-job.js | 2 +- .../actions/update-image-set-metadata.js | 4 +-- .../tests/list-dicom-import-jobs.unit.test.js | 17 +++++++------ .../list-image-set-versions.unit.test.js | 13 +++++----- 12 files changed, 67 insertions(+), 43 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 1a7e0a0043b..cef4e8868a9 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -327,10 +327,10 @@ medical-imaging_GetImageSetMetadata: - description: Utility function to get image set metadata snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3 - - description: Without version + - description: Get image set metadata without version snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion - - description: With version + - description: Get image set metadata with version snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion services: @@ -405,6 +405,7 @@ medical-imaging_UpdateImageSetMetadata: - description: snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 + - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: medical-imaging: {UpdateImageSetMetadata} medical-imaging_CopyImageSet: @@ -426,13 +427,13 @@ medical-imaging_CopyImageSet: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: Utility function to copy an image seet + - description: Utility function to copy an image set snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3 - - description: Without destination + - description: Copy an image set without a destination snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination - - description: With destination + - description: Copy an image set with a destination snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination services: diff --git a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js index f5185b35f65..9c84651734e 100644 --- a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -19,7 +19,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; export const copyImageSet = async (datastoreId = "xxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx", sourceVersionID = "1", destinationImageSetId = "", destinationVersionId = "") => { - let params = { + const params = { datastoreId: datastoreId, sourceImageSetId: imageSetId, copyImageSetInformation: { diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index d103ec1e4a6..96c15dc0d16 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -10,7 +10,7 @@ import {GetDatastoreCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreID - The ID of the data store to retrieve properties for. + * @param {string} datastoreID - The ID of the data store. */ export const getDatastore = async (datastoreID = "DATASTORE_ID") => { const response = await medicalImagingClient.send( diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index 30995eebf92..f7be32ffc39 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -11,7 +11,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. - * @param {string} jobId - The ID of the job. + * @param {string} jobId - The ID of the import job. */ export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", jobId = "xxxxxxxxxxxxxxxxxxxx") => { diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index 5071c99d904..42ea3785e1d 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -11,7 +11,7 @@ import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} imageFrameFileName - File path to write the image frame. + * @param {string} imageFrameFileName - The name of the file for the HTJ2K-encoded image frame. * @param {string} datastoreID - The data store's ID. * @param {string} imageSetID - The image set's ID. * @param {string} imageFrameID - The image frame's ID. diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index 4cc94f1e6b1..e95ee4160f1 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -11,7 +11,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; import {writeFileSync} from "fs"; /** - * @param {string} metadataFileName - The name of the file for gzipped metadata. + * @param {string} metadataFileName - The name of the file for the gzipped metadata. * @param {string} datastoreId - The ID of the data store. * @param {string} imagesetId - The ID of the image set. * @param {string} versionID - The optional version ID of the image set. @@ -20,14 +20,14 @@ export const getImageSetMetadata = async (metadataFileName = "metadata.json.gzip datastoreId = "xxxxxxxxxxxxxx", imagesetId = "xxxxxxxxxxxxxx", versionID = "") => { - const commandArgs = {datastoreId: datastoreId, imageSetId: imagesetId}; + const params = {datastoreId: datastoreId, imageSetId: imagesetId}; if (versionID !== "") { - commandArgs.versionID = versionID; + params.versionID = versionID; } const response = await medicalImagingClient.send( - new GetImageSetMetadataCommand(commandArgs) + new GetImageSetMetadataCommand(params) ); const buffer = await response.imageSetMetadataBlob.transformToByteArray(); writeFileSync(metadataFileName, buffer); diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index 798bb7d296e..60b46bb9aad 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -6,17 +6,27 @@ import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] -import {ListDICOMImportJobsCommand} from "@aws-sdk/client-medical-imaging"; +import {paginateListDICOMImportJobs} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. */ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => { - const response = await medicalImagingClient.send( - new ListDICOMImportJobsCommand({datastoreId: datastoreId}) - ); - console.log(response); + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50 + }; + + const commandParams = {datastoreId: datastoreId}; + const paginator = paginateListDICOMImportJobs(paginatorConfig, commandParams); + + let jobSummaries = []; + for await (const page of paginator) { + // page contains a single paginated output. + jobSummaries.push(...page["jobSummaries"]); + console.log(page); + } // { // '$metadata': { // httpStatusCode: 200, @@ -38,7 +48,7 @@ export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => // } // ]} - return response; + return jobSummaries; }; // snippet-end:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index 482530b8ba0..ff5546bdd90 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -6,7 +6,7 @@ import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] -import {ListImageSetVersionsCommand} from "@aws-sdk/client-medical-imaging"; +import {paginateListImageSetVersions} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** @@ -14,10 +14,21 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} imageSetId - The ID of the image set. */ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx") => { - const response = await medicalImagingClient.send( - new ListImageSetVersionsCommand({datastoreId: datastoreId, imageSetId: imageSetId}) - ); - console.log(response); + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50 + }; + + const commandParams = {datastoreId: datastoreId, imageSetId: imageSetId}; + console.log(paginatorConfig.client.constructor.name) + const paginator = paginateListImageSetVersions(paginatorConfig, commandParams); + + let imageSetPropertiesList = []; + for await (const page of paginator) { + // page contains a single paginated output. + imageSetPropertiesList.push(...page["imageSetPropertiesList"]); + console.log(page); + } // { // '$metadata': { // httpStatusCode: 200, @@ -36,11 +47,11 @@ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSe // versionId: '1' // }] // } - return response; + return imageSetPropertiesList; }; // snippet-end:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listImageSetVersions(); + await listImageSetVersions(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js index e587a7dd639..fe155c04663 100644 --- a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -10,7 +10,7 @@ import {StartDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** - * @param {string} jobName - The name of the job. + * @param {string} jobName - The name of the import job. * @param {string} datastoreId - The ID of the data store. * @param {string} dataAccessRoleArn - The Amazon Resource Name (ARN) of the role that grants permission. * @param {string} inputS3Uri - The URI of the S3 bucket containing the input files. diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js index e310bb4b323..9e9b9bcfdae 100644 --- a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -70,8 +70,8 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { } }; - await updateImageSetMetadata("728f13a131f748bf8d87a55d5ef6c5af", "22b8ce38456a11bfb8e16ff6bf037dd0", - "3", updateMetadata); + await updateImageSetMetadata("12345678901234567890123456789012", "12345678901234567890123456789012", + "1", updateMetadata); // snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] } diff --git a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js index 900fe750e81..4ce248e9de8 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -5,16 +5,15 @@ import {describe, it, expect, vi} from "vitest"; -const send = vi.fn(); +const paginateListDICOMImportJobs = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + paginateListDICOMImportJobs, + } }); const {listDICOMImportJobs} = await import("../actions/list-dicom-import-jobs.js"); @@ -24,7 +23,7 @@ describe("list-dicom-import-job", () => { const logSpy = vi.spyOn(console, "log"); const datastoreId = "12345678901234567890123456789012"; - const response = { + const response = { jobSummaries: [ { dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', @@ -35,10 +34,12 @@ describe("list-dicom-import-job", () => { jobStatus: 'COMPLETED', submittedAt: '2023-09-22T14:48:45.767Z' } - ] + ] }; - send.mockResolvedValueOnce(response); + paginateListDICOMImportJobs.mockImplementationOnce(async function* () { + yield response; + }); await listDICOMImportJobs(datastoreId); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js index 533d6f8170e..a99dabf4fd6 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js @@ -5,16 +5,15 @@ import {describe, it, expect, vi} from "vitest"; -const send = vi.fn(); +const paginateListImageSetVersions = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + paginateListImageSetVersions, + } }); const {listImageSetVersions} = await import("../actions/list-image-set-versions.js"); @@ -45,7 +44,9 @@ describe("list-image-set-versions", () => { }] }; - send.mockResolvedValueOnce(response); + paginateListImageSetVersions.mockImplementationOnce(async function* () { + yield response; + }); await listImageSetVersions(datastoreId, imageSetID); From 5e24a1de1837735a5cf2cf159c7a886de10ec053 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:57:41 -0400 Subject: [PATCH 20/31] formatting changes --- .../medical-imaging/actions/list-image-set-versions.js | 2 +- .../tests/list-dicom-import-jobs.unit.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index ff5546bdd90..093f78d914d 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -53,5 +53,5 @@ export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSe // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listImageSetVersions(); + await listImageSetVersions(); } diff --git a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js index 4ce248e9de8..43bad72ea22 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -13,7 +13,7 @@ vi.doMock("@aws-sdk/client-medical-imaging", async () => { return { ...actual, paginateListDICOMImportJobs, - } + } }); const {listDICOMImportJobs} = await import("../actions/list-dicom-import-jobs.js"); @@ -23,7 +23,7 @@ describe("list-dicom-import-job", () => { const logSpy = vi.spyOn(console, "log"); const datastoreId = "12345678901234567890123456789012"; - const response = { + const response = { jobSummaries: [ { dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', @@ -34,7 +34,7 @@ describe("list-dicom-import-job", () => { jobStatus: 'COMPLETED', submittedAt: '2023-09-22T14:48:45.767Z' } - ] + ] }; paginateListDICOMImportJobs.mockImplementationOnce(async function* () { From 3992db6a40cda6e734a64516f53a95be7c3dedd8 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:08:34 -0400 Subject: [PATCH 21/31] Editorial changes --- .../medical-imaging/actions/tag-resource.js | 2 +- .../medical-imaging/actions/untag-resource.js | 2 +- .../medical-imaging/scenarios/tagging-imagesets.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js index c0083ef251f..104c0a631db 100644 --- a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -11,7 +11,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. - * @param {{}} tags - The tag to add to the resource as JSON. + * @param {{}} tags - The tags to add to the resource as JSON. * - For example: {"Deployment" : "Development"} */ export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", diff --git a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js index a3f5a1d39e4..f61a3ebcfcf 100644 --- a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js @@ -11,7 +11,7 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. - * @param {{}} tagKeys - The keys of the tags to remove. + * @param {[]} tagKeys - The keys of the tags to remove. */ export const untagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", tagKeys = []) => { diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js index db79519a337..ebcc0dea95c 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js @@ -14,11 +14,11 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.imageset.tagging.V3] try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; const tags = { "Deployment": "Development" }; - await tagResource(datastoreArn, tags); + await tagResource(imagesetArn, tags); } catch (e) { console.log(e); } @@ -26,8 +26,8 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.imageset.list_tags.V3] try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; - const {tags} = await listTagsForResource(datastoreArn); + const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const {tags} = await listTagsForResource(imagesetArn); console.log(tags); } catch (e) { console.log(e); @@ -35,9 +35,9 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-end:[medical-imaging.JavaScript.imageset.list_tags.V3] // snippet-start:[medical-imaging.JavaScript.imageset.untag.V3] try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; + const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; const keys = ["Deployment"]; - await untagResource(datastoreArn, keys); + await untagResource(imagesetArn, keys); } catch (e) { console.log(e); } From 0c0fc27b131e6b80dcba9b448f318d0c00cb9d9b Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:05:17 -0400 Subject: [PATCH 22/31] minor fixes --- .../metadata/medical-imaging_metadata.yaml | 9 ++++--- .../example_code/medical-imaging/README.md | 27 ++++++++++++++++++- .../actions/update-image-set-metadata.js | 1 - 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index cef4e8868a9..887ec74e83f 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -1,8 +1,8 @@ # zexi 0.4.0 medical-imaging_Hello: - title: Hello &S3; - title_abbrev: Hello &S3; - synopsis: get started using &S3;. + title: Hello &AHI; + title_abbrev: Hello &AHI; + synopsis: get started using &AHI;. category: Hello languages: JavaScript: @@ -13,6 +13,8 @@ medical-imaging_Hello: - description: snippet_tags: - medical-imaging.JavaScript.datastore.createDatastoreV3 + services: + medical-imaging: {ListDatastores} medical-imaging_CreateDatastore: title: Create a &AHI; data store using an &AWS; SDK title_abbrev: Create a data store @@ -405,6 +407,7 @@ medical-imaging_UpdateImageSetMetadata: - description: snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 + - description: Demonstration of how to encode the metadata - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: medical-imaging: {UpdateImageSetMetadata} diff --git a/javascriptv3/example_code/medical-imaging/README.md b/javascriptv3/example_code/medical-imaging/README.md index fd74b80dbc1..d21ce290f55 100644 --- a/javascriptv3/example_code/medical-imaging/README.md +++ b/javascriptv3/example_code/medical-imaging/README.md @@ -1,4 +1,4 @@ - + # HealthImaging code examples for the SDK for JavaScript (v3) ## Overview @@ -30,6 +30,11 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas + +### Get started + +* [Hello HealthImaging](actions/create-datastore.js#L8) (`ListDatastores`) + ### Single actions Code excerpts that show you how to call individual service functions. @@ -59,6 +64,7 @@ Code examples that show you how to accomplish a specific task by calling multipl functions within the same service. * [Tagging a data store](scenarios/tagging-datastores.js) +* [Tagging an image set](scenarios/tagging-imagesets.js) ## Run the examples @@ -82,6 +88,13 @@ node ./scenarios/ +#### Hello HealthImaging + +This example shows you how to get started using HealthImaging. + +```bash +node ./hello.js +``` #### Tagging a data store @@ -96,6 +109,18 @@ This example shows you how to tag a HealthImaging data store. +#### Tagging an image set + +This example shows you how to tag a HealthImaging image set. + + + + + + + + + ### Tests âš  Running tests might result in charges to your AWS account. diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js index 9e9b9bcfdae..ba4fcb7db7c 100644 --- a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -50,7 +50,6 @@ export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", // snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3] // Invoke the following code if this file is being run directly. - if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] const updatableAttributes = From 28e7522bfd3895d28611f8b310c8cb7ecf254847 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:21:23 -0400 Subject: [PATCH 23/31] formatting --- .../actions/create-datastore.js | 40 +++++++++---------- .../actions/delete-datastore.js | 40 +++++++++---------- .../medical-imaging/actions/get-datastore.js | 6 +-- .../actions/list-datastores.js | 22 +++++----- .../example_code/medical-imaging/hello.js | 12 +++--- .../tests/get-datastore.integration.test.js | 20 +++++----- .../tests/list-datastores.integration.test.js | 12 +++--- 7 files changed, 76 insertions(+), 76 deletions(-) diff --git a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js index 2cb622d04b8..0a250f924c9 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -3,33 +3,33 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { fileURLToPath } from "url"; +import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] -import { CreateDatastoreCommand } from "@aws-sdk/client-medical-imaging"; -import { medicalImagingClient } from "../libs/medicalImagingClient.js"; +import {CreateDatastoreCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreName - The name of the data store to create. */ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { - const response = await medicalImagingClient.send( - new CreateDatastoreCommand({ datastoreName: datastoreName }), - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreStatus: 'CREATING' - // } - return response; + const response = await medicalImagingClient.send( + new CreateDatastoreCommand({datastoreName: datastoreName}), + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreStatus: 'CREATING' + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js index f7c2f5a2612..833de9d890e 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js @@ -3,34 +3,34 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { fileURLToPath } from "url"; +import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.deleteDatastoreV3] -import { DeleteDatastoreCommand } from "@aws-sdk/client-medical-imaging"; -import { medicalImagingClient } from "../libs/medicalImagingClient.js"; +import {DeleteDatastoreCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreID - The ID of the data store to delete. */ export const deleteDatastore = async (datastoreID = "DATASTORE_ID") => { - const response = await medicalImagingClient.send( - new DeleteDatastoreCommand({ datastoreId: datastoreID }), - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'f5beb409-678d-48c9-9173-9a001ee1ebb1', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreStatus: 'DELETING' - // } + const response = await medicalImagingClient.send( + new DeleteDatastoreCommand({datastoreId: datastoreID}), + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'f5beb409-678d-48c9-9173-9a001ee1ebb1', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreStatus: 'DELETING' + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.datastore.deleteDatastoreV3] diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index 9b532a9955b..96c15dc0d16 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { fileURLToPath } from "url"; +import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.getDatastoreV3] -import { GetDatastoreCommand } from "@aws-sdk/client-medical-imaging"; -import { medicalImagingClient } from "../libs/medicalImagingClient.js"; +import {GetDatastoreCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreID - The ID of the data store. diff --git a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js index 5ba1ea722c5..80da7ff77ce 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -3,22 +3,22 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { fileURLToPath } from "url"; +import {fileURLToPath} from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.listDatastoresV3] -import { paginateListDatastores } from "@aws-sdk/client-medical-imaging"; -import { medicalImagingClient } from "../libs/medicalImagingClient.js"; +import {paginateListDatastores} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; export const listDatastores = async () => { - const paginatorConfig = { - client: medicalImagingClient, - pageSize: 50, - }; + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; - const commandParams = {}; - const paginator = paginateListDatastores(paginatorConfig, commandParams); + const commandParams = {}; + const paginator = paginateListDatastores(paginatorConfig, commandParams); - let datastoreSummaries = []; + const datastoreSummaries = []; for await (const page of paginator) { // page contains a single paginated output. datastoreSummaries.push(...page["datastoreSummaries"]); @@ -46,7 +46,7 @@ export const listDatastores = async () => { // ] // } - return datastoreSummaries; + return datastoreSummaries; }; // snippet-end:[medical-imaging.JavaScript.datastore.listDatastoresV3] diff --git a/javascriptv3/example_code/medical-imaging/hello.js b/javascriptv3/example_code/medical-imaging/hello.js index a98b9438197..eded45bd76b 100644 --- a/javascriptv3/example_code/medical-imaging/hello.js +++ b/javascriptv3/example_code/medical-imaging/hello.js @@ -13,16 +13,16 @@ import {ListDatastoresCommand, MedicalImagingClient} from "@aws-sdk/client-medic const client = new MedicalImagingClient({}); export const helloMedicalImaging = async () => { - const command = new ListDatastoresCommand({}); + const command = new ListDatastoresCommand({}); - const {datastoreSummaries} = await client.send(command); - console.log("Datastores: "); - console.log(datastoreSummaries.map(item => item.datastoreName).join("\n")); - return datastoreSummaries; + const {datastoreSummaries} = await client.send(command); + console.log("Datastores: "); + console.log(datastoreSummaries.map(item => item.datastoreName).join("\n")); + return datastoreSummaries; }; // snippet-end:[javascript.v3.medical-imaging.hello] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - helloMedicalImaging(); + helloMedicalImaging(); } diff --git a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js index c77d458518e..060675fc78a 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js @@ -7,14 +7,14 @@ import {describe, it, expect} from "vitest"; import {getDatastore} from "../actions/get-datastore.js"; describe("getDatastore", () => { - it("should throw an error with the default fake data store ID", async () => { - try { - await getDatastore(); - } catch (err) { - console.log(err.message); - expect(err.message).toEqual( - "1 validation error detected: Value 'DATASTORE_ID' at 'datastoreId' failed to satisfy constraint: Member must satisfy regular expression pattern: [0-9a-z]{32}", - ); - } - }); + it("should throw an error with the default fake data store ID", async () => { + try { + await getDatastore(); + } catch (err) { + console.log(err.message); + expect(err.message).toEqual( + "1 validation error detected: Value 'DATASTORE_ID' at 'datastoreId' failed to satisfy constraint: Member must satisfy regular expression pattern: [0-9a-z]{32}", + ); + } + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js index c997466b57e..48d4f1b3d27 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js @@ -1,9 +1,9 @@ -import { describe, it, expect } from "vitest"; -import { listDatastores } from "../actions/list-datastores.js"; +import {describe, it, expect} from "vitest"; +import {listDatastores} from "../actions/list-datastores.js"; describe("ListDatastores", () => { - it("should return a datastores property that is an array", async () => { - const response = await listDatastores(); - expect(response).toBeInstanceOf(Array); - }); + it("should return a datastores property that is an array", async () => { + const response = await listDatastores(); + expect(response).toBeInstanceOf(Array); + }); }); From 970b30bb7ed95b09fad6262550757bda750ba787 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:27:53 -0400 Subject: [PATCH 24/31] yaml fix --- .doc_gen/metadata/medical-imaging_metadata.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 887ec74e83f..ce6a55c49c9 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -543,7 +543,7 @@ medical-imaging_tagging_datastores: synopsis: tag a &AHI; data store. category: Scenarios languages: - JavaScript: + JavaScript: versions: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging @@ -551,19 +551,19 @@ medical-imaging_tagging_datastores: - description: To tag a data store snippet_tags: - medical-imaging.JavaScript.datastore.tagging.V3 - - description: The utility function for tagging a resource + - description: The utility function for tagging a resource snippet_tags: - medical-imaging.JavaScript.resource.tagResourceV3 - description: To list tags for a data store snippet_tags: - medical-imaging.JavaScript.datastore.list_tags.V3 - - description: The utility function for listing a resource's tags + - description: The utility function for listing a resource's tags snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - description: To untag a data store snippet_tags: - medical-imaging.JavaScript.datastore.untag.V3 - - description: The utility function for untagging a resource + - description: The utility function for untagging a resource snippet_tags: - medical-imaging.JavaScript.resource.unTagResourceV3 services: @@ -582,19 +582,19 @@ medical-imaging_tagging_imagesets: - description: To tag an image set snippet_tags: - medical-imaging.JavaScript.imageset.tagging.V3 - - description: The utility function for tagging a resource + - description: The utility function for tagging a resource snippet_tags: - medical-imaging.JavaScript.resource.tagResourceV3 - description: To list tags for an image set snippet_tags: - medical-imaging.JavaScript.imageset.list_tags.V3 - - description: The utility function for listing a resource's tags + - description: The utility function for listing a resource's tags snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - description: To untag an image set snippet_tags: - medical-imaging.JavaScript.imageset.untag.V3 - - description: The utility function for untagging a resource + - description: The utility function for untagging a resource snippet_tags: - medical-imaging.JavaScript.resource.unTagResourceV3 services: From 7ef49d6ae92589bd32c9a6765c9f620c3cd5736d Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:32:53 -0400 Subject: [PATCH 25/31] yaml fixes --- .../metadata/medical-imaging_metadata.yaml | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index ce6a55c49c9..fd341790efd 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -266,18 +266,18 @@ medical-imaging_SearchImageSets: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: The utility function for searching image sets + - description: The utility function for searching image sets. snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3 - - description: "Use case #1: EQUAL operator" + - description: "Use case #1: EQUAL operator." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter - - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime" + - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1 - - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)" + - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 @@ -326,13 +326,13 @@ medical-imaging_GetImageSetMetadata: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: Utility function to get image set metadata + - description: Utility function to get image set metadata. snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3 - - description: Get image set metadata without version + - description: Get image set metadata without version. snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion - - description: Get image set metadata with version + - description: Get image set metadata with version. snippet_tags: - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion services: @@ -407,7 +407,7 @@ medical-imaging_UpdateImageSetMetadata: - description: snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 - - description: Demonstration of how to encode the metadata + - description: Demonstration of how to encode the metadata. - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: medical-imaging: {UpdateImageSetMetadata} @@ -430,13 +430,13 @@ medical-imaging_CopyImageSet: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: Utility function to copy an image set + - description: Utility function to copy an image set. snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3 - - description: Copy an image set without a destination + - description: Copy an image set without a destination. snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination - - description: Copy an image set with a destination + - description: Copy an image set with a destination. snippet_tags: - medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination services: @@ -548,22 +548,22 @@ medical-imaging_tagging_datastores: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: To tag a data store + - description: To tag a data store. snippet_tags: - medical-imaging.JavaScript.datastore.tagging.V3 - - description: The utility function for tagging a resource + - description: The utility function for tagging a resource. snippet_tags: - medical-imaging.JavaScript.resource.tagResourceV3 - - description: To list tags for a data store + - description: To list tags for a data store. snippet_tags: - medical-imaging.JavaScript.datastore.list_tags.V3 - description: The utility function for listing a resource's tags snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - - description: To untag a data store + - description: To untag a data store. snippet_tags: - medical-imaging.JavaScript.datastore.untag.V3 - - description: The utility function for untagging a resource + - description: The utility function for untagging a resource. snippet_tags: - medical-imaging.JavaScript.resource.unTagResourceV3 services: @@ -579,22 +579,22 @@ medical-imaging_tagging_imagesets: - sdk_version: 3 github: javascriptv3/example_code/medical-imaging excerpts: - - description: To tag an image set + - description: To tag an image set. snippet_tags: - medical-imaging.JavaScript.imageset.tagging.V3 - - description: The utility function for tagging a resource + - description: The utility function for tagging a resource. snippet_tags: - medical-imaging.JavaScript.resource.tagResourceV3 - - description: To list tags for an image set + - description: To list tags for an image set. snippet_tags: - medical-imaging.JavaScript.imageset.list_tags.V3 - - description: The utility function for listing a resource's tags + - description: The utility function for listing a resource's tags. snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - - description: To untag an image set + - description: To untag an image set. snippet_tags: - medical-imaging.JavaScript.imageset.untag.V3 - - description: The utility function for untagging a resource + - description: The utility function for untagging a resource. snippet_tags: - medical-imaging.JavaScript.resource.unTagResourceV3 services: From 07dd1894a6af0f83b22de678c74562c34dc8e263 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:34:59 -0400 Subject: [PATCH 26/31] yaml fix --- .doc_gen/metadata/medical-imaging_metadata.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index fd341790efd..b3661a4162d 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -273,11 +273,11 @@ medical-imaging_SearchImageSets: snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter - - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime." + - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime". snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1 - - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)." + - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)". snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 From 14d49b525b58f9428db1d37a8d1368675d9a7845 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 09:07:03 -0400 Subject: [PATCH 27/31] debugging yamllinter --- .doc_gen/metadata/medical-imaging_metadata.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index b3661a4162d..fd341790efd 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -273,11 +273,11 @@ medical-imaging_SearchImageSets: snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter - - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime". + - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1 - - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)". + - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 From c2fdfca6e679babff83c406a892e5acbec4cd5be Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Fri, 6 Oct 2023 09:10:06 -0400 Subject: [PATCH 28/31] yaml madness --- .doc_gen/metadata/medical-imaging_metadata.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index fd341790efd..ae581243930 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -408,6 +408,7 @@ medical-imaging_UpdateImageSetMetadata: snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 - description: Demonstration of how to encode the metadata. + snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: medical-imaging: {UpdateImageSetMetadata} @@ -557,7 +558,7 @@ medical-imaging_tagging_datastores: - description: To list tags for a data store. snippet_tags: - medical-imaging.JavaScript.datastore.list_tags.V3 - - description: The utility function for listing a resource's tags + - description: The utility function for listing a resource's tags. snippet_tags: - medical-imaging.JavaScript.resource.listTagsForResourceV3 - description: To untag a data store. From a02e25768cfafc46c900506cb71a7be30ba10ec9 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:44:59 -0400 Subject: [PATCH 29/31] Update javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js Co-authored-by: Corey Pyle --- .../actions/update-image-set-metadata.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js index ba4fcb7db7c..46696c5acd7 100644 --- a/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.js @@ -53,14 +53,14 @@ export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", if (process.argv[1] === fileURLToPath(import.meta.url)) { // snippet-start:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] const updatableAttributes = - '{' + - ' "SchemaVersion": 1.1,' + - ' "Patient": {' + - ' "DICOM": {' + - ' "PatientName": "Garcia^Gloria"' + - ' }' + - ' }' + - '}'; +JSON.stringify({ + "SchemaVersion": 1.1, + "Patient": { + "DICOM": { + "PatientName": "Garcia^Gloria" + } + } +}) const updateMetadata = { "DICOMUpdates": { From baee744707212a690ac839c54d8942f9c6266b7d Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:30:25 -0400 Subject: [PATCH 30/31] Responses to review --- .../metadata/medical-imaging_metadata.yaml | 4 +- .../example_code/medical-imaging/README.md | 56 +++-- .../medical-imaging/actions/copy-image-set.js | 149 ++++++++------ .../actions/create-datastore.js | 42 ++-- .../actions/delete-datastore.js | 46 ++--- .../actions/delete-image-set.js | 57 +++--- .../medical-imaging/actions/get-datastore.js | 54 ++--- .../actions/get-dicom-import-job.js | 66 +++--- .../actions/get-image-frame.js | 72 ++++--- .../actions/get-image-set-metadata.js | 108 +++++----- .../medical-imaging/actions/get-image-set.js | 71 ++++--- .../actions/list-datastores.js | 76 +++---- .../actions/list-dicom-import-jobs.js | 78 +++---- .../actions/list-image-set-versions.js | 79 +++---- .../actions/list-tags-for-resource.js | 46 +++-- .../actions/search-image-sets.js | 193 ++++++++++-------- .../actions/start-dicom-import-job.js | 70 ++++--- .../medical-imaging/actions/tag-resource.js | 50 ++--- .../medical-imaging/actions/untag-resource.js | 50 ++--- .../example_code/medical-imaging/hello.js | 19 +- .../scenarios/tagging-datastores.js | 72 ++++--- .../scenarios/tagging-imagesets.js | 72 ++++--- .../tests/copy-image-set.unit.test.js | 127 ++++++------ ...reate-delete-datastore.integration.test.js | 86 ++++---- .../tests/delete-image-set.unit.test.js | 70 +++---- .../tests/get-datastore.integration.test.js | 24 +-- .../tests/get-dicom-import-job.unit.test.js | 54 ++--- .../tests/get-image-frame.unit.test.js | 93 +++++---- .../tests/get-image-set-metadata.unit.test.js | 155 +++++++------- .../tests/get-image-set.unit.test.js | 94 ++++----- .../tests/list-datastores.integration.test.js | 12 +- .../tests/list-dicom-import-jobs.unit.test.js | 66 +++--- .../list-image-set-versions.unit.test.js | 80 ++++---- .../tests/list-tags-for-resource.unit.test.js | 65 +++--- .../tests/search-image-set.unit.test.js | 95 ++++----- .../tests/start-dicom-import-job.unit.test.js | 64 +++--- .../tests/tag-resource.unit.test.js | 67 +++--- .../tests/untag-resource.unit.test.js | 63 +++--- .../update-image-set-metadata.unit.test.js | 106 +++++----- 39 files changed, 1486 insertions(+), 1365 deletions(-) diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index ae581243930..91761a5bea6 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -277,7 +277,7 @@ medical-imaging_SearchImageSets: snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1 - - description: "Use case #3: BETWEEN operator using createdAt (time studies were previously persisted)." + - description: "Use case #3: BETWEEN operator using createdAt. Time studies were previously persisted." snippet_tags: - medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID - medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2 @@ -407,7 +407,7 @@ medical-imaging_UpdateImageSetMetadata: - description: snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3 - - description: Demonstration of how to encode the metadata. + - description: Encode the metadata. snippet_tags: - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: diff --git a/javascriptv3/example_code/medical-imaging/README.md b/javascriptv3/example_code/medical-imaging/README.md index c180ca0590f..4f41eab44b5 100644 --- a/javascriptv3/example_code/medical-imaging/README.md +++ b/javascriptv3/example_code/medical-imaging/README.md @@ -13,10 +13,10 @@ _HealthImaging is a HIPAA-eligible service that helps health care providers and ## âš  Important -* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/?aws-products-pricing.sort-by=item.additionalFields.productNameLowercase&aws-products-pricing.sort-order=asc&awsf.Free%20Tier%20Type=*all&awsf.tech-category=*all) and [Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). -* Running the tests might result in charges to your AWS account. -* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). -* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). +- Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/?aws-products-pricing.sort-by=item.additionalFields.productNameLowercase&aws-products-pricing.sort-order=asc&awsf.Free%20Tier%20Type=*all&awsf.tech-category=*all) and [Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). +- Running the tests might result in charges to your AWS account. +- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). +- This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). @@ -30,41 +30,40 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javas - ### Get started -* [Hello HealthImaging](actions/create-datastore.js#L8) (`ListDatastores`) +- [Hello HealthImaging](actions/create-datastore.js#L8) (`ListDatastores`) ### Single actions Code excerpts that show you how to call individual service functions. -* [Add a tag to a resource](actions/tag-resource.js#L8) (`TagResource`) -* [Copy an image set](actions/copy-image-set.js#L8) (`CopyImageSet`) -* [Create a data store](actions/create-datastore.js#L8) (`CreateDatastore`) -* [Delete a data store](actions/delete-datastore.js#L8) (`DeleteDatastore`) -* [Delete an image set](actions/delete-image-set.js#L8) (`DeleteImageSet`) -* [Get an image frame](actions/get-image-frame.js#L9) (`GetImageFrame`) -* [Get data store properties](actions/get-datastore.js#L8) (`GetDatastore`) -* [Get image set properties](actions/get-image-set.js#L8) (`GetImageSet`) -* [Get import job properties](actions/get-dicom-import-job.js#L8) (`GetDICOMImportJob`) -* [Get metadata for an image set](actions/get-image-set-metadata.js#L8) (`GetImageSetMetadata`) -* [Import bulk data into a data store](actions/start-dicom-import-job.js#L8) (`StartDICOMImportJob`) -* [List data stores](actions/list-datastores.js#L8) (`ListDatastores`) -* [List image set versions](actions/list-image-set-versions.js#L8) (`ListImageSetVersions`) -* [List import jobs for a data store](actions/list-dicom-import-jobs.js#L8) (`ListDICOMImportJobs`) -* [List tags for a resource](actions/list-tags-for-resource.js#L8) (`ListTagsForResource`) -* [Remove a tag from a resource](actions/untag-resource.js#L8) (`UntagResource`) -* [Search image sets](actions/search-image-sets.js#L8) (`SearchImageSets`) -* [Update image set metadata](actions/update-image-set-metadata.js#L8) (`UpdateImageSetMetadata`) +- [Add a tag to a resource](actions/tag-resource.js#L8) (`TagResource`) +- [Copy an image set](actions/copy-image-set.js#L8) (`CopyImageSet`) +- [Create a data store](actions/create-datastore.js#L8) (`CreateDatastore`) +- [Delete a data store](actions/delete-datastore.js#L8) (`DeleteDatastore`) +- [Delete an image set](actions/delete-image-set.js#L8) (`DeleteImageSet`) +- [Get an image frame](actions/get-image-frame.js#L9) (`GetImageFrame`) +- [Get data store properties](actions/get-datastore.js#L8) (`GetDatastore`) +- [Get image set properties](actions/get-image-set.js#L8) (`GetImageSet`) +- [Get import job properties](actions/get-dicom-import-job.js#L8) (`GetDICOMImportJob`) +- [Get metadata for an image set](actions/get-image-set-metadata.js#L8) (`GetImageSetMetadata`) +- [Import bulk data into a data store](actions/start-dicom-import-job.js#L8) (`StartDICOMImportJob`) +- [List data stores](actions/list-datastores.js#L8) (`ListDatastores`) +- [List image set versions](actions/list-image-set-versions.js#L8) (`ListImageSetVersions`) +- [List import jobs for a data store](actions/list-dicom-import-jobs.js#L8) (`ListDICOMImportJobs`) +- [List tags for a resource](actions/list-tags-for-resource.js#L8) (`ListTagsForResource`) +- [Remove a tag from a resource](actions/untag-resource.js#L8) (`UntagResource`) +- [Search image sets](actions/search-image-sets.js#L8) (`SearchImageSets`) +- [Update image set metadata](actions/update-image-set-metadata.js#L8) (`UpdateImageSetMetadata`) ### Scenarios Code examples that show you how to accomplish a specific task by calling multiple functions within the same service. -* [Tagging a data store](scenarios/tagging-datastores.js) -* [Tagging an image set](scenarios/tagging-imagesets.js) +- [Tagging a data store](scenarios/tagging-datastores.js) +- [Tagging an image set](scenarios/tagging-imagesets.js) ## Run the examples @@ -97,16 +96,13 @@ This example shows you how to get started using HealthImaging. node ./hello.js ``` - #### Tagging a data store This example shows you how to tag a HealthImaging data store. - - @@ -114,11 +110,9 @@ This example shows you how to tag a HealthImaging data store. This example shows you how to tag a HealthImaging image set. - - diff --git a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js index 9c84651734e..0bda8f1ac7d 100644 --- a/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -3,89 +3,102 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3] -import {CopyImageSetCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { CopyImageSetCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. * @param {string} imageSetId - The source image set ID. - * @param {string} sourceVersionID - The source version ID. + * @param {string} sourceVersionId - The source version ID. * @param {string} destinationImageSetId - The optional ID of the destination image set. * @param {string} destinationVersionId - The optional version ID of the destination image set. */ -export const copyImageSet = async (datastoreId = "xxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx", - sourceVersionID = "1", destinationImageSetId = "", - destinationVersionId = "") => { - const params = { - datastoreId: datastoreId, - sourceImageSetId: imageSetId, - copyImageSetInformation: { - sourceImageSet: {latestVersionId: sourceVersionID} - } +export const copyImageSet = async ( + datastoreId = "xxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxx", + sourceVersionId = "1", + destinationImageSetId = "", + destinationVersionId = "" +) => { + const params = { + datastoreId: datastoreId, + sourceImageSetId: imageSetId, + copyImageSetInformation: { + sourceImageSet: { latestVersionId: sourceVersionId }, + }, + }; + if (destinationImageSetId !== "" && destinationVersionId !== "") { + params.copyImageSetInformation.destinationImageSet = { + imageSetId: destinationImageSetId, + latestVersionId: destinationVersionId, }; - if (destinationImageSetId !== "" && destinationVersionId !== "") { - params.copyImageSetInformation.destinationImageSet = { - imageSetId: destinationImageSetId, - latestVersionId: destinationVersionId - }; - } + } - const response = await medicalImagingClient.send( - new CopyImageSetCommand(params) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxx', - // destinationImageSetProperties: { - // createdAt: 2023-09-27T19:46:21.824Z, - // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', - // imageSetId: 'xxxxxxxxxxxxxxx', - // imageSetState: 'LOCKED', - // imageSetWorkflowStatus: 'COPYING', - // latestVersionId: '1', - // updatedAt: 2023-09-27T19:46:21.824Z - // }, - // sourceImageSetProperties: { - // createdAt: 2023-09-22T14:49:26.427Z, - // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', - // imageSetId: 'xxxxxxxxxxxxxxxx', - // imageSetState: 'LOCKED', - // imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', - // latestVersionId: '4', - // updatedAt: 2023-09-27T19:46:21.824Z - // } - // } - return response; + const response = await medicalImagingClient.send( + new CopyImageSetCommand(params) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxx', + // destinationImageSetProperties: { + // createdAt: 2023-09-27T19:46:21.824Z, + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'COPYING', + // latestVersionId: '1', + // updatedAt: 2023-09-27T19:46:21.824Z + // }, + // sourceImageSetProperties: { + // createdAt: 2023-09-22T14:49:26.427Z, + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', + // latestVersionId: '4', + // updatedAt: 2023-09-27T19:46:21.824Z + // } + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] - try { - await copyImageSet("12345678901234567890123456789012", "12345678901234567890123456789012", "1"); - } catch (err) { - console.log(err); - } - // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] + // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] + try { + await copyImageSet( + "12345678901234567890123456789012", + "12345678901234567890123456789012", + "1" + ); + } catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.without_destination] - // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] - try { - await copyImageSet("12345678901234567890123456789012", "12345678901234567890123456789012", "4", - "12345678901234567890123456789012", "1"); - } catch (err) { - console.log(err); - } - // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] + // snippet-start:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] + try { + await copyImageSet( + "12345678901234567890123456789012", + "12345678901234567890123456789012", + "4", + "12345678901234567890123456789012", + "1" + ); + } catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination] } diff --git a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js index 0a250f924c9..a4a621b953f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -3,37 +3,37 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.createDatastoreV3] -import {CreateDatastoreCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { CreateDatastoreCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreName - The name of the data store to create. */ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { - const response = await medicalImagingClient.send( - new CreateDatastoreCommand({datastoreName: datastoreName}), - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreStatus: 'CREATING' - // } - return response; + const response = await medicalImagingClient.send( + new CreateDatastoreCommand({ datastoreName: datastoreName }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreStatus: 'CREATING' + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.datastore.createDatastoreV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await createDatastore(); + await createDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js index 833de9d890e..f33543713c5 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js @@ -3,38 +3,38 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.deleteDatastoreV3] -import {DeleteDatastoreCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { DeleteDatastoreCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** - * @param {string} datastoreID - The ID of the data store to delete. + * @param {string} datastoreId - The ID of the data store to delete. */ -export const deleteDatastore = async (datastoreID = "DATASTORE_ID") => { - const response = await medicalImagingClient.send( - new DeleteDatastoreCommand({datastoreId: datastoreID}), - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'f5beb409-678d-48c9-9173-9a001ee1ebb1', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreStatus: 'DELETING' - // } +export const deleteDatastore = async (datastoreId = "DATASTORE_ID") => { + const response = await medicalImagingClient.send( + new DeleteDatastoreCommand({ datastoreId }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'f5beb409-678d-48c9-9173-9a001ee1ebb1', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreStatus: 'DELETING' + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.datastore.deleteDatastoreV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await deleteDatastore(); + await deleteDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js index 7b979a1e661..64123790ba6 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.js @@ -3,40 +3,49 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.deleteImageSetV3] -import {DeleteImageSetCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { DeleteImageSetCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The data store ID. * @param {string} imageSetId - The image set ID. */ -export const deleteImageSet = async (datastoreId = "xxxxxxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxxxxxx") => { - const response = await medicalImagingClient.send( - new DeleteImageSetCommand({datastoreId: datastoreId, imageSetId: imageSetId}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxx', - // imageSetId: 'xxxxxxxxxxxxxxx', - // imageSetState: 'LOCKED', - // imageSetWorkflowStatus: 'DELETING' - // } - return response; +export const deleteImageSet = async ( + datastoreId = "xxxxxxxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxxxxxx" +) => { + const response = await medicalImagingClient.send( + new DeleteImageSetCommand({ + datastoreId: datastoreId, + imageSetId: imageSetId, + }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'LOCKED', + // imageSetWorkflowStatus: 'DELETING' + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.imageset.deleteImageSetV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await deleteImageSet("728f13a131f748bf8d87a55d5ef6c5af", "906e1c0ff5e9c69a14a9e4d36e0cea1e"); + await deleteImageSet( + "12345678901234567890123456789012", + "12345678901234567890123456789012" + ); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js index 96c15dc0d16..9b480fa29c7 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -3,43 +3,43 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.getDatastoreV3] -import {GetDatastoreCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { GetDatastoreCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreID - The ID of the data store. */ export const getDatastore = async (datastoreID = "DATASTORE_ID") => { - const response = await medicalImagingClient.send( - new GetDatastoreCommand({datastoreId: datastoreID}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '55ea7d2e-222c-4a6a-871e-4f591f40cadb', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreProperties: { - // createdAt: 2023-08-04T18:50:36.239Z, - // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreName: 'my_datastore', - // datastoreStatus: 'ACTIVE', - // updatedAt: 2023-08-04T18:50:36.239Z - // } - // } - return response["datastoreProperties"]; + const response = await medicalImagingClient.send( + new GetDatastoreCommand({ datastoreId: datastoreID }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '55ea7d2e-222c-4a6a-871e-4f591f40cadb', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreProperties: { + // createdAt: 2023-08-04T18:50:36.239Z, + // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreName: 'my_datastore', + // datastoreStatus: 'ACTIVE', + // updatedAt: 2023-08-04T18:50:36.239Z + // } + // } + return response["datastoreProperties"]; }; // snippet-end:[medical-imaging.JavaScript.datastore.getDatastoreV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getDatastore(); + await getDatastore(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js index f7be32ffc39..6bcc326c4f8 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -3,49 +3,51 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.dicom.getDICOMImportJobV3] -import {GetDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { GetDICOMImportJobCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. * @param {string} jobId - The ID of the import job. */ -export const getDICOMImportJob = async (datastoreId = "xxxxxxxxxxxxxxxxxxxx", - jobId = "xxxxxxxxxxxxxxxxxxxx") => { - const response = await medicalImagingClient.send( - new GetDICOMImportJobCommand({datastoreId: datastoreId, jobId: jobId}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'a2637936-78ea-44e7-98b8-7a87d95dfaee', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // jobProperties: { - // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', - // endedAt: 2023-09-19T17:29:21.753Z, - // inputS3Uri: 's3://healthimaging-source/CTStudy/', - // jobId: ''xxxxxxxxxxxxxxxxxxxxxxxxx'', - // jobName: 'job_1', - // jobStatus: 'COMPLETED', - // outputS3Uri: 's3://health-imaging-dest/ouput_ct/'xxxxxxxxxxxxxxxxxxxxxxxxx'-DicomImport-'xxxxxxxxxxxxxxxxxxxxxxxxx'/', - // submittedAt: 2023-09-19T17:27:25.143Z - // } - // } +export const getDICOMImportJob = async ( + datastoreId = "xxxxxxxxxxxxxxxxxxxx", + jobId = "xxxxxxxxxxxxxxxxxxxx" +) => { + const response = await medicalImagingClient.send( + new GetDICOMImportJobCommand({ datastoreId: datastoreId, jobId: jobId }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'a2637936-78ea-44e7-98b8-7a87d95dfaee', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // jobProperties: { + // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // endedAt: 2023-09-19T17:29:21.753Z, + // inputS3Uri: 's3://healthimaging-source/CTStudy/', + // jobId: ''xxxxxxxxxxxxxxxxxxxxxxxxx'', + // jobName: 'job_1', + // jobStatus: 'COMPLETED', + // outputS3Uri: 's3://health-imaging-dest/ouput_ct/'xxxxxxxxxxxxxxxxxxxxxxxxx'-DicomImport-'xxxxxxxxxxxxxxxxxxxxxxxxx'/', + // submittedAt: 2023-09-19T17:27:25.143Z + // } + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.dicom.getDICOMImportJobV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getDICOMImportJob(); + await getDICOMImportJob(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js index 42ea3785e1d..20b155bcae8 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; -import {writeFileSync} from "fs"; +import { fileURLToPath } from "url"; +import { writeFileSync } from "fs"; // snippet-start:[medical-imaging.JavaScript.imageset.getImageFrameV3] -import {GetImageFrameCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { GetImageFrameCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} imageFrameFileName - The name of the file for the HTJ2K-encoded image frame. @@ -16,39 +16,45 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} imageSetID - The image set's ID. * @param {string} imageFrameID - The image frame's ID. */ -export const getImageFrame = async (imageFrameFileName = "image.jph", - datastoreID = "DATASTORE_ID", - imageSetID = "IMAGE_SET_ID", - imageFrameID = "IMAGE_FRAME_ID") => { - const response = await medicalImagingClient.send( - new GetImageFrameCommand({ - datastoreId: datastoreID, - imageSetId: imageSetID, - imageFrameInformation: {imageFrameId: imageFrameID} - }) - ); - const buffer = await response.imageFrameBlob.transformToByteArray(); - writeFileSync(imageFrameFileName, buffer); +export const getImageFrame = async ( + imageFrameFileName = "image.jph", + datastoreID = "DATASTORE_ID", + imageSetID = "IMAGE_SET_ID", + imageFrameID = "IMAGE_FRAME_ID" +) => { + const response = await medicalImagingClient.send( + new GetImageFrameCommand({ + datastoreId: datastoreID, + imageSetId: imageSetID, + imageFrameInformation: { imageFrameId: imageFrameID }, + }) + ); + const buffer = await response.imageFrameBlob.transformToByteArray(); + writeFileSync(imageFrameFileName, buffer); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'e4ab42a5-25a3-4377-873f-374ecf4380e1', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // contentType: 'application/octet-stream', - // imageFrameBlob: IncomingMessage {} - // } - return response + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'e4ab42a5-25a3-4377-873f-374ecf4380e1', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // contentType: 'application/octet-stream', + // imageFrameBlob: IncomingMessage {} + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.imageset.getImageFrameV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getImageFrame("test.jph", "12345678901234567890123456789012", "12345678901234567890123456789012", - "12345678901234567890123456789012"); + await getImageFrame( + "test.jph", + "12345678901234567890123456789012", + "12345678901234567890123456789012", + "12345678901234567890123456789012" + ); } diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js index e95ee4160f1..bd41dcd42ed 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3] -import {GetImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; -import {writeFileSync} from "fs"; +import { GetImageSetMetadataCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; +import { writeFileSync } from "fs"; /** * @param {string} metadataFileName - The name of the file for the gzipped metadata. @@ -16,60 +16,68 @@ import {writeFileSync} from "fs"; * @param {string} imagesetId - The ID of the image set. * @param {string} versionID - The optional version ID of the image set. */ -export const getImageSetMetadata = async (metadataFileName = "metadata.json.gzip", - datastoreId = "xxxxxxxxxxxxxx", - imagesetId = "xxxxxxxxxxxxxx", - versionID = "") => { - const params = {datastoreId: datastoreId, imageSetId: imagesetId}; +export const getImageSetMetadata = async ( + metadataFileName = "metadata.json.gzip", + datastoreId = "xxxxxxxxxxxxxx", + imagesetId = "xxxxxxxxxxxxxx", + versionID = "" +) => { + const params = { datastoreId: datastoreId, imageSetId: imagesetId }; - if (versionID !== "") { - params.versionID = versionID; - } + if (versionID) { + params.versionID = versionID; + } - const response = await medicalImagingClient.send( - new GetImageSetMetadataCommand(params) - ); - const buffer = await response.imageSetMetadataBlob.transformToByteArray(); - writeFileSync(metadataFileName, buffer); + const response = await medicalImagingClient.send( + new GetImageSetMetadataCommand(params) + ); + const buffer = await response.imageSetMetadataBlob.transformToByteArray(); + writeFileSync(metadataFileName, buffer); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '5219b274-30ff-4986-8cab-48753de3a599', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // contentType: 'application/json', - // contentEncoding: 'gzip', - // imageSetMetadataBlob: IncomingMessage {} - // } + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '5219b274-30ff-4986-8cab-48753de3a599', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // contentType: 'application/json', + // contentEncoding: 'gzip', + // imageSetMetadataBlob: IncomingMessage {} + // } - return response; -} + return response; +}; // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] - try { - await getImageSetMetadata("metadata.json.gzip", "12345678901234567890123456789012", - "12345678901234567890123456789012"); - } catch (err) { - console.log("Error", err); - } - // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] + // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] + try { + await getImageSetMetadata( + "metadata.json.gzip", + "12345678901234567890123456789012", + "12345678901234567890123456789012" + ); + } catch (err) { + console.log("Error", err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion] - // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] - try { - await getImageSetMetadata("metadata2.json.gzip", "12345678901234567890123456789012", - "12345678901234567890123456789012", "1"); - } catch (err) { - console.log("Error", err); - } - // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] + // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] + try { + await getImageSetMetadata( + "metadata2.json.gzip", + "12345678901234567890123456789012", + "12345678901234567890123456789012", + "1" + ); + } catch (err) { + console.log("Error", err); + } + // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion] } - diff --git a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js index b101802693b..d5e9e0938c5 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-image-set.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.getImageSetV3] -import {GetImageSetCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { GetImageSetCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. @@ -15,41 +15,44 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} imageSetVersion - The optional version of the image set. * */ -export const getImageSet = async (datastoreId = "xxxxxxxxxxxxxxx", - imageSetId = "xxxxxxxxxxxxxxx", - imageSetVersion = "") => { - let params = {datastoreId: datastoreId, imageSetId: imageSetId}; - if (imageSetVersion !== "") { - params.imageSetVersion = imageSetVersion; - } - const response = await medicalImagingClient.send( - new GetImageSetCommand(params)); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '0615c161-410d-4d06-9d8c-6e1241bb0a5a', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // createdAt: 2023-09-22T14:49:26.427Z, - // datastoreId: 'xxxxxxxxxxxxxxx', - // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', - // imageSetId: 'xxxxxxxxxxxxxxx', - // imageSetState: 'ACTIVE', - // imageSetWorkflowStatus: 'CREATED', - // updatedAt: 2023-09-22T14:49:26.427Z, - // versionId: '1' - // } +export const getImageSet = async ( + datastoreId = "xxxxxxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxxxxx", + imageSetVersion = "" +) => { + let params = { datastoreId: datastoreId, imageSetId: imageSetId }; + if (imageSetVersion !== "") { + params.imageSetVersion = imageSetVersion; + } + const response = await medicalImagingClient.send( + new GetImageSetCommand(params) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '0615c161-410d-4d06-9d8c-6e1241bb0a5a', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // createdAt: 2023-09-22T14:49:26.427Z, + // datastoreId: 'xxxxxxxxxxxxxxx', + // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', + // imageSetId: 'xxxxxxxxxxxxxxx', + // imageSetState: 'ACTIVE', + // imageSetWorkflowStatus: 'CREATED', + // updatedAt: 2023-09-22T14:49:26.427Z, + // versionId: '1' + // } - return response; -} + return response; +}; // snippet-end:[medical-imaging.JavaScript.imageset.getImageSetV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await getImageSet(); + await getImageSet(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js index 80da7ff77ce..4ee4018b41f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -3,54 +3,54 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.datastore.listDatastoresV3] -import {paginateListDatastores} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { paginateListDatastores } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; export const listDatastores = async () => { - const paginatorConfig = { - client: medicalImagingClient, - pageSize: 50, - }; + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; - const commandParams = {}; - const paginator = paginateListDatastores(paginatorConfig, commandParams); + const commandParams = {}; + const paginator = paginateListDatastores(paginatorConfig, commandParams); - const datastoreSummaries = []; - for await (const page of paginator) { - // page contains a single paginated output. - datastoreSummaries.push(...page["datastoreSummaries"]); - console.log(page); - } - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '6aa99231-d9c2-4716-a46e-edb830116fa3', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreSummaries: [ - // { - // createdAt: 2023-08-04T18:49:54.429Z, - // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // datastoreName: 'my_datastore', - // datastoreStatus: 'ACTIVE', - // updatedAt: 2023-08-04T18:49:54.429Z - // } - // ... - // ] - // } + const datastoreSummaries = []; + for await (const page of paginator) { + // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`. + datastoreSummaries.push(...page["datastoreSummaries"]); + console.log(page); + } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6aa99231-d9c2-4716-a46e-edb830116fa3', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreSummaries: [ + // { + // createdAt: 2023-08-04T18:49:54.429Z, + // datastoreArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // datastoreName: 'my_datastore', + // datastoreStatus: 'ACTIVE', + // updatedAt: 2023-08-04T18:49:54.429Z + // } + // ... + // ] + // } - return datastoreSummaries; + return datastoreSummaries; }; // snippet-end:[medical-imaging.JavaScript.datastore.listDatastoresV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listDatastores(); + await listDatastores(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js index 60b46bb9aad..a4720bcc7aa 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -3,56 +3,58 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] -import {paginateListDICOMImportJobs} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { paginateListDICOMImportJobs } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. */ -export const listDICOMImportJobs = async (datastoreId = "xxxxxxxxxxxxxxxxxx") => { - const paginatorConfig = { - client: medicalImagingClient, - pageSize: 50 - }; +export const listDICOMImportJobs = async ( + datastoreId = "xxxxxxxxxxxxxxxxxx" +) => { + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; - const commandParams = {datastoreId: datastoreId}; - const paginator = paginateListDICOMImportJobs(paginatorConfig, commandParams); + const commandParams = { datastoreId: datastoreId }; + const paginator = paginateListDICOMImportJobs(paginatorConfig, commandParams); - let jobSummaries = []; - for await (const page of paginator) { - // page contains a single paginated output. - jobSummaries.push(...page["jobSummaries"]); - console.log(page); - } - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '3c20c66e-0797-446a-a1d8-91b742fd15a0', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // jobSummaries: [ - // { - // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', - // endedAt: 2023-09-22T14:49:51.351Z, - // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', - // jobName: 'test-1', - // jobStatus: 'COMPLETED', - // submittedAt: 2023-09-22T14:48:45.767Z - // } - // ]} + let jobSummaries = []; + for await (const page of paginator) { + // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`. + jobSummaries.push(...page["jobSummaries"]); + console.log(page); + } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '3c20c66e-0797-446a-a1d8-91b742fd15a0', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // jobSummaries: [ + // { + // dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // endedAt: 2023-09-22T14:49:51.351Z, + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxx', + // jobName: 'test-1', + // jobStatus: 'COMPLETED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + // ]} - return jobSummaries; + return jobSummaries; }; // snippet-end:[medical-imaging.JavaScript.dicom.listDICOMImportJobsV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listDICOMImportJobs(); + await listDICOMImportJobs(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js index 093f78d914d..83c4f8210f1 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -3,55 +3,60 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] -import {paginateListImageSetVersions} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { paginateListImageSetVersions } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. * @param {string} imageSetId - The ID of the image set. */ -export const listImageSetVersions = async (datastoreId = "xxxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx") => { - const paginatorConfig = { - client: medicalImagingClient, - pageSize: 50 - }; +export const listImageSetVersions = async ( + datastoreId = "xxxxxxxxxxxx", + imageSetId = "xxxxxxxxxxxx" +) => { + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; - const commandParams = {datastoreId: datastoreId, imageSetId: imageSetId}; - console.log(paginatorConfig.client.constructor.name) - const paginator = paginateListImageSetVersions(paginatorConfig, commandParams); + const commandParams = { datastoreId, imageSetId }; + const paginator = paginateListImageSetVersions( + paginatorConfig, + commandParams + ); - let imageSetPropertiesList = []; - for await (const page of paginator) { - // page contains a single paginated output. - imageSetPropertiesList.push(...page["imageSetPropertiesList"]); - console.log(page); - } - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '74590b37-a002-4827-83f2-3c590279c742', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // imageSetPropertiesList: [ - // { - // ImageSetWorkflowStatus: 'CREATED', - // createdAt: 2023-09-22T14:49:26.427Z, - // imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxx', - // imageSetState: 'ACTIVE', - // versionId: '1' - // }] - // } - return imageSetPropertiesList; + let imageSetPropertiesList = []; + for await (const page of paginator) { + // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`. + imageSetPropertiesList.push(...page["imageSetPropertiesList"]); + console.log(page); + } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '74590b37-a002-4827-83f2-3c590279c742', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // imageSetPropertiesList: [ + // { + // ImageSetWorkflowStatus: 'CREATED', + // createdAt: 2023-09-22T14:49:26.427Z, + // imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxx', + // imageSetState: 'ACTIVE', + // versionId: '1' + // }] + // } + return imageSetPropertiesList; }; // snippet-end:[medical-imaging.JavaScript.imageset.listImageSetVersionsV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listImageSetVersions(); + await listImageSetVersions(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js index 8841ac78d89..8aa26777825 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js @@ -3,37 +3,41 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.resource.listTagsForResourceV3] -import {ListTagsForResourceCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { ListTagsForResourceCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. */ -export const listTagsForResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxx:datastore/xxx/imageset/xxx") => { - const response = await medicalImagingClient.send( - new ListTagsForResourceCommand({resourceArn: resourceArn}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // tags: { Deployment: 'Development' } - // } +export const listTagsForResource = async ( + resourceArn = "arn:aws:medical-imaging:us-east-1:xxx:datastore/xxx/imageset/xxx" +) => { + const response = await medicalImagingClient.send( + new ListTagsForResourceCommand({ resourceArn: resourceArn }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // tags: { Deployment: 'Development' } + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.resource.listTagsForResourceV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await listTagsForResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af"); + await listTagsForResource( + "arn:aws:medical-imaging:us-east-1:1234567890:datastore/123456789901234567890123456789012" + ); } diff --git a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js index 14e96572d76..9fbe934cb31 100644 --- a/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -3,108 +3,129 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3] -import {SearchImageSetsCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { paginateSearchImageSets } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The data store's ID. - * @param {[]} filters - The search criteria filters. + * @param { import('@aws-sdk/client-medical-imaging').SearchFilter[] } filters - The search criteria filters. */ -export const searchImageSets = async (datastoreId = "xxxxxxxx", filters = []) => { - const response = await medicalImagingClient.send( - new SearchImageSetsCommand({ - datastoreId: datastoreId, - searchCriteria: { - filters: filters - } - }) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // imageSetsMetadataSummaries: [ - // { - // DICOMTags: [Object], - // createdAt: "2023-09-19T16:59:40.551Z", - // imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', - // updatedAt: "2023-09-19T16:59:40.551Z", - // version: 1 - // }] - // } +export const searchImageSets = async ( + datastoreId = "xxxxxxxx", + filters = [] +) => { + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; - return response["imageSetsMetadataSummaries"]; + const commandParams = { + datastoreId: datastoreId, + searchCriteria: { + filters, + }, + }; + + const paginator = paginateSearchImageSets(paginatorConfig, commandParams); + + const imageSetsMetadataSummaries = []; + for await (const page of paginator) { + // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`. + imageSetsMetadataSummaries.push(...page["imageSetsMetadataSummaries"]); + console.log(page); + } + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // imageSetsMetadataSummaries: [ + // { + // DICOMTags: [Object], + // createdAt: "2023-09-19T16:59:40.551Z", + // imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', + // updatedAt: "2023-09-19T16:59:40.551Z", + // version: 1 + // }] + // } + + return imageSetsMetadataSummaries; }; // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] - const datastoreId = "12345678901234567890123456789012"; - // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] - // Search using EQUAL operator. - // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] - try { - const filters = [{ - values: [{DICOMPatientId: "9227465"}], - operator: "EQUAL" - }]; + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] + const datastoreId = "12345678901234567890123456789012"; + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID] + // Search using EQUAL operator. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] + try { + const filters = [ + { + values: [{ DICOMPatientId: "9227465" }], + operator: "EQUAL", + }, + ]; - await searchImageSets(datastoreId, filters); - } catch (err) { - console.error(err); - } - // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] + await searchImageSets(datastoreId, filters); + } catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.equalFilter] - // Search with BETWEEN operator using DICOMStudyDate and DICOMStudyTime. - // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] - try { - const filters = [{ - values: [{ - DICOMStudyDateAndTime: { - DICOMStudyDate: '19900101', - DICOMStudyTime: '000000' - } + // Search with BETWEEN operator using DICOMStudyDate and DICOMStudyTime. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] + try { + const filters = [ + { + values: [ + { + DICOMStudyDateAndTime: { + DICOMStudyDate: "19900101", + DICOMStudyTime: "000000", + }, + }, + { + DICOMStudyDateAndTime: { + DICOMStudyDate: "20230901", + DICOMStudyTime: "000000", }, - { - DICOMStudyDateAndTime: { - DICOMStudyDate: '20230901', - DICOMStudyTime: '000000' - } - }], - operator: "BETWEEN" - }]; + }, + ], + operator: "BETWEEN", + }, + ]; - await searchImageSets(datastoreId, filters); - } catch (err) { - console.error(err); - } - // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] + await searchImageSets(datastoreId, filters); + } catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter1] - // Search with BETWEEN operator and createdAt date. - // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] - try { - const filters = [{ - values: [ - {createdAt: new Date("1985-04-12T23:20:50.52Z")}, - {createdAt: new Date("2023-09-12T23:20:50.52Z")}, - ], - operator: "BETWEEN" - }]; + // Search with BETWEEN operator and createdAt date. + // snippet-start:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] + try { + const filters = [ + { + values: [ + { createdAt: new Date("1985-04-12T23:20:50.52Z") }, + { createdAt: new Date("2023-09-12T23:20:50.52Z") }, + ], + operator: "BETWEEN", + }, + ]; - await searchImageSets(datastoreId, filters); - } catch (err) { - console.error(err); - } - // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] + await searchImageSets(datastoreId, filters); + } catch (err) { + console.error(err); + } + // snippet-end:[medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2] } -`` \ No newline at end of file diff --git a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js index fe155c04663..62178c90671 100644 --- a/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -3,11 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.dicom.startDicomImportJobV3] -import {StartDICOMImportJobCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { StartDICOMImportJobCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} jobName - The name of the import job. @@ -16,40 +16,42 @@ import {medicalImagingClient} from "../libs/medicalImagingClient.js"; * @param {string} inputS3Uri - The URI of the S3 bucket containing the input files. * @param {string} outputS3Uri - The URI of the S3 bucket where the output files are stored. */ -export const startDicomImportJob = async (jobName = "test-1", - datastoreId = "12345678901234567890123456789012", - dataAccessRoleArn = "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", - inputS3Uri = "s3://medical-imaging-dicom-input/dicom_input/", - outputS3Uri = "s3://medical-imaging-output/job_output/") => { - const response = await medicalImagingClient.send( - new StartDICOMImportJobCommand({ - jobName: jobName, - datastoreId: datastoreId, - dataAccessRoleArn: dataAccessRoleArn, - inputS3Uri: inputS3Uri, - outputS3Uri: outputS3Uri - }) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 200, - // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // }, - // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // jobStatus: 'SUBMITTED', - // submittedAt: 2023-09-22T14:48:45.767Z - // } - return response; +export const startDicomImportJob = async ( + jobName = "test-1", + datastoreId = "12345678901234567890123456789012", + dataAccessRoleArn = "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", + inputS3Uri = "s3://medical-imaging-dicom-input/dicom_input/", + outputS3Uri = "s3://medical-imaging-output/job_output/" +) => { + const response = await medicalImagingClient.send( + new StartDICOMImportJobCommand({ + jobName: jobName, + datastoreId: datastoreId, + dataAccessRoleArn: dataAccessRoleArn, + inputS3Uri: inputS3Uri, + outputS3Uri: outputS3Uri, + }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 200, + // requestId: '6e81d191-d46b-4e48-a08a-cdcc7e11eb79', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // }, + // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + // jobStatus: 'SUBMITTED', + // submittedAt: 2023-09-22T14:48:45.767Z + // } + return response; }; // snippet-end:[medical-imaging.JavaScript.dicom.startDicomImportJobV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await startDicomImportJob(); + await startDicomImportJob(); } diff --git a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js index 104c0a631db..b3bb4369509 100644 --- a/javascriptv3/example_code/medical-imaging/actions/tag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -3,40 +3,44 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.resource.tagResourceV3] -import {TagResourceCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { TagResourceCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. - * @param {{}} tags - The tags to add to the resource as JSON. + * @param {Record} tags - The tags to add to the resource as JSON. * - For example: {"Deployment" : "Development"} */ -export const tagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", - tags = {}) => { - const response = await medicalImagingClient.send( - new TagResourceCommand({resourceArn: resourceArn, tags: tags}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 204, - // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // } - // } +export const tagResource = async ( + resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", + tags = {} +) => { + const response = await medicalImagingClient.send( + new TagResourceCommand({ resourceArn: resourceArn, tags: tags }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 204, + // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // } + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.resource.tagResourceV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await tagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", - {"Deployment": "Development"}); + await tagResource( + "arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", + { Deployment: "Development" } + ); } diff --git a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js index f61a3ebcfcf..f4f5897bb15 100644 --- a/javascriptv3/example_code/medical-imaging/actions/untag-resource.js +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.js @@ -3,39 +3,43 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[medical-imaging.JavaScript.resource.unTagResourceV3] -import {UntagResourceCommand} from "@aws-sdk/client-medical-imaging"; -import {medicalImagingClient} from "../libs/medicalImagingClient.js"; +import { UntagResourceCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. - * @param {[]} tagKeys - The keys of the tags to remove. + * @param {string[]} tagKeys - The keys of the tags to remove. */ -export const untagResource = async (resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", - tagKeys = []) => { - const response = await medicalImagingClient.send( - new UntagResourceCommand({resourceArn: resourceArn, tagKeys: tagKeys}) - ); - console.log(response); - // { - // '$metadata': { - // httpStatusCode: 204, - // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', - // extendedRequestId: undefined, - // cfId: undefined, - // attempts: 1, - // totalRetryDelay: 0 - // } - // } +export const untagResource = async ( + resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", + tagKeys = [] +) => { + const response = await medicalImagingClient.send( + new UntagResourceCommand({ resourceArn: resourceArn, tagKeys: tagKeys }) + ); + console.log(response); + // { + // '$metadata': { + // httpStatusCode: 204, + // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', + // extendedRequestId: undefined, + // cfId: undefined, + // attempts: 1, + // totalRetryDelay: 0 + // } + // } - return response; + return response; }; // snippet-end:[medical-imaging.JavaScript.resource.unTagResourceV3] // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - await untagResource("arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", - ["Deployment"]); + await untagResource( + "arn:aws:medical-imaging:us-east-1:123502194722:datastore/728f13a131f748bf8d87a55d5ef6c5af", + ["Deployment"] + ); } diff --git a/javascriptv3/example_code/medical-imaging/hello.js b/javascriptv3/example_code/medical-imaging/hello.js index eded45bd76b..6669ac4b0e4 100644 --- a/javascriptv3/example_code/medical-imaging/hello.js +++ b/javascriptv3/example_code/medical-imaging/hello.js @@ -3,26 +3,29 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; // snippet-start:[javascript.v3.medical-imaging.hello] -import {ListDatastoresCommand, MedicalImagingClient} from "@aws-sdk/client-medical-imaging"; +import { + ListDatastoresCommand, + MedicalImagingClient, +} from "@aws-sdk/client-medical-imaging"; // When no region or credentials are provided, the SDK will use the // region and credentials from the local AWS config. const client = new MedicalImagingClient({}); export const helloMedicalImaging = async () => { - const command = new ListDatastoresCommand({}); + const command = new ListDatastoresCommand({}); - const {datastoreSummaries} = await client.send(command); - console.log("Datastores: "); - console.log(datastoreSummaries.map(item => item.datastoreName).join("\n")); - return datastoreSummaries; + const { datastoreSummaries } = await client.send(command); + console.log("Datastores: "); + console.log(datastoreSummaries.map((item) => item.datastoreName).join("\n")); + return datastoreSummaries; }; // snippet-end:[javascript.v3.medical-imaging.hello] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { - helloMedicalImaging(); + helloMedicalImaging(); } diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js index 6e91cab26ad..e211d06e4cf 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -7,43 +7,47 @@ // snippet-start:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] // snippet-end:[medical-imaging.JavaScript.medical-imaging_tagging_datastores.V3] -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; -const {tagResource} = await import("../actions/tag-resource.js"); -const {untagResource} = await import("../actions/untag-resource.js"); -const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); +const { tagResource } = await import("../actions/tag-resource.js"); +const { untagResource } = await import("../actions/untag-resource.js"); +const { listTagsForResource } = await import( + "../actions/list-tags-for-resource.js" +); // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { + // snippet-start:[medical-imaging.JavaScript.datastore.tagging.V3] + try { + const datastoreArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; + const tags = { + Deployment: "Development", + }; + await tagResource(datastoreArn, tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.datastore.tagging.V3] - // snippet-start:[medical-imaging.JavaScript.datastore.tagging.V3] - try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; - const tags = { - "Deployment": "Development" - }; - await tagResource(datastoreArn, tags); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.datastore.tagging.V3] - - // snippet-start:[medical-imaging.JavaScript.datastore.list_tags.V3] - try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; - const {tags} = await listTagsForResource(datastoreArn); - console.log(tags); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.datastore.list_tags.V3] - // snippet-start:[medical-imaging.JavaScript.datastore.untag.V3] - try { - const datastoreArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'; - const keys = ["Deployment"]; - await untagResource(datastoreArn, keys); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.datastore.untag.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.list_tags.V3] + try { + const datastoreArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; + const { tags } = await listTagsForResource(datastoreArn); + console.log(tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.datastore.list_tags.V3] + // snippet-start:[medical-imaging.JavaScript.datastore.untag.V3] + try { + const datastoreArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"; + const keys = ["Deployment"]; + await untagResource(datastoreArn, keys); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.datastore.untag.V3] } diff --git a/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js index ebcc0dea95c..ac4ad4c5f56 100644 --- a/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js @@ -3,43 +3,47 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {fileURLToPath} from "url"; +import { fileURLToPath } from "url"; -const {tagResource} = await import("../actions/tag-resource.js"); -const {untagResource} = await import("../actions/untag-resource.js"); -const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); +const { tagResource } = await import("../actions/tag-resource.js"); +const { untagResource } = await import("../actions/untag-resource.js"); +const { listTagsForResource } = await import( + "../actions/list-tags-for-resource.js" +); // Invoke the following code if this file is being run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { + // snippet-start:[medical-imaging.JavaScript.imageset.tagging.V3] + try { + const imagesetArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; + const tags = { + Deployment: "Development", + }; + await tagResource(imagesetArn, tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.tagging.V3] - // snippet-start:[medical-imaging.JavaScript.imageset.tagging.V3] - try { - const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; - const tags = { - "Deployment": "Development" - }; - await tagResource(imagesetArn, tags); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.imageset.tagging.V3] - - // snippet-start:[medical-imaging.JavaScript.imageset.list_tags.V3] - try { - const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; - const {tags} = await listTagsForResource(imagesetArn); - console.log(tags); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.imageset.list_tags.V3] - // snippet-start:[medical-imaging.JavaScript.imageset.untag.V3] - try { - const imagesetArn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012'; - const keys = ["Deployment"]; - await untagResource(imagesetArn, keys); - } catch (e) { - console.log(e); - } - // snippet-end:[medical-imaging.JavaScript.imageset.untag.V3] + // snippet-start:[medical-imaging.JavaScript.imageset.list_tags.V3] + try { + const imagesetArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; + const { tags } = await listTagsForResource(imagesetArn); + console.log(tags); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.list_tags.V3] + // snippet-start:[medical-imaging.JavaScript.imageset.untag.V3] + try { + const imagesetArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012"; + const keys = ["Deployment"]; + await untagResource(imagesetArn, keys); + } catch (e) { + console.log(e); + } + // snippet-end:[medical-imaging.JavaScript.imageset.untag.V3] } diff --git a/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js index 75ffb97d7be..2fe10b135b6 100644 --- a/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js @@ -3,81 +3,86 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {copyImageSet} = await import("../actions/copy-image-set.js"); +const { copyImageSet } = await import("../actions/copy-image-set.js"); describe("copy-image-set", () => { - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - datastoreId: 'xxxxxxxxxxxxxx', - destinationImageSetProperties: { - createdAt: "2023-09-27T19:46:21.824Z", - imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', - imageSetId: 'xxxxxxxxxxxxxxx', - imageSetState: 'LOCKED', - imageSetWorkflowStatus: 'COPYING', - latestVersionId: '1', - updatedAt: "2023-09-27T19:46:21.824Z" - }, - sourceImageSetProperties: { - createdAt: "2023-09-22T14:49:26.427Z", - imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', - imageSetId: 'xxxxxxxxxxxxxxxx', - imageSetState: 'LOCKED', - imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', - latestVersionId: '4', - updatedAt: "2023-09-27T19:46:21.824Z" - } - }; + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "d9b219ce-cc48-4a44-a5b2-c5c3068f1ee8", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + datastoreId: "xxxxxxxxxxxxxx", + destinationImageSetProperties: { + createdAt: "2023-09-27T19:46:21.824Z", + imageSetArn: + "arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx", + imageSetId: "xxxxxxxxxxxxxxx", + imageSetState: "LOCKED", + imageSetWorkflowStatus: "COPYING", + latestVersionId: "1", + updatedAt: "2023-09-27T19:46:21.824Z", + }, + sourceImageSetProperties: { + createdAt: "2023-09-22T14:49:26.427Z", + imageSetArn: + "arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx", + imageSetId: "xxxxxxxxxxxxxxxx", + imageSetState: "LOCKED", + imageSetWorkflowStatus: "COPYING_WITH_READ_ONLY_ACCESS", + latestVersionId: "4", + updatedAt: "2023-09-27T19:46:21.824Z", + }, + }; - it("should log the response without destination", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetID = "12345678901234567890123456789012"; - const sourceVersionId = "1"; + it("should log the response without destination", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + const sourceVersionId = "1"; + send.mockResolvedValueOnce(response); - send.mockResolvedValueOnce(response); + await copyImageSet(datastoreId, imageSetID, sourceVersionId); - await copyImageSet(datastoreId, imageSetID, sourceVersionId); + expect(logSpy).toHaveBeenCalledWith(response); + }); - expect(logSpy).toHaveBeenCalledWith(response); - }); + it("should log the response with destination", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + const sourceVersionId = "1"; + const destinationImageSetID = "12345678901234567890123456789012"; + const destinationVersionId = "1"; - it("should log the response with destination", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetID = "12345678901234567890123456789012"; - const sourceVersionId = "1"; - const destinationImageSetID = "12345678901234567890123456789012"; - const destinationVersionId = "1"; + send.mockResolvedValueOnce(response); + await copyImageSet( + datastoreId, + imageSetID, + sourceVersionId, + destinationImageSetID, + destinationVersionId + ); - send.mockResolvedValueOnce(response); - - await copyImageSet(datastoreId, imageSetID, sourceVersionId, destinationImageSetID, destinationVersionId); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js index 6ab79f0cde5..ebc5ae49abe 100644 --- a/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/create-delete-datastore.integration.test.js @@ -1,46 +1,46 @@ -import {describe, it, expect} from "vitest"; - -import {createDatastore} from "../actions/create-datastore.js"; -import {deleteDatastore} from "../actions/delete-datastore.js"; -import {getDatastore} from "../actions/get-datastore.js"; -import {listDatastores} from "../actions/list-datastores.js"; -import {wait} from "../../libs/utils/util-timers.js"; +import { describe, it, expect } from "vitest"; +import { createDatastore } from "../actions/create-datastore.js"; +import { deleteDatastore } from "../actions/delete-datastore.js"; +import { getDatastore } from "../actions/get-datastore.js"; +import { listDatastores } from "../actions/list-datastores.js"; +import { wait } from "../../libs/utils/util-timers.js"; describe("createDatastore/deleteDatastore", () => { - let datastoreID = ""; - const datastoreName = "jstest-" + Math.floor(Math.random() * 200000000); - - it("should create and delete a data store", async () => { - // Create topic. - const createDatastoreCommandOutput = await createDatastore(datastoreName); - datastoreID = createDatastoreCommandOutput.datastoreId; - - expect(datastoreID).toBeDefined(); - - let status = "NONE"; - let counter = 1; - while ((counter < 20) && (status !== "ACTIVE")) { // Redundant check with test timeout. - await wait(1); - const getDatastoreCommandOutput = await getDatastore(datastoreID); - status = getDatastoreCommandOutput["datastoreStatus"]; // eslint-disable-line - counter++; - } - - const listDatastoresCommandOutput = await listDatastores(); - - let found = false; - for (const datastore of listDatastoresCommandOutput) { - if (datastore.datastoreId === datastoreID) { // eslint-disable-line - found = true; - break; - } - } - - expect(found).toBe(true); - - // Delete topic. - await deleteDatastore(datastoreID); - }); - }, - 20000); // 20 seconds test timeout. + let datastoreID = ""; + const datastoreName = "jstest-" + Math.floor(Math.random() * 200000000); + + it("should create and delete a data store", async () => { + // Create topic. + const createDatastoreCommandOutput = await createDatastore(datastoreName); + datastoreID = createDatastoreCommandOutput.datastoreId; + + expect(datastoreID).toBeDefined(); + + let status = "NONE"; + let counter = 1; + while (counter < 20 && status !== "ACTIVE") { + // Redundant check with test timeout. + await wait(1); + const getDatastoreCommandOutput = await getDatastore(datastoreID); + status = getDatastoreCommandOutput["datastoreStatus"]; + counter++; + } + + const listDatastoresCommandOutput = await listDatastores(); + + let found = false; + for (const datastore of listDatastoresCommandOutput) { + if (datastore.datastoreId === datastoreID) { + // eslint-disable-line + found = true; + break; + } + } + + expect(found).toBe(true); + + // Delete topic. + await deleteDatastore(datastoreID); + }); +}, 20000); // 20 seconds test timeout. diff --git a/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js index 6f3b91c27a2..1d45062a76f 100644 --- a/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.unit.test.js @@ -3,49 +3,47 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {deleteImageSet} = await import("../actions/delete-image-set.js"); +const { deleteImageSet } = await import("../actions/delete-image-set.js"); describe("delete-image-set", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "6267bbd2-eaa5-4a50-8ee8-8fddf535cf73", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + datastoreId: "xxxxxxxxxxxxxxxx", + imageSetId: "xxxxxxxxxxxxxxx", + imageSetState: "LOCKED", + imageSetWorkflowStatus: "DELETING", + }; + + send.mockResolvedValueOnce(response); + + await deleteImageSet(datastoreId, imageSetID); - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetID = "12345678901234567890123456789012"; - - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: '6267bbd2-eaa5-4a50-8ee8-8fddf535cf73', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - datastoreId: 'xxxxxxxxxxxxxxxx', - imageSetId: 'xxxxxxxxxxxxxxx', - imageSetState: 'LOCKED', - imageSetWorkflowStatus: 'DELETING' - }; - - send.mockResolvedValueOnce(response); - - await deleteImageSet(datastoreId, imageSetID); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js index 060675fc78a..ad50758e822 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-datastore.integration.test.js @@ -3,18 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect} from "vitest"; -import {getDatastore} from "../actions/get-datastore.js"; +import { describe, it, expect } from "vitest"; +import { getDatastore } from "../actions/get-datastore.js"; describe("getDatastore", () => { - it("should throw an error with the default fake data store ID", async () => { - try { - await getDatastore(); - } catch (err) { - console.log(err.message); - expect(err.message).toEqual( - "1 validation error detected: Value 'DATASTORE_ID' at 'datastoreId' failed to satisfy constraint: Member must satisfy regular expression pattern: [0-9a-z]{32}", - ); - } - }); + it("should throw an error with the default fake data store ID", async () => { + try { + await getDatastore(); + } catch (err) { + console.log(err.message); + expect(err.message).toEqual( + "1 validation error detected: Value 'DATASTORE_ID' at 'datastoreId' failed to satisfy constraint: Member must satisfy regular expression pattern: [0-9a-z]{32}" + ); + } + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js index ca1f454b56f..3a25c2437d5 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js @@ -3,38 +3,40 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {getDICOMImportJob} = await import("../actions/get-dicom-import-job.js"); +const { getDICOMImportJob } = await import( + "../actions/get-dicom-import-job.js" +); describe("get-dicom-import-job", () => { - const jobId = "12345678901234567890123456789012"; - const datastoreId = "12345678901234567890123456789012"; - it("Should accept arguments and response", async () => { - const logSpy = vi.spyOn(console, "log"); - const response = { - jobId: jobId, - datastoreId: datastoreId, - jobStatus: 'TESTING', - submittedAt: '2019-01-01T00:00:00.000Z' - }; - - send.mockResolvedValueOnce(response); - - await getDICOMImportJob(datastoreId, jobId); - - expect(logSpy).toHaveBeenCalledWith(response) - }); + const jobId = "12345678901234567890123456789012"; + const datastoreId = "12345678901234567890123456789012"; + it("Should accept arguments and response", async () => { + const logSpy = vi.spyOn(console, "log"); + const response = { + jobId: jobId, + datastoreId: datastoreId, + jobStatus: "TESTING", + submittedAt: "2019-01-01T00:00:00.000Z", + }; + + send.mockResolvedValueOnce(response); + + await getDICOMImportJob(datastoreId, jobId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js index ed07b2eedee..cb0d103b211 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js @@ -3,60 +3,65 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; -import * as fs from 'fs'; +import { describe, it, expect, vi } from "vitest"; +import * as fs from "fs"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); class StreamMock { - constructor(dataArray) { - this.dataArray = dataArray; - } + constructor(dataArray) { + this.dataArray = dataArray; + } - transformToByteArray() { - return this.dataArray; - } + transformToByteArray() { + return this.dataArray; + } } -const {getImageFrame} = await import("../actions/get-image-frame.js"); +const { getImageFrame } = await import("../actions/get-image-frame.js"); describe("get-image-set-metadata", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; - const imageFrameID = "12345678901234567890123456789012"; - const metadataFileName = "med_image_frame_test.jph"; - - const response = { - metadata: { - httpStatusCode: 200, - requestId: '5219b274-30ff-4986-8cab-48753de3a599', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - contentType: 'text/plain', - imageFrameBlob: new StreamMock(new Uint8Array(256)) - }; - - send.mockResolvedValueOnce(response); - - await getImageFrame(metadataFileName, datastoreId, imageSetId, imageFrameID); - - expect(logSpy).toHaveBeenCalledWith(response); - expect(fs.existsSync(metadataFileName)).toBeTruthy(); - fs.unlinkSync(metadataFileName); - }); + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const imageFrameID = "12345678901234567890123456789012"; + const metadataFileName = "med_image_frame_test.jph"; + + const response = { + metadata: { + httpStatusCode: 200, + requestId: "5219b274-30ff-4986-8cab-48753de3a599", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + contentType: "text/plain", + imageFrameBlob: new StreamMock(new Uint8Array(256)), + }; + + send.mockResolvedValueOnce(response); + + await getImageFrame( + metadataFileName, + datastoreId, + imageSetId, + imageFrameID + ); + + expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js index 6ea2abb4bf1..6088675a377 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -3,90 +3,97 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; -import * as fs from 'fs'; +import { describe, it, expect, vi } from "vitest"; +import * as fs from "fs"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); class StreamMock { - constructor(dataArray) { - this.dataArray = dataArray; - } + constructor(dataArray) { + this.dataArray = dataArray; + } - transformToByteArray() { - return this.dataArray; - } + transformToByteArray() { + return this.dataArray; + } } -const {getImageSetMetadata} = await import("../actions/get-image-set-metadata.js"); +const { getImageSetMetadata } = await import( + "../actions/get-image-set-metadata.js" +); describe("get-image-set-metadata", () => { - it("should log the response without version", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; - const metadataFileName = "med_image_test.gzip"; - - const response = { - metadata: { - httpStatusCode: 200, - requestId: '5219b274-30ff-4986-8cab-48753de3a599', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - contentType: 'application/json', - contentEncoding: 'gzip', - imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) - }; - - send.mockResolvedValueOnce(response); - - await getImageSetMetadata(metadataFileName, datastoreId, imageSetId); - - expect(logSpy).toHaveBeenCalledWith(response); - expect(fs.existsSync(metadataFileName)).toBeTruthy(); - fs.unlinkSync(metadataFileName); - }); - - it("should log the response with version", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; - const metadataFileName = "med_image_test.gzip"; - const versionID = "1"; - - const response = { - metadata: { - httpStatusCode: 200, - requestId: '5219b274-30ff-4986-8cab-48753de3a599', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - contentType: 'application/json', - contentEncoding: 'gzip', - imageSetMetadataBlob: new StreamMock(new Uint8Array(256)) - }; - - send.mockResolvedValueOnce(response); - - await getImageSetMetadata(metadataFileName, datastoreId, imageSetId, versionID); - - expect(logSpy).toHaveBeenCalledWith(response); - expect(fs.existsSync(metadataFileName)).toBeTruthy(); - fs.unlinkSync(metadataFileName); - }); + it("should log the response without version", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const metadataFileName = "med_image_test.gzip"; + + const response = { + metadata: { + httpStatusCode: 200, + requestId: "5219b274-30ff-4986-8cab-48753de3a599", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + contentType: "application/json", + contentEncoding: "gzip", + imageSetMetadataBlob: new StreamMock(new Uint8Array(256)), + }; + + send.mockResolvedValueOnce(response); + + await getImageSetMetadata(metadataFileName, datastoreId, imageSetId); + + expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); + }); + + it("should log the response with version", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const metadataFileName = "med_image_test.gzip"; + const versionID = "1"; + + const response = { + metadata: { + httpStatusCode: 200, + requestId: "5219b274-30ff-4986-8cab-48753de3a599", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + contentType: "application/json", + contentEncoding: "gzip", + imageSetMetadataBlob: new StreamMock(new Uint8Array(256)), + }; + + send.mockResolvedValueOnce(response); + + await getImageSetMetadata( + metadataFileName, + datastoreId, + imageSetId, + versionID + ); + + expect(logSpy).toHaveBeenCalledWith(response); + expect(fs.existsSync(metadataFileName)).toBeTruthy(); + fs.unlinkSync(metadataFileName); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js index 23254d8cdc5..ca4e2f9e296 100644 --- a/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js @@ -3,67 +3,69 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {getImageSet} = await import("../actions/get-image-set.js"); +const { getImageSet } = await import("../actions/get-image-set.js"); describe("get-image-set", () => { - it("should log the response running without version ID", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; + it("should log the response running without version ID", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; - const response = { - createdAt: "2023-09-22T14:49:26.427Z", - datastoreId: datastoreId, - imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', - imageSetId: imageSetId, - imageSetState: 'ACTIVE', - imageSetWorkflowStatus: 'CREATED', - updatedAt: "2023-09-22T14:49:26.427Z", - versionId: '1' - }; + const response = { + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: datastoreId, + imageSetArn: + "arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx", + imageSetId: imageSetId, + imageSetState: "ACTIVE", + imageSetWorkflowStatus: "CREATED", + updatedAt: "2023-09-22T14:49:26.427Z", + versionId: "1", + }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); - await getImageSet(datastoreId, imageSetId); + await getImageSet(datastoreId, imageSetId); - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); - it("should log the response running with version ID", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; - const versionId = "1"; + it("should log the response running with version ID", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const versionId = "1"; - const response = { - createdAt: "2023-09-22T14:49:26.427Z", - datastoreId: datastoreId, - imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx', - imageSetId: imageSetId, - imageSetState: 'ACTIVE', - imageSetWorkflowStatus: 'CREATED', - updatedAt: "2023-09-22T14:49:26.427Z", - versionId: versionId - }; + const response = { + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: datastoreId, + imageSetArn: + "arn:aws:medical-imaging:us-east-1:xxxxxxxxxx:datastore/xxxxxxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxxx", + imageSetId: imageSetId, + imageSetState: "ACTIVE", + imageSetWorkflowStatus: "CREATED", + updatedAt: "2023-09-22T14:49:26.427Z", + versionId: versionId, + }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); - await getImageSet(datastoreId, imageSetId, versionId); + await getImageSet(datastoreId, imageSetId, versionId); - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js b/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js index 48d4f1b3d27..c997466b57e 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-datastores.integration.test.js @@ -1,9 +1,9 @@ -import {describe, it, expect} from "vitest"; -import {listDatastores} from "../actions/list-datastores.js"; +import { describe, it, expect } from "vitest"; +import { listDatastores } from "../actions/list-datastores.js"; describe("ListDatastores", () => { - it("should return a datastores property that is an array", async () => { - const response = await listDatastores(); - expect(response).toBeInstanceOf(Array); - }); + it("should return a datastores property that is an array", async () => { + const response = await listDatastores(); + expect(response).toBeInstanceOf(Array); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js index 43bad72ea22..5a4c524759f 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -3,46 +3,48 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const paginateListDICOMImportJobs = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - paginateListDICOMImportJobs, - } + return { + ...actual, + paginateListDICOMImportJobs, + }; }); -const {listDICOMImportJobs} = await import("../actions/list-dicom-import-jobs.js"); +const { listDICOMImportJobs } = await import( + "../actions/list-dicom-import-jobs.js" +); describe("list-dicom-import-job", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - - const response = { - jobSummaries: [ - { - dataAccessRoleArn: 'arn:aws:iam::xxxxxxxxxxxx:role/dicom_import', - datastoreId: datastoreId, - endedAt: '2023-09-22T14:49:51.351Z', - jobId: '12345678901234567890123456789012', - jobName: 'test-1', - jobStatus: 'COMPLETED', - submittedAt: '2023-09-22T14:48:45.767Z' - } - ] - }; - - paginateListDICOMImportJobs.mockImplementationOnce(async function* () { - yield response; - }); - - await listDICOMImportJobs(datastoreId); - - expect(logSpy).toHaveBeenCalledWith(response); + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + + const response = { + jobSummaries: [ + { + dataAccessRoleArn: "arn:aws:iam::xxxxxxxxxxxx:role/dicom_import", + datastoreId: datastoreId, + endedAt: "2023-09-22T14:49:51.351Z", + jobId: "12345678901234567890123456789012", + jobName: "test-1", + jobStatus: "COMPLETED", + submittedAt: "2023-09-22T14:48:45.767Z", + }, + ], + }; + + paginateListDICOMImportJobs.mockImplementationOnce(async function* () { + yield response; }); + + await listDICOMImportJobs(datastoreId); + + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js index a99dabf4fd6..e2ec8bf3c43 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js @@ -3,53 +3,55 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const paginateListImageSetVersions = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - paginateListImageSetVersions, - } + return { + ...actual, + paginateListImageSetVersions, + }; }); -const {listImageSetVersions} = await import("../actions/list-image-set-versions.js"); +const { listImageSetVersions } = await import( + "../actions/list-image-set-versions.js" +); describe("list-image-set-versions", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetID = "12345678901234567890123456789012"; - - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: '74590b37-a002-4827-83f2-3c590279c742', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - imageSetPropertiesList: [ - { - ImageSetWorkflowStatus: 'CREATED', - createdAt: "2023-09-22T14:49:26.427Z", - imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxx', - imageSetState: 'ACTIVE', - versionId: '1' - }] - }; - - paginateListImageSetVersions.mockImplementationOnce(async function* () { - yield response; - }); - - await listImageSetVersions(datastoreId, imageSetID); - - expect(logSpy).toHaveBeenCalledWith(response); + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetID = "12345678901234567890123456789012"; + + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "74590b37-a002-4827-83f2-3c590279c742", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + imageSetPropertiesList: [ + { + ImageSetWorkflowStatus: "CREATED", + createdAt: "2023-09-22T14:49:26.427Z", + imageSetId: "xxxxxxxxxxxxxxxxxxxxxxx", + imageSetState: "ACTIVE", + versionId: "1", + }, + ], + }; + + paginateListImageSetVersions.mockImplementationOnce(async function* () { + yield response; }); + + await listImageSetVersions(datastoreId, imageSetID); + + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js index 24441b1b118..18f6400d1d0 100644 --- a/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js @@ -3,45 +3,46 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {listTagsForResource} = await import("../actions/list-tags-for-resource.js"); +const { listTagsForResource } = await import( + "../actions/list-tags-for-resource.js" +); describe("list-tags-for-resource", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "008fc6d3-abec-4870-a155-20fa3631e645", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + tags: { Deployment: "Development" }, + }; + + send.mockResolvedValueOnce(response); + + await listTagsForResource(resourceArn); - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; - - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: '008fc6d3-abec-4870-a155-20fa3631e645', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - tags: {Deployment: 'Development'} - }; - - send.mockResolvedValueOnce(response); - - await listTagsForResource(resourceArn); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js index 18b193b3475..30ddbcc6677 100644 --- a/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js @@ -3,58 +3,61 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; -const send = vi.fn(); +const paginateSearchImageSets = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + + return { + ...actual, + paginateSearchImageSets, + }; }); -const {searchImageSets} = await import("../actions/search-image-sets.js"); +const { searchImageSets } = await import("../actions/search-image-sets.js"); describe("search-image-sets", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const filters = [{ - values: [ - {createdAt: new Date("1985-04-12T23:20:50.52Z")}, - {createdAt: new Date("2023-09-12T23:20:50.52Z")}, - ], - operator: "BETWEEN" - }]; - - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: 'f009ea9c-84ca-4749-b5b6-7164f00a5ada', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - imageSetsMetadataSummaries: [ - { - DICOMTags: [Object], - createdAt: "2023-09-19T16:59:40.551Z", - imageSetId: '7f75e1b5c0f40eac2b24cf712f485f50', - updatedAt: "2023-09-19T16:59:40.551Z", - version: 1 - }] - }; - - send.mockResolvedValueOnce(response); - - await searchImageSets(datastoreId, filters); - - expect(logSpy).toHaveBeenCalledWith(response); + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const filters = [ + { + values: [ + { createdAt: new Date("1985-04-12T23:20:50.52Z") }, + { createdAt: new Date("2023-09-12T23:20:50.52Z") }, + ], + operator: "BETWEEN", + }, + ]; + + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "f009ea9c-84ca-4749-b5b6-7164f00a5ada", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + imageSetsMetadataSummaries: [ + { + DICOMTags: [Object], + createdAt: "2023-09-19T16:59:40.551Z", + imageSetId: "7f75e1b5c0f40eac2b24cf712f485f50", + updatedAt: "2023-09-19T16:59:40.551Z", + version: 1, + }, + ], + }; + + paginateSearchImageSets.mockImplementationOnce(async function* () { + yield response; }); + + await searchImageSets(datastoreId, filters); + + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js index d18ef6c96af..05ef21f706e 100644 --- a/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js @@ -3,42 +3,46 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {startDicomImportJob} = await import("../actions/start-dicom-import-job.js"); +const { startDicomImportJob } = await import( + "../actions/start-dicom-import-job.js" +); describe("start-dicom-import-job", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - - const response = { - jobId: "12345678901234567890123456789012", - datastoreId: datastoreId, - jobStatus: 'CREATING', - submittedAt: '2019-01-01T00:00:00.000Z' - }; - - send.mockResolvedValueOnce(response); - - await startDicomImportJob("test-1", - datastoreId, - "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", - "s3://medical-imaging-dicom-input/dicom_input/", - "s3://medical-imaging-output/job_output/"); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + + const response = { + jobId: "12345678901234567890123456789012", + datastoreId: datastoreId, + jobStatus: "CREATING", + submittedAt: "2019-01-01T00:00:00.000Z", + }; + + send.mockResolvedValueOnce(response); + + await startDicomImportJob( + "test-1", + datastoreId, + "arn:aws:iam::xxxxxxxxxxxx:role/ImportJobDataAccessRole", + "s3://medical-imaging-dicom-input/dicom_input/", + "s3://medical-imaging-output/job_output/" + ); + + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js index a18b150cf6e..5dea842ded6 100644 --- a/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js @@ -3,47 +3,46 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {tagResource} = await import("../actions/tag-resource.js"); +const { tagResource } = await import("../actions/tag-resource.js"); describe("resource", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + const tags = { + Deployment: "Development", + }; + + const response = { + $metadata: { + httpStatusCode: 204, + requestId: "8a6de9a3-ec8e-47ef-8643-473518b19d45", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + }; + + send.mockResolvedValueOnce(response); + + await tagResource(resourceArn, tags); - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; - const tags = { - "Deployment": "Development" - } - - const response = - { - '$metadata': { - httpStatusCode: 204, - requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - } - }; - - send.mockResolvedValueOnce(response); - - await tagResource(resourceArn, tags); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js index 352a4b3dbc2..61e8516c0b3 100644 --- a/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js @@ -3,45 +3,44 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {untagResource} = await import("../actions/untag-resource.js"); +const { untagResource } = await import("../actions/untag-resource.js"); describe("untag-resource", () => { + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const resourceArn = + "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; + const keys = ["Deployment"]; + + const response = { + $metadata: { + httpStatusCode: 204, + requestId: "8a6de9a3-ec8e-47ef-8643-473518b19d45", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + }; + + send.mockResolvedValueOnce(response); + + await untagResource(resourceArn, keys); - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const resourceArn = "arn:aws:medical-imaging:us-east-1:123456789012:datastore/xxxxxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxx"; - const keys = ["Deployment"]; - - const response = - { - '$metadata': { - httpStatusCode: 204, - requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - } - }; - - send.mockResolvedValueOnce(response); - - await untagResource(resourceArn, keys); - - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); diff --git a/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js b/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js index cd9664c282d..b48203b63ca 100644 --- a/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js +++ b/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js @@ -3,67 +3,71 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {describe, it, expect, vi} from "vitest"; +import { describe, it, expect, vi } from "vitest"; const send = vi.fn(); vi.doMock("@aws-sdk/client-medical-imaging", async () => { - const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); - return { - ...actual, - MedicalImagingClient: class { - send = send; - }, - }; + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + return { + ...actual, + MedicalImagingClient: class { + send = send; + }, + }; }); -const {updateImageSetMetadata} = await import("../actions/update-image-set-metadata.js"); +const { updateImageSetMetadata } = await import( + "../actions/update-image-set-metadata.js" +); describe("update-image-set-metadata", () => { - it("should log the response", async () => { - const logSpy = vi.spyOn(console, "log"); - const datastoreId = "12345678901234567890123456789012"; - const imageSetId = "12345678901234567890123456789012"; - const versionID = "1"; - const updatableAttributes = - '{' + - ' "SchemaVersion": 1.1,' + - ' "Patient": {' + - ' "DICOM": {' + - ' "PatientName": "Garcia^Gloria"' + - ' }' + - ' }' + - '}'; + it("should log the response", async () => { + const logSpy = vi.spyOn(console, "log"); + const datastoreId = "12345678901234567890123456789012"; + const imageSetId = "12345678901234567890123456789012"; + const versionID = "1"; + const updatableAttributes = JSON.stringify({ + SchemaVersion: 1.1, + Patient: { + DICOM: { + PatientName: "Garcia^Gloria", + }, + }, + }); - const updateMetadata = { - "DICOMUpdates": { - "updatableAttributes": - new TextEncoder().encode(updatableAttributes) - } - }; - const response = - { - '$metadata': { - httpStatusCode: 200, - requestId: '7966e869-e311-4bff-92ec-56a61d3003ea', - extendedRequestId: undefined, - cfId: undefined, - attempts: 1, - totalRetryDelay: 0 - }, - createdAt: "2023-09-22T14:49:26.427Z", - datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - imageSetState: 'LOCKED', - imageSetWorkflowStatus: 'UPDATING', - latestVersionId: '4', - updatedAt: "2023-09-27T19:41:43.494Z" - }; + const updateMetadata = { + DICOMUpdates: { + updatableAttributes: new TextEncoder().encode(updatableAttributes), + }, + }; + const response = { + $metadata: { + httpStatusCode: 200, + requestId: "7966e869-e311-4bff-92ec-56a61d3003ea", + extendedRequestId: undefined, + cfId: undefined, + attempts: 1, + totalRetryDelay: 0, + }, + createdAt: "2023-09-22T14:49:26.427Z", + datastoreId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + imageSetId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + imageSetState: "LOCKED", + imageSetWorkflowStatus: "UPDATING", + latestVersionId: "4", + updatedAt: "2023-09-27T19:41:43.494Z", + }; - send.mockResolvedValueOnce(response); + send.mockResolvedValueOnce(response); - await updateImageSetMetadata(datastoreId, imageSetId, versionID, updateMetadata); + await updateImageSetMetadata( + datastoreId, + imageSetId, + versionID, + updateMetadata + ); - expect(logSpy).toHaveBeenCalledWith(response); - }); + expect(logSpy).toHaveBeenCalledWith(response); + }); }); From 77f9f53451ce5b1150df4fd36d3423a7eee9fc00 Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:20:41 -0400 Subject: [PATCH 31/31] Addressing linting error --- .../example_code/medical-imaging/actions/list-datastores.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js index 4ee4018b41f..1d75d1c80cb 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -18,6 +18,9 @@ export const listDatastores = async () => { const commandParams = {}; const paginator = paginateListDatastores(paginatorConfig, commandParams); + /** + * @type {import("@aws-sdk/client-medical-imaging").DatastoreSummary[]} + */ const datastoreSummaries = []; for await (const page of paginator) { // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`.