

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

# 取消標記資源
<a name="untag-resource"></a>

使用 [https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_UntagResource.html](https://docs.aws.amazon.com/healthimaging/latest/APIReference/API_UntagResource.html)動作取消標記 AWS HealthImaging 中的[資料存放](getting-started-concepts.md#concept-data-store)區和[映像集](getting-started-concepts.md#concept-image-set)。下列程式碼範例說明如何搭配 AWS 管理主控台 AWS CLI、 和 AWS SDKs 使用 `UntagResource`動作。如需詳細資訊，請參閱《 *AWS 一般參考 指南*》中的[標記您的 AWS 資源](https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html)。

**取消標記資源**  
根據您對 AWS HealthImaging 的存取偏好設定，選擇選單。

## AWS 主控台
<a name="code-example-console-untag-resource"></a>

1. 開啟 HealthImaging 主控台[資料存放區頁面](https://console.aws.amazon.com/medical-imaging/home#/dataStores)。

1. 選擇資料存放區。

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

1. 選擇**詳細資訊**索引標籤。

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

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

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

1. 選擇**儲存變更**。

## AWS CLI 和 SDKs
<a name="code-example-cli-sdk-untag-resource"></a>

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

**AWS CLI**  
**範例 1：取消標記資料存放區**  
下列 `untag-resource` 程式碼範例會取消標記資料存放區。  

```
aws medical-imaging untag-resource \
    --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012" \
    --tag-keys '["Deployment"]'
```
此命令不會產生輸出。  
**範例 2：取消標記影像集**  
下列 `untag-resource` 程式碼範例會取消標記影像集。  

```
aws medical-imaging untag-resource \
    --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b" \
    --tag-keys '["Deployment"]'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱 [AWS HealthImaging 開發人員指南中的使用 HealthImaging 標記資源](https://docs.aws.amazon.com/healthimaging/latest/devguide/tagging.html)。 *AWS HealthImaging *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/medical-imaging/untag-resource.html)。

------
#### [ Java ]

**適用於 Java 2.x 的 SDK**  

```
    public static void untagMedicalImagingResource(MedicalImagingClient medicalImagingClient,
            String resourceArn,
            Collection<String> tagKeys) {
        try {
            UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder()
                    .resourceArn(resourceArn)
                    .tagKeys(tagKeys)
                    .build();

            medicalImagingClient.untagResource(untagResourceRequest);

            System.out.println("Tags have been removed from the resource.");
        } catch (MedicalImagingException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
    }
```
+  如需 API 詳細資訊，請參閱《AWS SDK for Java 2.x API 參考》**中的 [UntagResource](https://docs.aws.amazon.com/goto/SdkForJavaV2/medical-imaging-2023-07-19/UntagResource)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/medicalimaging#code-examples)中設定和執行。

------
#### [ JavaScript ]

**適用於 JavaScript (v3) 的 SDK**  

```
import { UntagResourceCommand } 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 {string[]} tagKeys - The keys of the tags to remove.
 */
export const untagResource = async (
  resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx",
  tagKeys = [],
) => {
  const response = await medicalImagingClient.send(
    new UntagResourceCommand({ resourceArn: resourceArn, tagKeys: tagKeys }),
  );
  console.log(response);
  // {
  //     '$metadata': {
  //        httpStatusCode: 204,
  //         requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45',
  //         extendedRequestId: undefined,
  //         cfId: undefined,
  //         attempts: 1,
  //         totalRetryDelay: 0
  //    }
  // }

  return response;
};
```
+  如需 API 詳細資訊，請參閱《適用於 JavaScript 的 AWS SDK API 參考》**中的 [UntagResource](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/medical-imaging/command/UntagResourceCommand)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/medical-imaging#code-examples)中設定和執行。

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

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

```
class MedicalImagingWrapper:
    def __init__(self, health_imaging_client):
        self.health_imaging_client = health_imaging_client


    def untag_resource(self, resource_arn, tag_keys):
        """
        Untag a resource.

        :param resource_arn: The ARN of the resource.
        :param tag_keys: The tag keys to remove.
        """
        try:
            self.health_imaging_client.untag_resource(
                resourceArn=resource_arn, tagKeys=tag_keys
            )
        except ClientError as err:
            logger.error(
                "Couldn't untag resource. Here's why: %s: %s",
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
```
下列程式碼會執行個體化 MedicalImagingWrapper 物件。  

```
    client = boto3.client("medical-imaging")
    medical_imaging_wrapper = MedicalImagingWrapper(client)
```
+  如需 API 詳細資訊，請參閱《AWS SDK for Python (Boto3) API 參考》**中的 [UntagResource](https://docs.aws.amazon.com/goto/boto3/medical-imaging-2023-07-19/UntagResource)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/medical-imaging#code-examples)中設定和執行。

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

**適用於 SAP ABAP 的開發套件**  

```
    TRY.
        " iv_resource_arn = 'arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012'
        lo_mig->untagresource(
          iv_resourcearn = iv_resource_arn
          it_tagkeys = it_tag_keys ).
        MESSAGE 'Resource untagged successfully.' TYPE 'I'.
      CATCH /aws1/cx_migaccessdeniedex.
        MESSAGE 'Access denied.' TYPE 'I'.
      CATCH /aws1/cx_miginternalserverex.
        MESSAGE 'Internal server error.' TYPE 'I'.
      CATCH /aws1/cx_migresourcenotfoundex.
        MESSAGE 'Resource not found.' TYPE 'I'.
      CATCH /aws1/cx_migthrottlingex.
        MESSAGE 'Request throttled.' TYPE 'I'.
      CATCH /aws1/cx_migvalidationex.
        MESSAGE 'Validation error.' TYPE 'I'.
    ENDTRY.
```
+  如需 API 詳細資訊，請參閱《適用於 *AWS SAP ABAP 的 SDK API 參考*》中的 [UntagResource](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)。
 GitHub 上提供更多範例。尋找完整範例，並了解如何在 [AWS 程式碼範例儲存庫](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/mig#code-examples)中設定和執行。

------

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