diff --git a/.doc_gen/metadata/medical-imaging_metadata.yaml b/.doc_gen/metadata/medical-imaging_metadata.yaml
index 91761a5bea6..26300dacfd8 100644
--- a/.doc_gen/metadata/medical-imaging_metadata.yaml
+++ b/.doc_gen/metadata/medical-imaging_metadata.yaml
@@ -43,7 +43,8 @@ medical-imaging_CreateDatastore:
- sdk_version: 2
github: javav2/example_code/medicalimaging
excerpts:
- - snippet_tags:
+ - description:
+ snippet_tags:
- medicalimaging.java2.create_datastore.main
JavaScript:
versions:
@@ -123,7 +124,8 @@ medical-imaging_ListDatastores:
- sdk_version: 2
github: javav2/example_code/medicalimaging
excerpts:
- - snippet_tags:
+ - description:
+ snippet_tags:
- medicalimaging.java2.list_datastores.main
JavaScript:
versions:
@@ -163,7 +165,8 @@ medical-imaging_GetDatastore:
- sdk_version: 2
github: javav2/example_code/medicalimaging
excerpts:
- - snippet_tags:
+ - description:
+ snippet_tags:
- medicalimaging.java2.get_datastore.main
JavaScript:
versions:
@@ -197,6 +200,14 @@ medical-imaging_StartDICOMImportJob:
- description:
snippet_tags:
- medical-imaging.JavaScript.dicom.startDicomImportJobV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.start_dicom_import_job.main
services:
medical-imaging: {StartDICOMImportJob}
medical-imaging_GetDICOMImportJob:
@@ -221,6 +232,14 @@ medical-imaging_GetDICOMImportJob:
- description:
snippet_tags:
- medical-imaging.JavaScript.dicom.getDICOMImportJobV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.get_dicom_import_job.main
services:
medical-imaging: {GetDICOMImportJob}
medical-imaging_ListDICOMImportJobs:
@@ -245,6 +264,14 @@ medical-imaging_ListDICOMImportJobs:
- description:
snippet_tags:
- medical-imaging.JavaScript.dicom.listDICOMImportJobsV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.list_dicom_import_jobs.main
services:
medical-imaging: {ListDICOMImportJobs}
medical-imaging_SearchImageSets:
@@ -281,6 +308,23 @@ medical-imaging_SearchImageSets:
snippet_tags:
- medical-imaging.JavaScript.resource.searchImageSetV3.datastoreID
- medical-imaging.JavaScript.resource.searchImageSetV3.betweenFilter2
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description: The utility function for searching image sets.
+ snippet_tags:
+ - medicalimaging.java2.search_imagesets.main
+ - description: "Use case #1: EQUAL operator."
+ snippet_tags:
+ - medicalimaging.java2.search_imagesets.use_case1
+ - description: "Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime."
+ snippet_tags:
+ - medicalimaging.java2.search_imagesets.use_case2
+ - description: "Use case #3: BETWEEN operator using createdAt. Time studies were previously persisted."
+ snippet_tags:
+ - medicalimaging.java2.search_imagesets.use_case3
services:
medical-imaging: {SearchImageSets}
medical-imaging_GetImageSet:
@@ -305,6 +349,14 @@ medical-imaging_GetImageSet:
- description:
snippet_tags:
- medical-imaging.JavaScript.imageset.getImageSetV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.get_imageset.main
services:
medical-imaging: {GetImageSet}
medical-imaging_GetImageSetMetadata:
@@ -335,6 +387,14 @@ medical-imaging_GetImageSetMetadata:
- description: Get image set metadata with version.
snippet_tags:
- medical-imaging.JavaScript.imageset.getImageSetMetadataV3.withversion
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.get_imageset.main
services:
medical-imaging: {GetImageSetMetadata}
medical-imaging_GetImageFrame:
@@ -359,6 +419,14 @@ medical-imaging_GetImageFrame:
- description:
snippet_tags:
- medical-imaging.JavaScript.imageset.getImageFrameV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.get_image_frame.main
services:
medical-imaging: {GetImageFrame}
medical-imaging_ListImageSetVersions:
@@ -383,6 +451,14 @@ medical-imaging_ListImageSetVersions:
- description:
snippet_tags:
- medical-imaging.JavaScript.imageset.listImageSetVersionsV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.list_imageset_versions.main
services:
medical-imaging: {ListImageSetVersions}
medical-imaging_UpdateImageSetMetadata:
@@ -410,6 +486,14 @@ medical-imaging_UpdateImageSetMetadata:
- description: Encode the metadata.
snippet_tags:
- medical-imaging.JavaScript.datastore.updateImageSetMetadataV3.main
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.update_image_set_metadata.main
services:
medical-imaging: {UpdateImageSetMetadata}
medical-imaging_CopyImageSet:
@@ -440,6 +524,14 @@ medical-imaging_CopyImageSet:
- description: Copy an image set with a destination.
snippet_tags:
- medical-imaging.JavaScript.imageset.copyImageSetV3.with_destination
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.copy_imageset.main
services:
medical-imaging: {CopyImageSet}
medical-imaging_DeleteImageSet:
@@ -464,6 +556,14 @@ medical-imaging_DeleteImageSet:
- description:
snippet_tags:
- medical-imaging.JavaScript.imageset.deleteImageSetV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.delete_imageset.main
services:
medical-imaging: {DeleteImageSet}
medical-imaging_TagResource:
@@ -488,6 +588,14 @@ medical-imaging_TagResource:
- description:
snippet_tags:
- medical-imaging.JavaScript.resource.tagResourceV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.tag_resource.main
services:
medical-imaging: {TagResource}
medical-imaging_UntagResource:
@@ -512,6 +620,14 @@ medical-imaging_UntagResource:
- description:
snippet_tags:
- medical-imaging.JavaScript.resource.unTagResourceV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.untag_resource.main
services:
medical-imaging: {UntagResource}
medical-imaging_ListTagsForResource:
@@ -536,6 +652,14 @@ medical-imaging_ListTagsForResource:
- description:
snippet_tags:
- medical-imaging.JavaScript.resource.listTagsForResourceV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description:
+ snippet_tags:
+ - medicalimaging.java2.list_tags_for_resource.main
services:
medical-imaging: {ListTagsForResource}
medical-imaging_tagging_datastores:
@@ -567,6 +691,32 @@ medical-imaging_tagging_datastores:
- description: The utility function for untagging a resource.
snippet_tags:
- medical-imaging.JavaScript.resource.unTagResourceV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description: To tag a data store.
+ snippet_tags:
+ - medicalimaging.java2.tagging_datastores.datastore_arn
+ - medicalimaging.java2.tagging_datastores.tag
+ - description: The utility function for tagging a resource.
+ snippet_tags:
+ - medicalimaging.java2.tag_resource.main
+ - description: To list tags for a data store.
+ snippet_tags:
+ - medicalimaging.java2.tagging_datastores.datastore_arn
+ - medicalimaging.java2.tagging_datastores.list
+ - description: The utility function for listing a resource's tags.
+ snippet_tags:
+ - medicalimaging.java2.list_tags_for_resource.main
+ - description: To untag a data store.
+ snippet_tags:
+ - medicalimaging.java2.tagging_datastores.datastore_arn
+ - medicalimaging.java2.tagging_datastores.untag
+ - description: The utility function for untagging a resource.
+ snippet_tags:
+ - medicalimaging.java2.untag_resource.main
services:
medical-imaging: {TagResource, UntagResource, ListTagsForResource}
medical-imaging_tagging_imagesets:
@@ -598,5 +748,31 @@ medical-imaging_tagging_imagesets:
- description: The utility function for untagging a resource.
snippet_tags:
- medical-imaging.JavaScript.resource.unTagResourceV3
+ Java:
+ versions:
+ - sdk_version: 2
+ github: javav2/example_code/medicalimaging
+ excerpts:
+ - description: To tag an image set.
+ snippet_tags:
+ - medicalimaging.java2.tagging_imagesets.datastore_arn
+ - medicalimaging.java2.tagging_imagesets.tag
+ - description: The utility function for tagging a resource.
+ snippet_tags:
+ - medicalimaging.java2.tag_resource.main
+ - description: To list tags for an image set.
+ snippet_tags:
+ - medicalimaging.java2.tagging_imagesets.datastore_arn
+ - medicalimaging.java2.tagging_imagesets.list
+ - description: The utility function for listing a resource's tags.
+ snippet_tags:
+ - medicalimaging.java2.list_tags_for_resource.main
+ - description: To untag an image set.
+ snippet_tags:
+ - medicalimaging.java2.tagging_imagesets.datastore_arn
+ - medicalimaging.java2.tagging_imagesets.untag
+ - description: The utility function for untagging a resource.
+ snippet_tags:
+ - medicalimaging.java2.untag_resource.main
services:
medical-imaging: {TagResource, UntagResource, ListTagsForResource}
diff --git a/.doc_gen/readmes/config.py b/.doc_gen/readmes/config.py
index f99f35129b1..a5ee23e17a7 100644
--- a/.doc_gen/readmes/config.py
+++ b/.doc_gen/readmes/config.py
@@ -43,6 +43,9 @@
'base_folder': 'javav2',
'service_folder': 'javav2/example_code/{{service["name"]}}',
'sdk_api_ref': 'https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/{{service["name"]}}/package-summary.html',
+ 'service_folder_overrides': {
+ 'medical-imaging': 'javav2/example_code/medicalimaging',
+ }
}
},
'JavaScript': {
diff --git a/javav2/example_code/medicalimaging/README.md b/javav2/example_code/medicalimaging/README.md
index 4d4e89086e2..7ad79d8e25f 100644
--- a/javav2/example_code/medicalimaging/README.md
+++ b/javav2/example_code/medicalimaging/README.md
@@ -1,4 +1,4 @@
-
+
# HealthImaging code examples for the SDK for Java 2.x
## Overview
@@ -12,7 +12,7 @@ Shows how to use the AWS SDK for Java 2.x 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,32 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav
Code excerpts that show you how to call individual service functions.
-* [Create a data store](src/main/java/com/example/medicalimaging/CreateDatastore.java#L56) (`CreateDatastore`)
-* [Delete a data store](src/main/java/com/example/medicalimaging/DeleteDatastore.java#L54) (`DeleteDatastore`)
-* [Get data store properties](rc/main/java/com/example/medicalimaging/GetDatastore.java#L59) (`GetDatastore`)
-* [List data stores](src/main/java/com/example/medicalimaging/ListDatastores.java#L45) (`ListDatastores`)
+* [Add a tag to a resource](src/main/java/com/example/medicalimaging/TagResource.java#L60) (`TagResource`)
+* [Copy an image set](src/main/java/com/example/medicalimaging/CopyImageSet.java#L70) (`CopyImageSet`)
+* [Create a data store](src/main/java/com/example/medicalimaging/CreateDatastore.java#L57) (`CreateDatastore`)
+* [Delete a data store](src/main/java/com/example/medicalimaging/DeleteDatastore.java#L55) (`DeleteDatastore`)
+* [Delete an image set](src/main/java/com/example/medicalimaging/DeleteImageSet.java#L58) (`DeleteImageSet`)
+* [Get an image frame](src/main/java/com/example/medicalimaging/GetImageFrame.java#L67) (`GetImageFrame`)
+* [Get data store properties](src/main/java/com/example/medicalimaging/GetDatastore.java#L60) (`GetDatastore`)
+* [Get image set properties](src/main/java/com/example/medicalimaging/GetImageSet.java#L68) (`GetImageSet`)
+* [Get import job properties](src/main/java/com/example/medicalimaging/GetDicomImportJob.java#L84) (`GetDICOMImportJob`)
+* [Get metadata for an image set](src/main/java/com/example/medicalimaging/GetImageSet.java#L68) (`GetImageSetMetadata`)
+* [Import bulk data into a data store](src/main/java/com/example/medicalimaging/StartDicomImportJob.java#L67) (`StartDICOMImportJob`)
+* [List data stores](src/main/java/com/example/medicalimaging/ListDatastores.java#L51) (`ListDatastores`)
+* [List image set versions](src/main/java/com/example/medicalimaging/ListImageSetVersions.java#L66) (`ListImageSetVersions`)
+* [List import jobs for a data store](src/main/java/com/example/medicalimaging/ListDicomImportJobs.java#L63) (`ListDICOMImportJobs`)
+* [List tags for a resource](src/main/java/com/example/medicalimaging/ListTagsForResource.java#L61) (`ListTagsForResource`)
+* [Remove a tag from a resource](src/main/java/com/example/medicalimaging/UntagResource.java#L60) (`UntagResource`)
+* [Search image sets](src/main/java/com/example/medicalimaging/SearchImageSets.java#L128) (`SearchImageSets`)
+* [Update image set metadata](src/main/java/com/example/medicalimaging/UpdateImageSetMetadata.java#L78) (`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](src/main/java/com/example/medicalimaging/TaggingDatastores.java)
+* [Tagging an image set](src/main/java/com/example/medicalimaging/TaggingImageSets.java)
## Run the examples
@@ -49,6 +71,30 @@ Code excerpts that show you how to call individual service functions.
+#### 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/javav2/example_code/medicalimaging/pom.xml b/javav2/example_code/medicalimaging/pom.xml
index f7484f9ed62..9863fa14f02 100644
--- a/javav2/example_code/medicalimaging/pom.xml
+++ b/javav2/example_code/medicalimaging/pom.xml
@@ -50,6 +50,10 @@
5.9.2
test
+
+ software.amazon.awssdk
+ secretsmanager
+
com.google.code.gson
gson
@@ -78,10 +82,13 @@
2.0.7
test
-
software.amazon.awssdk
medicalimaging
+
+ software.amazon.awssdk
+ s3
+
\ No newline at end of file
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/CopyImageSet.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/CopyImageSet.java
new file mode 100644
index 00000000000..32e032a2756
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/CopyImageSet.java
@@ -0,0 +1,110 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to copy an image set.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.copy_imageset.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.*;
+
+//snippet-end:[medicalimaging.java2.copy_imageset.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class CopyImageSet {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imageSetId - The ID of the image set.\n" +
+ " latestVersionId - The latest version ID of the image set.\n" +
+ " destinationImageSetId - The optional destination image set ID.\n" +
+ " destinationVersionId - The optional destination version ID.\n";
+
+ if ((args.length != 3) && (args.length != 5)) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String imageSetId = args[1];
+ String versionId = args[2];
+ String destinationImageSetId = null;
+ String destinationVersionId = null;
+
+ if (args.length == 5) {
+ destinationImageSetId = args[3];
+ destinationVersionId = args[4];
+ }
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ String copiedImageSetId = copyMedicalImageSet(medicalImagingClient, datastoreId, imageSetId,
+ versionId, destinationImageSetId, destinationVersionId);
+
+ System.out.println("The copied image set ID is " + copiedImageSetId);
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.copy_imageset.main]
+ public static String copyMedicalImageSet(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String imageSetId,
+ String latestVersionId,
+ String destinationImageSetId,
+ String destinationVersionId) {
+
+ try {
+ CopySourceImageSetInformation copySourceImageSetInformation = CopySourceImageSetInformation.builder()
+ .latestVersionId(latestVersionId)
+ .build();
+
+ CopyImageSetInformation.Builder copyImageSetBuilder = CopyImageSetInformation.builder()
+ .sourceImageSet(copySourceImageSetInformation);
+
+ if (destinationImageSetId != null) {
+ copyImageSetBuilder = copyImageSetBuilder.destinationImageSet(CopyDestinationImageSet.builder()
+ .imageSetId(destinationImageSetId)
+ .latestVersionId(destinationVersionId)
+ .build());
+ }
+
+ CopyImageSetRequest copyImageSetRequest = CopyImageSetRequest.builder()
+ .datastoreId(datastoreId)
+ .sourceImageSetId(imageSetId)
+ .copyImageSetInformation(copyImageSetBuilder.build())
+ .build();
+
+ CopyImageSetResponse response = medicalImagingClient.copyImageSet(copyImageSetRequest);
+
+ return response.destinationImageSetProperties().imageSetId();
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return "";
+ }
+//snippet-end:[medicalimaging.java2.copy_imageset.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/DeleteImageSet.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/DeleteImageSet.java
new file mode 100644
index 00000000000..1c0fa9b78dd
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/DeleteImageSet.java
@@ -0,0 +1,77 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to delete an image set.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.delete_imageset.import]
+
+//snippet-end:[medicalimaging.java2.delete_imageset.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.DeleteImageSetRequest;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class DeleteImageSet {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n";
+
+ if (args.length != 2) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String imagesetId = args[1];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ deleteMedicalImageSet(medicalImagingClient, datastoreId, imagesetId);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.delete_imageset.main]
+ public static void deleteMedicalImageSet(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String imagesetId) {
+ try {
+ DeleteImageSetRequest deleteImageSetRequest = DeleteImageSetRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId)
+ .build();
+
+ medicalImagingClient.deleteImageSet(deleteImageSetRequest);
+
+ System.out.println("The image set was deleted.");
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.delete_imageset.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetDicomImportJob.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetDicomImportJob.java
new file mode 100644
index 00000000000..a488c100a92
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetDicomImportJob.java
@@ -0,0 +1,136 @@
+//snippet-sourcedescription:[StartDicomImportJob.java demonstrates how to get an import job's properties.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.get_dicom_import_job.import]
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.core.ResponseBytes;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.DICOMImportJobProperties;
+import software.amazon.awssdk.services.medicalimaging.model.GetDicomImportJobRequest;
+import software.amazon.awssdk.services.medicalimaging.model.GetDicomImportJobResponse;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.S3Uri;
+import software.amazon.awssdk.services.s3.S3Utilities;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectResponse;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+//snippet-end:[medicalimaging.java2.get_dicom_import_job.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class GetDicomImportJob {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " < \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " jobId - The ID of the job.\n";
+
+ if (args.length != 2) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String jobId = args[1];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ DICOMImportJobProperties importJobProperties = getDicomImportJob(medicalImagingClient, datastoreId, jobId);
+
+ System.out.println("The job properties are " + importJobProperties);
+
+ S3Client s3Client = S3Client.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ List imagesets = getImageSetsForImportJobProperties(s3Client, importJobProperties);
+
+ System.out.println("The imported imagesets are " + imagesets);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.get_dicom_import_job.main]
+ public static DICOMImportJobProperties getDicomImportJob(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String jobId) {
+
+ try {
+ GetDicomImportJobRequest getDicomImportJobRequest = GetDicomImportJobRequest.builder()
+ .datastoreId(datastoreId)
+ .jobId(jobId)
+ .build();
+ GetDicomImportJobResponse response = medicalImagingClient.getDICOMImportJob(getDicomImportJobRequest);
+ return response.jobProperties();
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+//snippet-end:[medicalimaging.java2.get_dicom_import_job.main]
+
+ public static List getImageSetsForImportJobProperties(S3Client s3client,
+ DICOMImportJobProperties jobProperties) {
+ try {
+ S3Utilities s3Utilities = s3client.utilities();
+ URI manifestUri = URI.create(jobProperties.outputS3Uri() + "job-output-manifest.json");
+ S3Uri manifestS3Uri = s3Utilities.parseUri(manifestUri);
+
+ System.out.println("bucket " + manifestS3Uri.bucket().orElse("not found") +
+ ", key " + manifestS3Uri.key().orElse("not found"));
+ GetObjectRequest getObjectRequest = GetObjectRequest.builder()
+ .bucket(manifestS3Uri.bucket().get())
+ .key(manifestS3Uri.key().get())
+ .build();
+
+ ResponseBytes objectBytes = s3client.getObjectAsBytes(getObjectRequest);
+ String manifest = objectBytes.asUtf8String();
+ JsonObject jsonObject = JsonParser.parseString(manifest).getAsJsonObject();
+ JsonObject jobSummary = jsonObject.getAsJsonObject("jobSummary");
+ List result = new ArrayList<>();
+ for (JsonElement imageSetSummary : jobSummary.getAsJsonArray("imageSetsSummary")) {
+ result.add(imageSetSummary.getAsJsonObject().get("imageSetId").getAsString());
+ }
+
+ return result;
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageFrame.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageFrame.java
new file mode 100644
index 00000000000..eafa2e92e3f
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageFrame.java
@@ -0,0 +1,92 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to retrieve an image set image frame.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.get_image_frame.import]
+
+//snippet-end:[medicalimaging.java2.get_image_frame.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.GetImageFrameRequest;
+import software.amazon.awssdk.services.medicalimaging.model.ImageFrameInformation;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+import java.nio.file.FileSystems;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class GetImageFrame {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " destinationPath - The destination path for the downloaded file.\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n" +
+ " imageFrameId - The ID of the image frame.\n";
+
+
+ if (args.length != 4) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String destinationPath = args[0];
+ String datastoreId = args[1];
+ String imagesetId = args[2];
+ String imageFrameId = args[3];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ getMedicalImageSetFrame(medicalImagingClient, destinationPath,
+ datastoreId, imagesetId, imageFrameId);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.get_image_frame.main]
+ public static void getMedicalImageSetFrame(MedicalImagingClient medicalImagingClient,
+ String destinationPath,
+ String datastoreId,
+ String imagesetId,
+ String imageFrameId) {
+
+ try {
+ GetImageFrameRequest getImageSetMetadataRequest = GetImageFrameRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId)
+ .imageFrameInformation(ImageFrameInformation.builder()
+ .imageFrameId(imageFrameId)
+ .build())
+ .build();
+ medicalImagingClient.getImageFrame(getImageSetMetadataRequest,
+ FileSystems.getDefault().getPath(destinationPath));
+
+ System.out.println("Image frame downloaded to " + destinationPath);
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.get_image_frame.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSet.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSet.java
new file mode 100644
index 00000000000..f2a726d7518
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSet.java
@@ -0,0 +1,91 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to retrieve information about an image set.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.get_imageset.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.GetImageSetRequest;
+import software.amazon.awssdk.services.medicalimaging.model.GetImageSetResponse;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+//snippet-end:[medicalimaging.java2.get_imageset.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class GetImageSet {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n" +
+ " versionId - The optional version ID of the image set.\n";
+
+ if ((args.length != 2) && (args.length != 3)) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String imagesetId = args[1];
+ String versionid = null;
+ if (args.length == 3) {
+ versionid = args[2];
+ }
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ GetImageSetResponse getImageSetResponse = getMedicalImageSet(medicalImagingClient, datastoreId, imagesetId,
+ versionid);
+
+
+ System.out.println("The get image response is " + getImageSetResponse);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.get_imageset.main]
+ public static GetImageSetResponse getMedicalImageSet(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String imagesetId,
+ String versionId) {
+ try {
+ GetImageSetRequest.Builder getImageSetRequestBuilder = GetImageSetRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId);
+
+ if (versionId != null) {
+ getImageSetRequestBuilder = getImageSetRequestBuilder.versionId(versionId);
+ }
+
+ return medicalImagingClient.getImageSet(getImageSetRequestBuilder.build());
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+//snippet-end:[medicalimaging.java2.get_imageset.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSetMetadata.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSetMetadata.java
new file mode 100644
index 00000000000..298696bf104
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/GetImageSetMetadata.java
@@ -0,0 +1,96 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to retrieve the image set metadata.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.get_imageset_metadata.import]
+
+//snippet-end:[medicalimaging.java2.get_imageset_metadata.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.GetImageSetMetadataRequest;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+import java.nio.file.FileSystems;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class GetImageSetMetadata {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " destinationPath - The destination path for the downloaded file.\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n" +
+ " versionId - The optional version ID of the image set.\n";
+
+ if ((args.length != 3) && (args.length != 4)) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String destinationPath = args[0];
+ String datastoreId = args[1];
+ String imagesetId = args[2];
+ String versionId = null;
+ if (args.length == 4) {
+ versionId = args[3];
+ }
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ getMedicalImageSetMetadata(medicalImagingClient, destinationPath,
+ datastoreId, imagesetId, versionId);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.get_imageset_metadata.main]
+ public static void getMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient,
+ String destinationPath,
+ String datastoreId,
+ String imagesetId,
+ String versionId) {
+
+ try {
+ GetImageSetMetadataRequest.Builder getImageSetMetadataRequestBuilder =
+ GetImageSetMetadataRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId);
+
+ if (versionId != null) {
+ getImageSetMetadataRequestBuilder =
+ getImageSetMetadataRequestBuilder.versionId(versionId);
+ }
+
+ medicalImagingClient.getImageSetMetadata(getImageSetMetadataRequestBuilder.build(),
+ FileSystems.getDefault().getPath(destinationPath));
+
+ System.out.println("Metadata downloaded to " + destinationPath);
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.get_imageset_metadata.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDatastores.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDatastores.java
index 9a8640b2eeb..76e142309be 100644
--- a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDatastores.java
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDatastores.java
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
+
//snippet-end:[medicalimaging.java2.list_datastores.import]
/**
@@ -42,7 +43,7 @@ public static void main(String[] args) {
List datastoreSummaries = listMedicalImagingDatastores(medicalImagingClient);
if (datastoreSummaries != null) {
- System.out.println("The medical imaging data store properties are " + datastoreSummaries);
+ System.out.println("Here is the list of data stores:\n" + datastoreSummaries);
}
medicalImagingClient.close();
}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDicomImportJobs.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDicomImportJobs.java
new file mode 100644
index 00000000000..44f567d08b7
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListDicomImportJobs.java
@@ -0,0 +1,81 @@
+//snippet-sourcedescription:[StartDicomImportJob.java demonstrates how to list import jobs in AWS HealthImaging.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.list_dicom_import_jobs.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.DICOMImportJobSummary;
+import software.amazon.awssdk.services.medicalimaging.model.ListDicomImportJobsRequest;
+import software.amazon.awssdk.services.medicalimaging.model.ListDicomImportJobsResponse;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+//snippet-end:[medicalimaging.java2.list_dicom_import_jobs.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class ListDicomImportJobs {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n";
+
+ if (args.length != 1) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ List summaries = listDicomImportJobs(medicalImagingClient, datastoreId);
+
+ System.out.println("The import jobs are " + summaries);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.list_dicom_import_jobs.main]
+ public static List listDicomImportJobs(MedicalImagingClient medicalImagingClient,
+ String datastoreId) {
+
+ try {
+ ListDicomImportJobsRequest listDicomImportJobsRequest = ListDicomImportJobsRequest.builder()
+ .datastoreId(datastoreId)
+ .build();
+ ListDicomImportJobsResponse response = medicalImagingClient.listDICOMImportJobs(listDicomImportJobsRequest);
+ return response.jobSummaries();
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return new ArrayList<>();
+ }
+//snippet-end:[medicalimaging.java2.list_dicom_import_jobs.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListImageSetVersions.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListImageSetVersions.java
new file mode 100644
index 00000000000..1a51c644f34
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListImageSetVersions.java
@@ -0,0 +1,89 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to retrieve the versions for an image set.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.list_imageset_versions.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.ImageSetProperties;
+import software.amazon.awssdk.services.medicalimaging.model.ListImageSetVersionsRequest;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.medicalimaging.paginators.ListImageSetVersionsIterable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+//snippet-end:[medicalimaging.java2.list_imageset_versions.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class ListImageSetVersions {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n";
+
+ if (args.length != 2) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String imagesetId = args[1];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ List imageSetProperties = listMedicalImageSetVersions(medicalImagingClient, datastoreId, imagesetId);
+
+
+ System.out.println("The image set versions are " + imageSetProperties);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.list_imageset_versions.main]
+ public static List listMedicalImageSetVersions(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String imagesetId) {
+ try {
+ ListImageSetVersionsRequest getImageSetRequest = ListImageSetVersionsRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId)
+ .build();
+
+ ListImageSetVersionsIterable responses = medicalImagingClient.listImageSetVersionsPaginator(getImageSetRequest);
+ List imageSetProperties = new ArrayList<>();
+ responses.stream().forEach(response -> imageSetProperties.addAll(response.imageSetPropertiesList()));
+
+ return imageSetProperties;
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+//snippet-end:[medicalimaging.java2.list_imageset_versions.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListTagsForResource.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListTagsForResource.java
new file mode 100644
index 00000000000..76e5f51d23d
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/ListTagsForResource.java
@@ -0,0 +1,78 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to list tags for a resource.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.list_tags_for_resource.import]
+
+//snippet-end:[medicalimaging.java2.list_tags_for_resource.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.ListTagsForResourceRequest;
+import software.amazon.awssdk.services.medicalimaging.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class ListTagsForResource {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " resourceArn - The Amazon Resource Name (ARN) of the resource.\n";
+
+ if (args.length != 1) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String resourceArn = args[0];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ ListTagsForResourceResponse result = listMedicalImagingResourceTags(medicalImagingClient, resourceArn);
+
+ if (result != null) {
+ System.out.println("Tags for resource: " + result.tags());
+ }
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.list_tags_for_resource.main]
+ public static ListTagsForResourceResponse listMedicalImagingResourceTags(MedicalImagingClient medicalImagingClient,
+ String resourceArn) {
+ try {
+ ListTagsForResourceRequest listTagsForResourceRequest = ListTagsForResourceRequest.builder()
+ .resourceArn(resourceArn)
+ .build();
+
+ return medicalImagingClient.listTagsForResource(listTagsForResourceRequest);
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+//snippet-end:[medicalimaging.java2.list_tags_for_resource.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/SearchImageSets.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/SearchImageSets.java
new file mode 100644
index 00000000000..2ef56d1fc85
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/SearchImageSets.java
@@ -0,0 +1,150 @@
+//snippet-sourcedescription:[SearchImageSets.java demonstrates how to search for image sets in a data store.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.search_imagesets.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.*;
+import software.amazon.awssdk.services.medicalimaging.paginators.SearchImageSetsIterable;
+
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+//snippet-end:[medicalimaging.java2.search_imagesets.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+
+public class SearchImageSets {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " patientId - The ID of the patient to search for.\\n";
+
+ if (args.length != 2) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String patientId = args[1];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ // Use case #1: EQUAL operator.
+ //snippet-start:[medicalimaging.java2.search_imagesets.use_case1]
+ List searchFilters = Collections.singletonList(SearchFilter.builder()
+ .operator(Operator.EQUAL)
+ .values(SearchByAttributeValue.builder()
+ .dicomPatientId(patientId)
+ .build())
+ .build());
+
+ List imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient,
+ datastoreId, searchFilters);
+ if (imageSetsMetadataSummaries != null) {
+ System.out.println("The image sets for patient " + patientId + " are:\n" + imageSetsMetadataSummaries);
+ System.out.println();
+ }
+ //snippet-end:[medicalimaging.java2.search_imagesets.use_case1]
+
+ // Use case #2: BETWEEN operator using DICOMStudyDate and DICOMStudyTime.
+ //snippet-start:[medicalimaging.java2.search_imagesets.use_case2]
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+ searchFilters = Collections.singletonList(SearchFilter.builder()
+ .operator(Operator.BETWEEN)
+ .values(SearchByAttributeValue.builder()
+ .dicomStudyDateAndTime(DICOMStudyDateAndTime.builder()
+ .dicomStudyDate("19990101")
+ .dicomStudyTime("000000.000")
+ .build())
+ .build(),
+ SearchByAttributeValue.builder()
+ .dicomStudyDateAndTime(DICOMStudyDateAndTime.builder()
+ .dicomStudyDate((LocalDate.now().format(formatter)))
+ .dicomStudyTime("000000.000")
+ .build())
+ .build())
+ .build());
+
+ imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient,
+ datastoreId, searchFilters);
+ if (imageSetsMetadataSummaries != null) {
+ System.out.println("The image sets searched with BETWEEN operator using DICOMStudyDate and DICOMStudyTime are:\n" +
+ imageSetsMetadataSummaries);
+ System.out.println();
+ }
+ //snippet-end:[medicalimaging.java2.search_imagesets.use_case2]
+
+ // Use case #3: BETWEEN operator using createdAt. Time studies were previously persisted.
+ //snippet-start:[medicalimaging.java2.search_imagesets.use_case3]
+ searchFilters = Collections.singletonList(SearchFilter.builder()
+ .operator(Operator.BETWEEN)
+ .values(SearchByAttributeValue.builder()
+ .createdAt(Instant.parse("1985-04-12T23:20:50.52Z"))
+ .build(),
+ SearchByAttributeValue.builder()
+ .createdAt(Instant.now())
+ .build())
+ .build());
+
+ imageSetsMetadataSummaries = searchMedicalImagingImageSets(medicalImagingClient,
+ datastoreId, searchFilters);
+ if (imageSetsMetadataSummaries != null) {
+ System.out.println("The image sets searched with BETWEEN operator using createdAt are:\n " + imageSetsMetadataSummaries);
+ System.out.println();
+ }
+ //snippet-end:[medicalimaging.java2.search_imagesets.use_case3]
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.search_imagesets.main]
+ public static List searchMedicalImagingImageSets(MedicalImagingClient medicalImagingClient,
+ String datastoreId, List searchFilters) {
+ try {
+ SearchImageSetsRequest datastoreRequest = SearchImageSetsRequest.builder()
+ .datastoreId(datastoreId)
+ .searchCriteria(SearchCriteria.builder().filters(searchFilters).build())
+ .build();
+ SearchImageSetsIterable responses = medicalImagingClient.searchImageSetsPaginator(datastoreRequest);
+ List imageSetsMetadataSummaries = new ArrayList<>();
+
+ responses.stream().forEach(response -> imageSetsMetadataSummaries.addAll(response.imageSetsMetadataSummaries()));
+
+ return imageSetsMetadataSummaries;
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return null;
+ }
+ //snippet-end:[medicalimaging.java2.search_imagesets.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/StartDicomImportJob.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/StartDicomImportJob.java
new file mode 100644
index 00000000000..f613f9e2441
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/StartDicomImportJob.java
@@ -0,0 +1,93 @@
+//snippet-sourcedescription:[StartDicomImportJob.java demonstrates how to import bulk data into in an AWS HealthImaging data store.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.start_dicom_import_job.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.medicalimaging.model.StartDicomImportJobRequest;
+import software.amazon.awssdk.services.medicalimaging.model.StartDicomImportJobResponse;
+
+//snippet-end:[medicalimaging.java2.start_dicom_import_job.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class StartDicomImportJob {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " jobName - The import job name.\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " dataAccessRoleArn - The Amazon Resource Name (ARN) of the IAM role that grants permission to access medical imaging resource.\n" +
+ " inputS3Uri - The input prefix path for the S3 bucket that contains the DICOM files to be imported.\n" +
+ " outputS3Uri - The output prefix of the S3 bucket to upload the results of the DICOM import job.\n";
+
+ if (args.length != 5) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String jobName = args[0];
+ String datastoreId = args[1];
+ String dataAccessRoleArn = args[2];
+ String inputS3Uri = args[3];
+ String outputS3Uri = args[4];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ String jobID = startDicomImportJob(medicalImagingClient, jobName, datastoreId, dataAccessRoleArn, inputS3Uri, outputS3Uri);
+
+ System.out.println("The job ID is " + jobID);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.start_dicom_import_job.main]
+ public static String startDicomImportJob(MedicalImagingClient medicalImagingClient,
+ String jobName,
+ String datastoreId,
+ String dataAccessRoleArn,
+ String inputS3Uri,
+ String outputS3Uri) {
+
+ try {
+ StartDicomImportJobRequest startDicomImportJobRequest = StartDicomImportJobRequest.builder()
+ .jobName(jobName)
+ .datastoreId(datastoreId)
+ .dataAccessRoleArn(dataAccessRoleArn)
+ .inputS3Uri(inputS3Uri)
+ .outputS3Uri(outputS3Uri)
+ .build();
+ StartDicomImportJobResponse response = medicalImagingClient.startDICOMImportJob(startDicomImportJobRequest);
+ return response.jobId();
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+
+ return "";
+ }
+//snippet-end:[medicalimaging.java2.start_dicom_import_job.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TagResource.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TagResource.java
new file mode 100644
index 00000000000..ef922c02358
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TagResource.java
@@ -0,0 +1,79 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to tag a resource.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.tag_resource.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.medicalimaging.model.TagResourceRequest;
+import software.amazon.awssdk.utils.ImmutableMap;
+
+import java.util.Map;
+
+//snippet-end:[medicalimaging.java2.tag_resource.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class TagResource {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " resourceArn - The Amazon Resource Name (ARN) of the resource.\n";
+
+ if (args.length != 1) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String resourceArn = args[0];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ tagMedicalImagingResource(medicalImagingClient, resourceArn, ImmutableMap.of("Deployment", "Development"));
+
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.tag_resource.main]
+ public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient,
+ String resourceArn,
+ Map tags) {
+ try {
+ TagResourceRequest tagResourceRequest = TagResourceRequest.builder()
+ .resourceArn(resourceArn)
+ .tags(tags)
+ .build();
+
+ medicalImagingClient.tagResource(tagResourceRequest);
+
+ System.out.println("Tags have been added to the resource.");
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.tag_resource.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingDatastores.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingDatastores.java
new file mode 100644
index 00000000000..102b6831749
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingDatastores.java
@@ -0,0 +1,63 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates tagging, untagging and listing tags for a data store.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.tagging_datastores.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.utils.ImmutableMap;
+
+import java.util.Collections;
+
+//snippet-end:[medicalimaging.java2.tagging_datastores.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class TaggingDatastores {
+
+ public static void main(String[] args) {
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ // Set datastoreArn to the ARN of an actual data store.
+ //snippet-start:[medicalimaging.java2.tagging_datastores.datastore_arn]
+ final String datastoreArn =
+ "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012";
+ //snippet-end:[medicalimaging.java2.tagging_datastores.datastore_arn]
+
+ //snippet-start:[medicalimaging.java2.tagging_datastores.tag]
+ TagResource.tagMedicalImagingResource(medicalImagingClient, datastoreArn, ImmutableMap.of("Deployment", "Development"));
+ //snippet-end:[medicalimaging.java2.tagging_datastores.tag]
+
+ //snippet-start:[medicalimaging.java2.tagging_datastores.list]
+ ListTagsForResourceResponse result = ListTagsForResource.listMedicalImagingResourceTags(medicalImagingClient, datastoreArn);
+ if (result != null) {
+ System.out.println("Tags for resource: " + result.tags());
+ }
+ //snippet-end:[medicalimaging.java2.tagging_datastores.list]
+
+ //snippet-start:[medicalimaging.java2.tagging_datastores.untag]
+ UntagResource.untagMedicalImagingResource(medicalImagingClient, datastoreArn, Collections.singletonList("Deployment"));
+ //snippet-end:[medicalimaging.java2.tagging_datastores.untag]
+
+ medicalImagingClient.close();
+ }
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingImageSets.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingImageSets.java
new file mode 100644
index 00000000000..c71513b27b7
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/TaggingImageSets.java
@@ -0,0 +1,63 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates tagging, untagging and listing tags for an image set.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.tagging_imagesets.import]
+
+//snippet-end:[medicalimaging.java2.tagging_imagesets.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.utils.ImmutableMap;
+
+import java.util.Collections;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class TaggingImageSets {
+
+ public static void main(String[] args) {
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ // Set imageSetArn to the ARN of an actual image set.
+ //snippet-start:[medicalimaging.java2.tagging_imagesets.datastore_arn]
+ final String imageSetArn =
+ "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012";
+ //snippet-end:[medicalimaging.java2.tagging_imagesets.datastore_arn]
+
+ //snippet-start:[medicalimaging.java2.tagging_imagesets.tag]
+ TagResource.tagMedicalImagingResource(medicalImagingClient, imageSetArn, ImmutableMap.of("Deployment", "Development"));
+ //snippet-end:[medicalimaging.java2.tagging_imagesets.tag]
+
+ //snippet-start:[medicalimaging.java2.tagging_imagesets.list]
+ ListTagsForResourceResponse result = ListTagsForResource.listMedicalImagingResourceTags(medicalImagingClient, imageSetArn);
+ if (result != null) {
+ System.out.println("Tags for resource: " + result.tags());
+ }
+ //snippet-end:[medicalimaging.java2.tagging_imagesets.list]
+
+ //snippet-start:[medicalimaging.java2.tagging_imagesets.untag]
+ UntagResource.untagMedicalImagingResource(medicalImagingClient, imageSetArn, Collections.singletonList("Deployment"));
+ //snippet-end:[medicalimaging.java2.tagging_imagesets.untag]
+
+ medicalImagingClient.close();
+ }
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UntagResource.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UntagResource.java
new file mode 100644
index 00000000000..af4e31b6890
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UntagResource.java
@@ -0,0 +1,79 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to remove tags from a resource.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.untag_resource.import]
+
+//snippet-end:[medicalimaging.java2.untag_resource.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.medicalimaging.model.UntagResourceRequest;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class UntagResource {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " resourceArn - The Amazon Resource Name (ARN) of the resource.\n";
+
+ if (args.length != 1) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String resourceArn = args[0];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ untagMedicalImagingResource(medicalImagingClient, resourceArn, Collections.singletonList("Deployment"));
+
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.untag_resource.main]
+ public static void untagMedicalImagingResource(MedicalImagingClient medicalImagingClient,
+ String resourceArn,
+ Collection tagKeys) {
+ try {
+ UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder()
+ .resourceArn(resourceArn)
+ .tagKeys(tagKeys)
+ .build();
+
+ medicalImagingClient.untagResource(untagResourceRequest);
+
+ System.out.println("Tags have been removed from the resource.");
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.untag_resource.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UpdateImageSetMetadata.java b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UpdateImageSetMetadata.java
new file mode 100644
index 00000000000..2cc9dfa3a12
--- /dev/null
+++ b/javav2/example_code/medicalimaging/src/main/java/com/example/medicalimaging/UpdateImageSetMetadata.java
@@ -0,0 +1,101 @@
+//snippet-sourcedescription:[GetImageSet.java demonstrates how to update an image set's metadata.]
+//snippet-keyword:[AWS SDK for Java v2]
+//snippet-keyword:[AWS HealthImaging]
+
+package com.example.medicalimaging;
+
+/*
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ SPDX-License-Identifier: Apache-2.0
+*/
+
+//snippet-start:[medicalimaging.java2.update_image_set_metadata.import]
+
+import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
+import software.amazon.awssdk.core.SdkBytes;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
+import software.amazon.awssdk.services.medicalimaging.model.DICOMUpdates;
+import software.amazon.awssdk.services.medicalimaging.model.MedicalImagingException;
+import software.amazon.awssdk.services.medicalimaging.model.MetadataUpdates;
+import software.amazon.awssdk.services.medicalimaging.model.UpdateImageSetMetadataRequest;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+//snippet-end:[medicalimaging.java2.update_image_set_metadata.import]
+
+/**
+ * Before running this Java V2 code example, set up your development environment, including your credentials.
+ *
+ * For more information, see the following documentation topic:
+ *
+ * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
+ */
+public class UpdateImageSetMetadata {
+
+ public static void main(String[] args) {
+ final String usage = "\n" +
+ "Usage:\n" +
+ " \n\n" +
+ "Where:\n" +
+ " datastoreId - The ID of the data store.\n" +
+ " imagesetId - The ID of the image set.\n" +
+ " versionId - The latest version ID of the image set.\n";
+
+ if (args.length != 3) {
+ System.out.println(usage);
+ System.exit(1);
+ }
+
+ String datastoreId = args[0];
+ String imagesetId = args[1];
+ String versionid = args[2];
+
+ Region region = Region.US_WEST_2;
+ MedicalImagingClient medicalImagingClient = MedicalImagingClient.builder()
+ .region(region)
+ .credentialsProvider(ProfileCredentialsProvider.create())
+ .build();
+
+ final String updateAttributes = "{\"SchemaVersion\":1.1,\"Patient\":{\"DICOM\":{\"PatientName\":\"MX^MX\"}}}";
+ final String removeAttributes = "{\"SchemaVersion\":1.1,\"Patient\":{\"DICOM\":{\"PatientSex\":\"X\"}}}";
+ MetadataUpdates metadataUpdates = MetadataUpdates.builder()
+ .dicomUpdates(DICOMUpdates.builder()
+ .updatableAttributes(SdkBytes.fromByteBuffer(
+ ByteBuffer.wrap(updateAttributes.getBytes(StandardCharsets.UTF_8))))
+ .removableAttributes(SdkBytes.fromByteBuffer(
+ ByteBuffer.wrap(removeAttributes.getBytes(StandardCharsets.UTF_8))))
+ .build())
+ .build();
+
+ updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId,
+ versionid, metadataUpdates);
+
+ medicalImagingClient.close();
+ }
+
+ //snippet-start:[medicalimaging.java2.update_image_set_metadata.main]
+ public static void updateMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient,
+ String datastoreId,
+ String imagesetId,
+ String versionId,
+ MetadataUpdates metadataUpdates) {
+ try {
+ UpdateImageSetMetadataRequest updateImageSetMetadataRequest = UpdateImageSetMetadataRequest.builder()
+ .datastoreId(datastoreId)
+ .imageSetId(imagesetId)
+ .latestVersionId(versionId)
+ .updateImageSetMetadataUpdates(metadataUpdates)
+ .build();
+
+ medicalImagingClient.updateImageSetMetadata(updateImageSetMetadataRequest);
+
+ System.out.println("The image set metadata was updated");
+ } catch (MedicalImagingException e) {
+ System.err.println(e.awsErrorDetails().errorMessage());
+ System.exit(1);
+ }
+ }
+//snippet-end:[medicalimaging.java2.update_image_set_metadata.main]
+}
diff --git a/javav2/example_code/medicalimaging/src/test/java/AWSMedicalImagingTest.java b/javav2/example_code/medicalimaging/src/test/java/AWSMedicalImagingTest.java
index 6dfa3e1d07a..d3a90a2e1a2 100644
--- a/javav2/example_code/medicalimaging/src/test/java/AWSMedicalImagingTest.java
+++ b/javav2/example_code/medicalimaging/src/test/java/AWSMedicalImagingTest.java
@@ -3,20 +3,26 @@
SPDX-License-Identifier: Apache-2.0
*/
-import com.example.medicalimaging.CreateDatastore;
-import com.example.medicalimaging.DeleteDatastore;
-import com.example.medicalimaging.GetDatastore;
-import com.example.medicalimaging.ListDatastores;
+import com.example.medicalimaging.*;
+import com.google.gson.Gson;
import org.junit.jupiter.api.*;
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.medicalimaging.MedicalImagingClient;
-import software.amazon.awssdk.services.medicalimaging.model.DatastoreProperties;
+import software.amazon.awssdk.services.medicalimaging.model.*;
+import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
+import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
+import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
+import software.amazon.awssdk.utils.ImmutableMap;
+import java.io.File;
+import java.time.Instant;
+import java.util.Collections;
import java.util.List;
import java.util.Random;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* To run these integration tests, you must set the required values
@@ -28,13 +34,24 @@ public class AWSMedicalImagingTest {
private static MedicalImagingClient medicalImagingClient;
private static String datastoreName = "";
- private static String datastoreID = "";
+
+ private static String workingDatastoreId = "";
+
+ private static String imageSetId = "";
+ private static String imageFrameId = "";
+
+ private static String dataResourceArn = "";
+ private static String createdDatastoreId = "";
+
+ private static String importJobId = "";
+
+
@BeforeAll
public static void setUp() {
medicalImagingClient = MedicalImagingClient.builder()
- .region(Region.US_EAST_1)
+ .region(Region.US_WEST_2) // TODO: change back to US-EAST-1
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
@@ -42,23 +59,60 @@ public static void setUp() {
int randomNum = random.nextInt((10000 - 1) + 1) + 1;
datastoreName = "java_test_" + randomNum;
+ // Get the values to run these tests from AWS Secrets Manager.
+ Gson gson = new Gson();
+ String json = getSecretValues();
+ SecretValues values = gson.fromJson(json, SecretValues.class);
+ workingDatastoreId = values.getDatastoreId();
+ imageSetId = values.getImageSetId();
+ imageFrameId = values.getImageFrameId();
+ importJobId = values.getImportJobId();
+ dataResourceArn = values.getDataResourceArn();
+
+ // Uncomment this code block if you prefer using a config.properties file to retrieve AWS values required for these tests.
+ /*
+
+ try (InputStream input = AWSMedicalImagingTest.class.getClassLoader().getResourceAsStream("config.properties")) {
+ Properties prop = new Properties();
+ prop.load(input);
+ dataAccessRoleArn = prop.getProperty("dataAccessRoleArn");
+ inputS3Uri= prop.getProperty("inputS3Uri");
+ outputS3Uri= prop.getProperty("outputS3Uri");
+
+ if (input == null) {
+ System.out.println("Sorry, unable to find config.properties");
+ return;
+ }
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ */
+ }
+
+
+ @SuppressWarnings("resource")
+ private static String getSecretValues() {
+ SecretsManagerClient secretClient = SecretsManagerClient.builder()
+ .region(Region.US_WEST_2) // TODO: change back to US-EAST-1
+ .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
+ .build();
+ String secretName = "test/medicalimaging";
+
+ GetSecretValueRequest valueRequest = GetSecretValueRequest.builder()
+ .secretId(secretName)
+ .build();
+
+ GetSecretValueResponse valueResponse = secretClient.getSecretValue(valueRequest);
+ return valueResponse.secretString();
}
@Test
@Tag("IntegrationTest")
@Order(1)
public void createDatastoreTest() {
- assertDoesNotThrow(() -> datastoreID = CreateDatastore.createMedicalImageDatastore(medicalImagingClient, datastoreName));
- assertFalse(datastoreID.isEmpty());
-
- // Sleep for 10 seconds to give time for the data store to be created
- try {
- Thread.sleep(10000);
- } catch (java.lang.InterruptedException e) {
- System.err.println("Sleep Interrupted");
- }
-
- System.out.println("Test 1 passed");
+ assertDoesNotThrow(() -> createdDatastoreId = CreateDatastore.createMedicalImageDatastore(medicalImagingClient, datastoreName));
+ assert (!createdDatastoreId.isEmpty());
}
@@ -67,7 +121,7 @@ public void createDatastoreTest() {
@Order(2)
public void getDatastoreTest() {
final DatastoreProperties[] datastoreProperties = {null};
- assertDoesNotThrow(() -> datastoreProperties[0] = GetDatastore.getMedicalImageDatastore(medicalImagingClient, datastoreID));
+ assertDoesNotThrow(() -> datastoreProperties[0] = GetDatastore.getMedicalImageDatastore(medicalImagingClient, workingDatastoreId));
assertNotNull(datastoreProperties[0]);
System.out.println("Test 2 passed");
@@ -89,8 +143,187 @@ public void listDatastoresTest() {
@Test
@Tag("IntegrationTest")
@Order(4)
- public void deleteDatastoreTest() {
- assertDoesNotThrow(() -> DeleteDatastore.deleteMedicalImagingDatastore(medicalImagingClient, datastoreID));
+ public void getDicomImportJobTest() {
+ final DICOMImportJobProperties[] dicomImportJobSummaries = {null};
+ assertDoesNotThrow(() -> dicomImportJobSummaries[0] = GetDicomImportJob.getDicomImportJob(medicalImagingClient,
+ workingDatastoreId, importJobId));
+ assertNotNull(dicomImportJobSummaries[0]);
+
System.out.println("Test 4 passed");
}
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(5)
+ public void listDicomImportJobsTest() {
+ @SuppressWarnings("rawtypes") final List[] dicomImportJobSummaries = {null};
+ assertDoesNotThrow(() -> dicomImportJobSummaries[0] = ListDicomImportJobs.listDicomImportJobs(medicalImagingClient,
+ workingDatastoreId));
+ assertNotNull(dicomImportJobSummaries[0]);
+
+ System.out.println("Test 5 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(6)
+ public void searchImageSetsTest() {
+ List searchFilters = Collections.singletonList(SearchFilter.builder()
+ .operator(Operator.BETWEEN)
+ .values(SearchByAttributeValue.builder()
+ .createdAt(Instant.parse("1985-04-12T23:20:50.52Z"))
+ .build(),
+ SearchByAttributeValue.builder()
+ .createdAt(Instant.now())
+ .build())
+ .build());
+
+ @SuppressWarnings("rawtypes") final List[] searchResults = {null};
+ assertDoesNotThrow(() -> searchResults[0] = SearchImageSets.searchMedicalImagingImageSets(medicalImagingClient,
+ workingDatastoreId, searchFilters));
+ assertNotNull(searchResults[0]);
+
+ System.out.println("Test 6 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(7)
+ public void getImageSetTest() {
+ final GetImageSetResponse[] imageSetResponses = {null};
+ assertDoesNotThrow(() -> imageSetResponses[0] = GetImageSet.getMedicalImageSet(medicalImagingClient,
+ workingDatastoreId, imageSetId, "1"));
+ assertNotNull(imageSetResponses[0]);
+
+ System.out.println("Test 7 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(8)
+ public void getImageSetMetadataTest() {
+ final String metadataFileName = "java_metadatata.json.gzip";
+ assertDoesNotThrow(() -> GetImageSetMetadata.getMedicalImageSetMetadata(medicalImagingClient, metadataFileName,
+ workingDatastoreId, imageSetId, "1"));
+
+ File metadataFile = new File(metadataFileName);
+ assert (metadataFile.exists());
+ //noinspection ResultOfMethodCallIgnored
+ metadataFile.delete();
+
+ System.out.println("Test 8 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(9)
+ public void getImageFrameTest() {
+ final String imageFileName = "java_impage.jph";
+ assertDoesNotThrow(() -> GetImageFrame.getMedicalImageSetFrame(medicalImagingClient, imageFileName,
+ workingDatastoreId, imageSetId, imageFrameId));
+
+ File imageFile = new File(imageFileName);
+ assert (imageFile.exists());
+ //noinspection ResultOfMethodCallIgnored
+ imageFile.delete();
+
+ System.out.println("Test 9 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(10)
+ public void listImageSetVersionsTest() {
+ @SuppressWarnings("rawtypes") List[] imageSetVersions = new List[1];
+ assertDoesNotThrow(() -> imageSetVersions[0] = ListImageSetVersions.listMedicalImageSetVersions(medicalImagingClient, workingDatastoreId, imageSetId));
+ assertNotNull(imageSetVersions[0]);
+
+ System.out.println("Test 10 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(11)
+ public void tagResourceTest() {
+ assertDoesNotThrow(() -> TagResource.tagMedicalImagingResource(medicalImagingClient, dataResourceArn, ImmutableMap.of("Deployment", "Development")));
+
+
+ System.out.println("Test 11 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(12)
+ public void listTagsForResourceTest() {
+ ListTagsForResourceResponse[] listTagsForResourceResponses = {null};
+ assertDoesNotThrow(() -> listTagsForResourceResponses[0] = ListTagsForResource.listMedicalImagingResourceTags(medicalImagingClient, dataResourceArn));
+ assertNotNull(listTagsForResourceResponses[0]);
+
+ System.out.println("Test 12 passed");
+ }
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(13)
+ public void untagResourceTest() {
+ assertDoesNotThrow(() -> UntagResource.untagMedicalImagingResource(medicalImagingClient, dataResourceArn, Collections.singletonList("Deployment")));
+
+ System.out.println("Test 13 passed");
+ }
+
+
+ @Test
+ @Tag("IntegrationTest")
+ @Order(14)
+ public void deleteDatastoreTest() {
+ assert (!createdDatastoreId.isEmpty());
+ int count = 0;
+ while (count < 20) {
+ final DatastoreProperties[] datastoreProperties = {null};
+ assertDoesNotThrow(() -> datastoreProperties[0] = GetDatastore.getMedicalImageDatastore(medicalImagingClient, workingDatastoreId));
+ if (datastoreProperties[0].datastoreStatus().toString().equals("ACTIVE")) {
+ break;
+ }
+ assertDoesNotThrow(() -> Thread.sleep(1000));
+ count++;
+ }
+ assertDoesNotThrow(() -> DeleteDatastore.deleteMedicalImagingDatastore(medicalImagingClient, createdDatastoreId));
+ System.out.println("Test 14 passed");
+ }
+
+ @SuppressWarnings("unused")
+ @Nested
+ @DisplayName("A class used to get test values from test/medicalimaging (an AWS Secrets Manager secret)")
+ class SecretValues {
+
+ private String datastoreId;
+
+ private String imageSetId;
+
+ private String imageFrameId;
+
+ private String importJobId;
+
+ private String dataResourceArn;
+
+ public String getDatastoreId() {
+ return datastoreId;
+ }
+
+ public String getImageSetId() {
+ return imageSetId;
+ }
+
+ public String getImageFrameId() {
+ return imageFrameId;
+ }
+
+ public String getImportJobId() {
+ return importJobId;
+ }
+
+ public String getDataResourceArn() {
+ return dataResourceArn;
+ }
+ }
}
\ No newline at end of file