

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 标记 HealthLake 数据存储
<a name="managing-data-stores-tagging"></a>

您可以以标签的形式将元 HealthLake 数据分配给数据存储。每个标签都是由用户定义的键和值组成的标签。标签可帮助您管理、识别、组织、搜索和筛选数据存储。

**重要提示**  
请勿在标签中存储受保护的健康信息（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 管理控制台 和 AWS CLI 和的代码示例 AWS SDKs。有关更多信息，请参阅《AWS HealthLake API Reference》**中的 [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 的详细信息，请参阅适用[TagResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/TagResource)于 *Python 的AWS SDK (Boto3) API 参考*。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中查找完整示例，了解如何进行设置和运行。

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

**适用于 SAP ABAP 的 SDK**  
 还有更多相关信息 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 的详细信息，请参阅适用[TagResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)于 S *AP 的AWS SDK ABAP API 参考*。

------

**示例可用性**  
找不到所需的内容？ 使用本页右侧边栏上的 “**提供反馈**” 链接请求代码示例。

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

1. 登录 HealthLake 控制台上的[数据存储](https://console.aws.amazon.com/healthlake/home#/list-datastores)页面。

1. 选择数据存储。

   **数据存储详细信息**页面将会打开。

1. 在 **标签** 部分中，选择 **管理标签**。

   将打开**管理标签**页面。

1. 选择 **添加新标签**。

1. 输入一个 **键**和可选的 **值**（可选）。

1. 选择**保存**。

## 列出 HealthLake 数据存储的标签
<a name="listtagsforresource"></a>

`ListTagsForResource`用于列出 HealthLake 数据存储的标签。以下菜单提供了操作步骤 AWS 管理控制台 和 AWS CLI 和的代码示例 AWS SDKs。有关更多信息，请参阅《AWS HealthLake API Reference》**中的 [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 开发人员指南》[AWS HealthLake中的为资源添加标签](https://docs.aws.amazon.com/healthlake/latest/devguide/tagging.html)。  
+  有关 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 的详细信息，请参阅适用[ListTagsForResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/ListTagsForResource)于 *Python 的AWS SDK (Boto3) API 参考*。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中查找完整示例，了解如何进行设置和运行。

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

**适用于 SAP ABAP 的 SDK**  
 还有更多相关信息 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 的详细信息，请参阅适用[ListTagsForResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)于 S *AP 的AWS SDK ABAP API 参考*。

------

**示例可用性**  
找不到所需的内容？ 使用本页右侧边栏上的 “**提供反馈**” 链接请求代码示例。

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

1. 登录 HealthLake 控制台上的[数据存储](https://console.aws.amazon.com/healthlake/home#/list-datastores)页面。

1. 选择数据存储。

   **数据存储详细信息**页面将会打开。在**标签**部分下，列出了所有数据存储标签。

## 取消标记数据存储 HealthLake
<a name="untagresource"></a>

`UntagResource`用于从 HealthLake 数据存储中移除标签。以下菜单提供了操作步骤 AWS 管理控制台 和 AWS CLI 和的代码示例 AWS SDKs。有关更多信息，请参阅《AWS HealthLake API Reference》**中的 [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 的详细信息，请参阅适用[UntagResource](https://docs.aws.amazon.com/goto/boto3/healthlake-2017-07-01/UntagResource)于 *Python 的AWS SDK (Boto3) API 参考*。
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/healthlake#code-examples)中查找完整示例，了解如何进行设置和运行。

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

**适用于 SAP ABAP 的 SDK**  
 还有更多相关信息 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 的详细信息，请参阅适用[UntagResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)于 S *AP 的AWS SDK ABAP API 参考*。

------

**示例可用性**  
找不到所需的内容？ 使用本页右侧边栏上的 “**提供反馈**” 链接请求代码示例。

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

1. 登录 HealthLake 控制台上的[数据存储](https://console.aws.amazon.com/healthlake/home#/list-datastores)页面。

1. 选择数据存储。

   **数据存储详细信息**页面将会打开。

1. 在 **标签** 部分中，选择 **管理标签**。

   将打开**管理标签**页面。

1. 在标签旁选择 **移除**，以移除标签。

1. 选择**保存**。