Listing tags for a resource - AWS HealthImaging

Listing tags for a resource

Use the ListTagsForResource action to list tags for data stores and image sets in AWS HealthImaging. The following code examples describe how to use the ListTagsForResource 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 list tags for a resource

Choose a menu based on your access preference to AWS HealthImaging.

  1. Open the HealthImaging console Data stores page.

  2. Choose a data store.

    The Data store details page opens.

  3. Choose the Details tab.

    Under the Tags section, all data store tags are listed.

CLI
AWS CLI

Example 1: To list resource tags for a data store

The following list-tags-for-resource code example lists tags for a data store.

aws medical-imaging list-tags-for-resource \ --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012"

Output:

{ "tags":{ "Deployment":"Development" } }

Example 2: To list resource tags for an image set

The following list-tags-for-resource code example lists tags for an image set.

aws medical-imaging list-tags-for-resource \ --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b"

Output:

{ "tags":{ "Deployment":"Development" } }

Java
SDK for Java 2.x
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; }
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 { ListTagsForResourceCommand } from "@aws-sdk/client-medical-imaging"; import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} resourceArn - The Amazon Resource Name (ARN) for the data store or image set. */ export const listTagsForResource = async ( resourceArn = "arn:aws:medical-imaging:us-east-1:abc:datastore/def/imageset/ghi", ) => { const response = await medicalImagingClient.send( new ListTagsForResourceCommand({ resourceArn: resourceArn }), ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: '008fc6d3-abec-4870-a155-20fa3631e645', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // tags: { Deployment: 'Development' } // } return response; };
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 list_tags_for_resource(self, resource_arn): """ List the tags for a resource. :param resource_arn: The ARN of the resource. :return: The list of tags. """ try: tags = self.health_imaging_client.list_tags_for_resource( resourceArn=resource_arn ) except ClientError as err: logger.error( "Couldn't list tags for resource. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return tags["tags"]

The following code instantiates the MedicalImagingWrapper object.

client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
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.