

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 標記 HealthLake 資料存放區
<a name="managing-data-stores-tagging"></a>

您可以將中繼資料以標籤形式指派給 HealthLake 資料存放區。每個標籤都是由使用者定義的金鑰和值組成的標籤。標籤可協助您管理、識別、組織、搜尋和篩選資料存放區。

**Important (重要)**  
請勿在標籤中存放受保護醫療資訊 (PHI)、個人身分識別資訊 (PII) 或其他機密或敏感資訊。標籤不適用於私有或敏感資料。

下列主題說明如何使用 AWS 管理主控台、 AWS CLI和 AWS SDKs 來使用 HealthLake 標記操作。如需詳細資訊，請參閱《 *AWS 一般參考 指南*》中的[標記您的 AWS 資源](https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html)。

**Topics**
+ [標記 HealthLake 資料存放區](#tagresource)
+ [列出 HealthLake 資料存放區的標籤](#listtagsforresource)
+ [取消標記 HealthLake 資料存放區](#untagresource)

## 標記 HealthLake 資料存放區
<a name="tagresource"></a>

使用 `TagResource`標記 HealthLake 資料存放區。下列功能表提供 AWS CLI AWS SDKs 的 AWS 管理主控台 和 程式碼範例程序。如需詳細資訊，請參閱 *AWS HealthLake API 參考*中的 [https://docs.aws.amazon.com/healthlake/latest/APIReference/API_TagResource.html.html](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_TagResource.html.html)。

**標記 HealthLake 資料存放區**  
根據您的存取偏好設定選擇選單 AWS HealthLake。

### AWS CLI 和 SDKs
<a name="tagresource-cli-sdk"></a>

------
#### [ CLI ]

**AWS CLI**  
**將標籤新增至資料存放區**  
以下 `tag-resource` 範例示範如何將標籤新增至資料存放區。  

```
aws healthlake tag-resource \
    --resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe" \
    --tags '[{"Key": "key1", "Value": "value1"}]'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS HealthLake 開發人員指南》**中的[將標籤新增至資料存放區](https://docs.aws.amazon.com/healthlake/latest/devguide/add-a-tag.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/healthlake/tag-resource.html)。

------
#### [ Python ]

**適用於 Python 的 SDK (Boto3)**  

```
    @classmethod
    def from_client(cls) -> "HealthLakeWrapper":
        """
        Creates a HealthLakeWrapper instance with a default AWS HealthLake client.

        :return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
        """
        health_lake_client = boto3.client("healthlake")
        return cls(health_lake_client)


    def tag_resource(self, resource_arn: str, tags: list[dict[str, str]]) -> None:
        """
        Tags a HealthLake resource.
        :param resource_arn: The resource ARN.
        :param tags: The tags to add to the resource.
        """
        try:
            self.health_lake_client.tag_resource(ResourceARN=resource_arn, Tags=tags)
        except ClientError as err:
            logger.exception(
                "Couldn't tag resource %s. Here's why %s",
                resource_arn,
                err.response["Error"]["Message"],
            )
            raise
```
+  如需 API 詳細資訊，請參閱《AWS SDK for Python (Boto3) API 參考》**中的 [TagResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/TagResource)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中設定和執行。

------
#### [ SAP ABAP ]

**適用於 SAP ABAP 的開發套件**  
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/hll#code-examples)中設定和執行。

```
    TRY.
        " iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
        lo_hll->tagresource(
          iv_resourcearn = iv_resource_arn
          it_tags = it_tags
        ).
        MESSAGE 'Resource tagged successfully.' TYPE 'I'.
      CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
        DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_validation_ex.
      CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
        lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_notfound_ex.
    ENDTRY.
```
+  如需 API 詳細資訊，請參閱《適用於 *AWS SAP ABAP 的 SDK API 參考*》中的 [TagResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)。

------

**可用性範例**  
找不到所需的內容嗎？ 使用此頁面右側的**提供意見回饋**連結來請求程式碼範例。

### AWS 主控台
<a name="tagresource-console"></a>

1. 登入 HealthLake 主控台上的[資料存放](https://console.aws.amazon.com/healthlake/home#/list-datastores)區頁面。

1. 選擇資料存放區。

   **資料存放區詳細資訊**頁面隨即開啟。

1. 在**標籤**區段下，選擇**管理標籤**。

   隨即開啟**管理標籤**頁面。

1. 選擇 **Add new tag (新增標籤)**。

1. 輸入**金鑰**和**值** （選用）。

1. 選擇**儲存**。

## 列出 HealthLake 資料存放區的標籤
<a name="listtagsforresource"></a>

使用 `ListTagsForResource`列出 HealthLake 資料存放區的標籤。下列功能表提供 AWS CLI AWS SDKs 的 AWS 管理主控台 和 程式碼範例程序。如需詳細資訊，請參閱 *AWS HealthLake API 參考*中的 [https://docs.aws.amazon.com/healthlake/latest/APIReference/API_ListTagsForResource.html.html](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_ListTagsForResource.html.html)。

**列出 HealthLake 資料存放區的標籤**  
根據您的存取偏好設定選擇選單 AWS HealthLake。

### AWS CLI 和 SDKs
<a name="listtagsforresource-cli-sdk"></a>

------
#### [ CLI ]

**AWS CLI**  
**列出資料存放區的標籤**  
下列 `list-tags-for-resource` 範例列出與指定資料存放區相關聯的標籤：  

```
aws healthlake list-tags-for-resource \
    --resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe"
```
輸出：  

```
{
    "tags": {
        "key": "value",
        "key1": "value1"
    }
}
```
如需詳細資訊，請參閱《[AWS HealthLake 開發人員指南》中的在HealthLake 中標記資源](https://docs.aws.amazon.com/healthlake/latest/devguide/tagging.html)。 AWS HealthLake   
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/healthlake/list-tags-for-resource.html)。

------
#### [ Python ]

**適用於 Python 的 SDK (Boto3)**  

```
    @classmethod
    def from_client(cls) -> "HealthLakeWrapper":
        """
        Creates a HealthLakeWrapper instance with a default AWS HealthLake client.

        :return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
        """
        health_lake_client = boto3.client("healthlake")
        return cls(health_lake_client)


    def list_tags_for_resource(self, resource_arn: str) -> dict[str, str]:
        """
        Lists the tags for a HealthLake resource.
        :param resource_arn: The resource ARN.
        :return: The tags for the resource.
        """
        try:
            response = self.health_lake_client.list_tags_for_resource(
                ResourceARN=resource_arn
            )
            return response["Tags"]
        except ClientError as err:
            logger.exception(
                "Couldn't list tags for resource %s. Here's why %s",
                resource_arn,
                err.response["Error"]["Message"],
            )
            raise
```
+  如需 API 詳細資訊，請參閱《AWS SDK for Python (Boto3) API 參考》**中的 [ListTagsForResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/ListTagsForResource)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中設定和執行。

------
#### [ SAP ABAP ]

**適用於 SAP ABAP 的開發套件**  
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/hll#code-examples)中設定和執行。

```
    TRY.
        " iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
        DATA(lo_result) = lo_hll->listtagsforresource(
          iv_resourcearn = iv_resource_arn
        ).
        ot_tags = lo_result->get_tags( ).
        DATA(lv_tag_count) = lines( ot_tags ).
        MESSAGE |Found { lv_tag_count } tag(s).| TYPE 'I'.
      CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
        DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_validation_ex.
      CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
        lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_notfound_ex.
    ENDTRY.
```
+  如需 API 詳細資訊，請參閱《適用於 *AWS SAP ABAP 的 SDK API 參考*》中的 [ListTagsForResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)。

------

**可用性範例**  
找不到所需的內容嗎？ 使用此頁面右側的**提供意見回饋**連結來請求程式碼範例。

### AWS 主控台
<a name="listtagsforresource-console"></a>

1. 登入 HealthLake 主控台上的[資料存放](https://console.aws.amazon.com/healthlake/home#/list-datastores)區頁面。

1. 選擇資料存放區。

   **資料存放區詳細資訊**頁面隨即開啟。在**標籤**區段下，會列出所有資料存放區標籤。

## 取消標記 HealthLake 資料存放區
<a name="untagresource"></a>

使用 從 HealthLake 資料存放區`UntagResource`移除標籤。下列功能表提供 AWS CLI AWS SDKs 的 AWS 管理主控台 和 程式碼範例程序。如需詳細資訊，請參閱 *AWS HealthLake API 參考*中的 [https://docs.aws.amazon.com/healthlake/latest/APIReference/API_UntagResource.html.html](https://docs.aws.amazon.com/healthlake/latest/APIReference/API_UntagResource.html.html)。

**取消標記 HealthLake 資料存放區**  
根據您的存取偏好設定選擇選單 AWS HealthLake。

### AWS CLI 和 SDKs
<a name="untagresource-cli-sdk"></a>

------
#### [ CLI ]

**AWS CLI**  
**從資料存放區移除標籤。**  
下列 `untag-resource` 範例示範如何從資料存放區移除標籤。  

```
aws healthlake untag-resource \
    --resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/b91723d65c6fdeb1d26543a49d2ed1fa" \
    --tag-keys '["key1"]'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《AWS HealthLake 開發人員指南》**中的[從資料存放區移除標籤](https://docs.aws.amazon.com/healthlake/latest/devguide/remove-tags.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/healthlake/untag-resource.html)。

------
#### [ Python ]

**適用於 Python 的 SDK (Boto3)**  

```
    @classmethod
    def from_client(cls) -> "HealthLakeWrapper":
        """
        Creates a HealthLakeWrapper instance with a default AWS HealthLake client.

        :return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
        """
        health_lake_client = boto3.client("healthlake")
        return cls(health_lake_client)


    def untag_resource(self, resource_arn: str, tag_keys: list[str]) -> None:
        """
        Untags a HealthLake resource.
        :param resource_arn: The resource ARN.
        :param tag_keys: The tag keys to remove from the resource.
        """
        try:
            self.health_lake_client.untag_resource(
                ResourceARN=resource_arn, TagKeys=tag_keys
            )
        except ClientError as err:
            logger.exception(
                "Couldn't untag resource %s. Here's why %s",
                resource_arn,
                err.response["Error"]["Message"],
            )
            raise
```
+  如需 API 詳細資訊，請參閱《AWS SDK for Python (Boto3) API 參考》**中的 [UntagResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/UntagResource)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中設定和執行。

------
#### [ SAP ABAP ]

**適用於 SAP ABAP 的開發套件**  
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/hll#code-examples)中設定和執行。

```
    TRY.
        " iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
        lo_hll->untagresource(
          iv_resourcearn = iv_resource_arn
          it_tagkeys = it_tag_keys
        ).
        MESSAGE 'Resource untagged successfully.' TYPE 'I'.
      CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
        DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_validation_ex.
      CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
        lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
        MESSAGE lv_error TYPE 'I'.
        RAISE EXCEPTION lo_notfound_ex.
    ENDTRY.
```
+  如需 API 詳細資訊，請參閱《適用於 *AWS SAP ABAP 的 SDK API 參考*》中的 [UntagResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)。

------

**可用性範例**  
找不到所需的內容嗎？ 使用此頁面右側的**提供意見回饋**連結來請求程式碼範例。

### AWS 主控台
<a name="untagresource-console"></a>

1. 登入 HealthLake 主控台上的[資料存放](https://console.aws.amazon.com/healthlake/home#/list-datastores)區頁面。

1. 選擇資料存放區。

   **資料存放區詳細資訊**頁面隨即開啟。

1. 在**標籤**區段下，選擇**管理標籤**。

   隨即開啟**管理標籤**頁面。

1. 選擇您要**移除**之標籤旁的移除。

1. 選擇**儲存**。