Skip to content

Commit

Permalink
moving the tagging scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
meyertst-aws committed Oct 17, 2023
1 parent 4aacb42 commit fc006f5
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 49 deletions.
10 changes: 5 additions & 5 deletions python/example_code/medical-imaging/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--Generated by WRITEME on 2023-10-16 19:52:26.053001 (UTC)-->
<!--Generated by WRITEME on 2023-10-17 12:32:16.226632 (UTC)-->
# HealthImaging code examples for the SDK for Python

## Overview
Expand Down Expand Up @@ -63,8 +63,8 @@ Code excerpts that show you how to call individual service functions.
Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

* [Tagging a data store](medical_imaging_basics.py)
* [Tagging an image set](medical_imaging_basics.py)
* [Tagging a data store](tagging_data_stores.py)
* [Tagging an image set](tagging_image_sets.py)

## Run the examples

Expand All @@ -87,7 +87,7 @@ This example shows you how to tag a HealthImaging data store.
Start the example by running the following at a command prompt:

```
python medical_imaging_basics.py
python tagging_data_stores.py
```


Expand All @@ -105,7 +105,7 @@ This example shows you how to tag a HealthImaging image set.
Start the example by running the following at a command prompt:

```
python medical_imaging_basics.py
python tagging_image_sets.py
```


Expand Down
44 changes: 0 additions & 44 deletions python/example_code/medical-imaging/medical_imaging_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,50 +464,6 @@ def list_tags_for_resource(self, resource_arn):

# snippet-end:[python.example_code.medical-imaging.ListTagsForResource]

def tagging_datastore(self, datastore_arn):
# snippet-start:[python.example_code.medical-imaging.tagging_datastore.arn]
"""
Taggging a data store.
:param datastore_arn: The Amazon Resource Name (ARN) of the data store.
For example: arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012
"""
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.arn]

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.tag]
self.tag_resource(datastore_arn, {"Deployment": "Development"})
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.tag]

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.list]
self.list_tags_for_resource(datastore_arn)
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.list]

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.untag]
self.untag_resource(datastore_arn, ["Deployment"])

# snippet-end:[python.example_code.medical-imaging.tagging_datastore.untag]

def tagging_image_set(self, image_set_arn):
# snippet-start:[python.example_code.medical-imaging.tagging_image_set.arn]
"""
Taggging a data store.
:param image_set_arn: The Amazon Resource Name (ARN) of the data store.
For example: arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/12345678901234567890123456789012
"""
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.arn]

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.tag]
self.tag_resource(image_set_arn, {"Deployment": "Development"})
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.tag]

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.list]
self.list_tags_for_resource(image_set_arn)
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.list]

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.untag]
self.untag_resource(image_set_arn, ["Deployment"])
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.untag]

def usage_demo(self, source_s3_uri, dest_s3_uri, data_access_role_arn):
data_store_name = f"python_usage_demo_data_store_{random.randint(0, 200000)}"
Expand Down
47 changes: 47 additions & 0 deletions python/example_code/medical-imaging/tagging_data_stores.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

"""
Purpose
Shows how to use the AWS SDK for Python (Boto3) to tag AWS HealthImaging data stores.
"""
import boto3
from medical_imaging_basics import MedicalImagingWrapper


def tagging_data_stores(medical_imaging_wrapper, data_store_arn):
"""
Taggging a data store.
:param medical_imaging_wrapper: A MedicalImagingWrapper instance.
:param data_store_arn: The Amazon Resource Name (ARN) of the data store.
For example: arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012
"""

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.tag]
medical_imaging_wrapper.tag_resource(data_store_arn, {"Deployment": "Development"})
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.tag]

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.list]
medical_imaging_wrapper.list_tags_for_resource(data_store_arn)
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.list]

# snippet-start:[python.example_code.medical-imaging.tagging_datastore.untag]
medical_imaging_wrapper.untag_resource(data_store_arn, ["Deployment"])

# snippet-end:[python.example_code.medical-imaging.tagging_datastore.untag]


if __name__ == '__main__':
# Replace this ARN with your own.
# snippet-start:[python.example_code.medical-imaging.tagging_datastore.arn]
a_data_store_arn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'
# snippet-end:[python.example_code.medical-imaging.tagging_datastore.arn]

a_data_store_arn = input(f"Enter the ARN of the data store to tag: ")

client = boto3.client('medical-imaging')
a_medical_imaging_wrapper = MedicalImagingWrapper(client)

tagging_data_stores(a_medical_imaging_wrapper, a_data_store_arn)
48 changes: 48 additions & 0 deletions python/example_code/medical-imaging/tagging_image_sets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

"""
Purpose
Shows how to use the AWS SDK for Python (Boto3) to tag AWS HealthImaging image sets.
"""
import boto3
from medical_imaging_basics import MedicalImagingWrapper


def tagging_image_sets(medical_imaging_wrapper, image_set_arn):
"""
Taggging an image set.
:param medical_imaging_wrapper: A MedicalImagingWrapper instance.
:param image_set_arn: The Amazon Resource Name (ARN) of the image set.
For example: 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/' \
'imageset/12345678901234567890123456789012'
"""

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.tag]
medical_imaging_wrapper.tag_resource(image_set_arn, {"Deployment": "Development"})
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.tag]

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.list]
medical_imaging_wrapper.list_tags_for_resource(image_set_arn)
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.list]

# snippet-start:[python.example_code.medical-imaging.tagging_image_set.untag]
medical_imaging_wrapper.untag_resource(image_set_arn, ["Deployment"])
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.untag]


if __name__ == '__main__':
# Replace this ARN with your own.
# snippet-start:[python.example_code.medical-imaging.tagging_image_set.arn]
an_image_set_arn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/' \
'imageset/12345678901234567890123456789012'
# snippet-end:[python.example_code.medical-imaging.tagging_image_set.arn]

an_image_set_arn = input(f"Enter the ARN of the image set to tag: ")

client = boto3.client('medical-imaging')
a_medical_imaging_wrapper = MedicalImagingWrapper(client)

tagging_image_sets(a_medical_imaging_wrapper, an_image_set_arn)

0 comments on commit fc006f5

Please sign in to comment.