diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml index 1a973c606a5..91761a5bea6 100644 --- a/.doc_gen/metadata/medical-imaging_metadata.yaml +++ b/.doc_gen/metadata/medical-imaging_metadata.yaml @@ -1,4 +1,20 @@ # zexi 0.4.0 +medical-imaging_Hello: + title: Hello &AHI; + title_abbrev: Hello &AHI; + synopsis: get started using &AHI;. + category: Hello + languages: + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - 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 @@ -173,6 +189,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 +213,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 +237,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 +261,26 @@ 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: The utility function for searching image sets. + snippet_tags: + - medical-imaging.JavaScript.resource.searchImageSetV3 + - 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: @@ -237,6 +297,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 +321,20 @@ 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: Utility function to get image set metadata. + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3 + - description: Get image set metadata without version. + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withoutversion + - description: Get image set metadata with version. + snippet_tags: + - medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion services: medical-imaging: {GetImageSetMetadata} medical-imaging_GetImageFrame: @@ -269,6 +351,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 +375,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 +399,17 @@ 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 + - description: Encode the metadata. + snippet_tags: + - medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main services: medical-imaging: {UpdateImageSetMetadata} medical-imaging_CopyImageSet: @@ -317,6 +426,20 @@ 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: Utility function to copy an image set. + snippet_tags: + - medical-imaging.JavaScript.imageset.copyImageSetV3 + - 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. + snippet_tags: + - medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination services: medical-imaging: {CopyImageSet} medical-imaging_DeleteImageSet: @@ -333,6 +456,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 +480,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 +504,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 +528,75 @@ 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: tag a &AHI; data store. + category: Scenarios + languages: + JavaScript: + versions: + - sdk_version: 3 + github: javascriptv3/example_code/medical-imaging + excerpts: + - description: To tag a data store. + snippet_tags: + - 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.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.datastore.untag.V3 + - description: The utility function for untagging a resource. + snippet_tags: + - 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/README.md b/javascriptv3/example_code/medical-imaging/README.md index cd08216892d..4f41eab44b5 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) @@ -13,7 +13,7 @@ _HealthImaging is a HIPAA-eligible service that helps health care providers and ## ⚠ 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). @@ -30,14 +30,40 @@ 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. +- [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) +- [Tagging an image set](scenarios/tagging-imagesets.js) ## Run the examples @@ -62,6 +88,34 @@ node ./scenarios/ +#### Hello HealthImaging + +This example shows you how to get started using HealthImaging. + +```bash +node ./hello.js +``` + +#### Tagging a data store + +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/copy-image-set.js b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js new file mode 100644 index 00000000000..0bda8f1ac7d --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/copy-image-set.js @@ -0,0 +1,104 @@ +/* + * 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 = "" +) => { + const 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 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.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.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 cda1c53e268..a4a621b953f 100644 --- a/javascriptv3/example_code/medical-imaging/actions/create-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/create-datastore.js @@ -14,7 +14,7 @@ import { medicalImagingClient } from "../libs/medicalImagingClient.js"; */ export const createDatastore = async (datastoreName = "DATASTORE_NAME") => { const response = await medicalImagingClient.send( - new CreateDatastoreCommand({ datastoreName: datastoreName }), + new CreateDatastoreCommand({ datastoreName: datastoreName }) ); console.log(response); // { @@ -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("test-result"); + 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 7fa10820aa5..f33543713c5 100644 --- a/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/delete-datastore.js @@ -10,11 +10,11 @@ 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") => { +export const deleteDatastore = async (datastoreId = "DATASTORE_ID") => { const response = await medicalImagingClient.send( - new DeleteDatastoreCommand({ datastoreId: datastoreID }), + new DeleteDatastoreCommand({ datastoreId }) ); console.log(response); // { @@ -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)) { - 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 new file mode 100644 index 00000000000..64123790ba6 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/delete-image-set.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.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 the following code if this file is being run directly. +if (process.argv[1] === fileURLToPath(import.meta.url)) { + 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 f2586ae1dde..9b480fa29c7 100644 --- a/javascriptv3/example_code/medical-imaging/actions/get-datastore.js +++ b/javascriptv3/example_code/medical-imaging/actions/get-datastore.js @@ -10,11 +10,11 @@ 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( - new GetDatastoreCommand({ datastoreId: datastoreID }), + new GetDatastoreCommand({ datastoreId: datastoreID }) ); console.log(response); // { @@ -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', @@ -36,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. +// Invoke the following code if this file is being 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 new file mode 100644 index 00000000000..6bcc326c4f8 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-dicom-import-job.js @@ -0,0 +1,53 @@ +/* + * 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.dicom.getDICOMImportJobV3] +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 + // } + // } + + 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(); +} 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..20b155bcae8 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-frame.js @@ -0,0 +1,60 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +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"; + +/** + * @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. + */ +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; +}; +// 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" + ); +} 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..bd41dcd42ed --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set-metadata.js @@ -0,0 +1,83 @@ +/* + * 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.getImageSetMetadataV3] +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. + * @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. + */ +export const getImageSetMetadata = async ( + metadataFileName = "metadata.json.gzip", + datastoreId = "xxxxxxxxxxxxxx", + imagesetId = "xxxxxxxxxxxxxx", + versionID = "" +) => { + const params = { datastoreId: datastoreId, imageSetId: imagesetId }; + + if (versionID) { + params.versionID = versionID; + } + + 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 {} + // } + + 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.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 new file mode 100644 index 00000000000..d5e9e0938c5 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/get-image-set.js @@ -0,0 +1,58 @@ +/* + * 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.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.imageset.getImageSetV3] + +// 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 f312ce5f20f..1d75d1c80cb 100644 --- a/javascriptv3/example_code/medical-imaging/actions/list-datastores.js +++ b/javascriptv3/example_code/medical-imaging/actions/list-datastores.js @@ -18,10 +18,13 @@ 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) { - // page contains a single paginated output. - datastoreSummaries.push(...page.datastoreSummaries); + // Each page contains a list of `jobSummaries`. The list is truncated if is larger than `pageSize`. + datastoreSummaries.push(...page["datastoreSummaries"]); console.log(page); } // { @@ -50,7 +53,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)) { - 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 new file mode 100644 index 00000000000..a4720bcc7aa --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-dicom-import-jobs.js @@ -0,0 +1,60 @@ +/* + * 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.dicom.listDICOMImportJobsV3] +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, + }; + + const commandParams = { datastoreId: datastoreId }; + const paginator = paginateListDICOMImportJobs(paginatorConfig, commandParams); + + 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; +}; +// 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(); +} 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..83c4f8210f1 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-image-set-versions.js @@ -0,0 +1,62 @@ +/* + * 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.listImageSetVersionsV3] +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, + }; + + const commandParams = { datastoreId, imageSetId }; + const paginator = paginateListImageSetVersions( + paginatorConfig, + commandParams + ); + + 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(); +} 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..8aa26777825 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/list-tags-for-resource.js @@ -0,0 +1,43 @@ +/* + * 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 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: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 new file mode 100644 index 00000000000..9fbe934cb31 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/search-image-sets.js @@ -0,0 +1,131 @@ +/* + * 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 { paginateSearchImageSets } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; + +/** + * @param {string} datastoreId - The data store's ID. + * @param { import('@aws-sdk/client-medical-imaging').SearchFilter[] } filters - The search criteria filters. + */ +export const searchImageSets = async ( + datastoreId = "xxxxxxxx", + filters = [] +) => { + const paginatorConfig = { + client: medicalImagingClient, + pageSize: 50, + }; + + 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", + }, + ]; + + 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] +} 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..62178c90671 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/start-dicom-import-job.js @@ -0,0 +1,57 @@ +/* + * 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.dicom.startDicomImportJobV3] +import { StartDICOMImportJobCommand } from "@aws-sdk/client-medical-imaging"; +import { medicalImagingClient } from "../libs/medicalImagingClient.js"; + +/** + * @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. + * @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.dicom.startDicomImportJobV3] + +// 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 new file mode 100644 index 00000000000..b3bb4369509 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/tag-resource.js @@ -0,0 +1,46 @@ +/* + * 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 {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 + // } + // } + + 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" } + ); +} 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..f4f5897bb15 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/untag-resource.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"; + +// 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 {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 + // } + // } + + 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"] + ); +} 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..46696c5acd7 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/actions/update-image-set-metadata.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.datastore.updateImageSetMetadataV3] +import {UpdateImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; +import {medicalImagingClient} from "../libs/medicalImagingClient.js"; + +/** + * @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. + */ +export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", + imageSetId = "xxxxxxxxxx", + latestVersionId = "1", + updateMetadata = '{}') => { + const response = await medicalImagingClient.send( + new UpdateImageSetMetadataCommand({ + datastoreId: datastoreId, + imageSetId: imageSetId, + latestVersionId: latestVersionId, + updateImageSetMetadataUpdates: updateMetadata + }) + ); + console.log(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 + // } + return response; +}; +// 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 = +JSON.stringify({ + "SchemaVersion": 1.1, + "Patient": { + "DICOM": { + "PatientName": "Garcia^Gloria" + } + } +}) + + const updateMetadata = { + "DICOMUpdates": { + "updatableAttributes": + new TextEncoder().encode(updatableAttributes) + } + }; + + await updateImageSetMetadata("12345678901234567890123456789012", "12345678901234567890123456789012", + "1", updateMetadata); +// snippet-end:[medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main] +} + diff --git a/javascriptv3/example_code/medical-imaging/hello.js b/javascriptv3/example_code/medical-imaging/hello.js new file mode 100644 index 00000000000..6669ac4b0e4 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/hello.js @@ -0,0 +1,31 @@ +/* + * 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 new file mode 100644 index 00000000000..e211d06e4cf --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-datastores.js @@ -0,0 +1,53 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * 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] + +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.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] +} 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..ac4ad4c5f56 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/scenarios/tagging-imagesets.js @@ -0,0 +1,49 @@ +/* + * 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 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] +} 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..2fe10b135b6 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/copy-image-set.unit.test.js @@ -0,0 +1,88 @@ +/* + * 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..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 = "createDeleteDatastoreJSTest"; - - 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 new file mode 100644 index 00000000000..1d45062a76f --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/delete-image-set.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 { 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 cda2ea817e6..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 @@ -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"; @@ -8,7 +13,7 @@ describe("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}", + "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 new file mode 100644 index 00000000000..3a25c2437d5 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-dicom-import-job.unit.test.js @@ -0,0 +1,42 @@ +/* + * 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 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 new file mode 100644 index 00000000000..cb0d103b211 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-frame.unit.test.js @@ -0,0 +1,67 @@ +/* + * 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( + 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 new file mode 100644 index 00000000000..6088675a377 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set-metadata.unit.test.js @@ -0,0 +1,99 @@ +/* + * 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 { 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); + }); +}); 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..ca4e2f9e296 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/get-image-set.unit.test.js @@ -0,0 +1,71 @@ +/* + * 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..5a4c524759f --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-dicom-import-jobs.unit.test.js @@ -0,0 +1,50 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +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"); + + return { + ...actual, + paginateListDICOMImportJobs, + }; +}); + +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); + }); +}); 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..e2ec8bf3c43 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-image-set-versions.unit.test.js @@ -0,0 +1,57 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +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"); + + return { + ...actual, + paginateListImageSetVersions, + }; +}); + +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); + }); +}); 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..18f6400d1d0 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/list-tags-for-resource.unit.test.js @@ -0,0 +1,48 @@ +/* + * 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..30ddbcc6677 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/search-image-set.unit.test.js @@ -0,0 +1,63 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from "vitest"; + +const paginateSearchImageSets = vi.fn(); + +vi.doMock("@aws-sdk/client-medical-imaging", async () => { + const actual = await vi.importActual("@aws-sdk/client-medical-imaging"); + + return { + ...actual, + paginateSearchImageSets, + }; +}); + +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, + }, + ], + }; + + 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 new file mode 100644 index 00000000000..05ef21f706e --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/start-dicom-import-job.unit.test.js @@ -0,0 +1,48 @@ +/* + * 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 { 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); + }); +}); 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..5dea842ded6 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/tag-resource.unit.test.js @@ -0,0 +1,48 @@ +/* + * 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..61e8516c0b3 --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/untag-resource.unit.test.js @@ -0,0 +1,46 @@ +/* + * 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..b48203b63ca --- /dev/null +++ b/javascriptv3/example_code/medical-imaging/tests/update-image-set-metadata.unit.test.js @@ -0,0 +1,73 @@ +/* + * 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 = 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", + }; + + send.mockResolvedValueOnce(response); + + await updateImageSetMetadata( + datastoreId, + imageSetId, + versionID, + updateMetadata + ); + + expect(logSpy).toHaveBeenCalledWith(response); + }); +});