Use the TagResource
action to tag data
stores and image sets in AWS HealthImaging. The
following code examples describe how to use the TagResource
action with the
AWS Management Console, AWS CLI, and AWS SDKs. For more information, see Tagging your AWS resources in
the AWS General Reference Guide.
To tag a resource
Choose a menu based on your access preference to AWS HealthImaging.
-
Open the HealthImaging console Data stores page
. -
Choose a data store.
The Data store details page opens.
-
Choose the Details tab.
-
Under the Tags section, choose Manage tags.
The Manage tags page opens.
-
Choose Add new tag.
-
Enter a Key and Value (optional).
-
Choose Save changes.
AWS Console
-
Open the HealthImaging console Data stores page
. -
Choose a data store.
The Data store details page opens.
-
Choose the Details tab.
-
Under the Tags section, choose Manage tags.
The Manage tags page opens.
-
Choose Add new tag.
-
Enter a Key and Value (optional).
-
Choose Save changes.
- CLI
-
- AWS CLI
-
Example 1: To tag a data store
The following
tag-resource
code examples tags a data store.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
Example 2: To tag an image set
The following
tag-resource
code examples tags an image set.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
-
For API details, see TagResource
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> 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); } }
-
For API details, see TagResource in AWS SDK for Java 2.x API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
- JavaScript
-
- SDK for JavaScript (v3)
-
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<string,string>} 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; };
-
For API details, see TagResource in AWS SDK for JavaScript API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
- Python
-
- SDK for Python (Boto3)
-
class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def tag_resource(self, resource_arn, tags): """ Tag a resource. :param resource_arn: The ARN of the resource. :param tags: The tags to apply. """ try: self.health_imaging_client.tag_resource(resourceArn=resource_arn, tags=tags) except ClientError as err: logger.error( "Couldn't tag resource. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
The following code instantiates the MedicalImagingWrapper object.
client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
-
For API details, see TagResource in AWS SDK for Python (Boto3) API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
Example availability
Can't find what you need? Request a code example using the Provide feedback link on the right sidebar of this page.
AWS CLI and SDKs
- CLI
-
- AWS CLI
-
Example 1: To tag a data store
The following
tag-resource
code examples tags a data store.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
Example 2: To tag an image set
The following
tag-resource
code examples tags an image set.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
-
For API details, see TagResource
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> 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); } }
-
For API details, see TagResource in AWS SDK for Java 2.x API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
- JavaScript
-
- SDK for JavaScript (v3)
-
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<string,string>} 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; };
-
For API details, see TagResource in AWS SDK for JavaScript API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
- Python
-
- SDK for Python (Boto3)
-
class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def tag_resource(self, resource_arn, tags): """ Tag a resource. :param resource_arn: The ARN of the resource. :param tags: The tags to apply. """ try: self.health_imaging_client.tag_resource(resourceArn=resource_arn, tags=tags) except ClientError as err: logger.error( "Couldn't tag resource. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
The following code instantiates the MedicalImagingWrapper object.
client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
-
For API details, see TagResource in AWS SDK for Python (Boto3) API Reference.
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. -
- AWS CLI
-
Example 1: To tag a data store
The following
tag-resource
code examples tags a data store.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
Example 2: To tag an image set
The following
tag-resource
code examples tags an image set.aws medical-imaging tag-resource \ --resource-arn
"arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b"
\ --tags '{"Deployment":"Development"}
'This command produces no output.
-
For API details, see TagResource
in AWS CLI Command Reference.
-
Example availability
Can't find what you need? Request a code example using the Provide feedback link on the right sidebar of this page.