标记资源 - AWS HealthImaging

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

标记资源

使用TagResource操作在中标记数据存储图像集AWS HealthImaging。以下代码示例描述了如何将TagResource操作与 AWS Management Console AWS CLI、和一起使用 AWS SDKs。有关更多信息,请参阅AWS 一般参考 指南中的为AWS 资源添加标签

为资源添加标签

根据您的访问偏好选择菜单AWS HealthImaging。

  1. 打开 HealthImaging 控制台数据存储页面

  2. 选择数据存储。

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

  3. 选择详细信息选项卡。

  4. 标签 部分中,选择 管理标签

    将打开管理标签页面。

  5. 选择 添加新标签

  6. 输入一个 和可选的 (可选)。

  7. 选择 保存更改

CLI
AWS CLI

例 1:标记数据存储

以下 tag-resource 代码示例可标记数据存储。

aws medical-imaging tag-resource \ --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012" \ --tags '{"Deployment":"Development"}'

此命令不生成任何输出。

例 2:标记影像集

以下 tag-resource 代码示例可标记影像集。

aws medical-imaging tag-resource \ --resource-arn "arn:aws:medical-imaging:us-east-1:123456789012:datastore/12345678901234567890123456789012/imageset/18f88ac7870584f58d56256646b4d92b" \ --tags '{"Deployment":"Development"}'

此命令不生成任何输出。

有关更多信息,请参阅《AWS HealthImaging 开发人员指南》 AWS HealthImaging中的使用为资源添加标签

  • 有关API详细信息,请参阅AWS CLI 命令参考TagResource中的。

Java
SDK适用于 Java 2.x
public static void tagMedicalImagingResource(MedicalImagingClient medicalImagingClient, String resourceArn, Map<String, String> tags) { try { TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceArn) .tags(tags) .build(); medicalImagingClient.tagResource(tagResourceRequest); System.out.println("Tags have been added to the resource."); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • 有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 TagResource” 中的。

注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整实例,了解如何进行设置和运行。

JavaScript
SDK对于 JavaScript (v3)
import { TagResourceCommand } 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 {Record<string,string>} tags - The tags to add to the resource as JSON. * - For example: {"Deployment" : "Development"} */ export const tagResource = async ( resourceArn = "arn:aws:medical-imaging:us-east-1:xxxxxx:datastore/xxxxx/imageset/xxx", tags = {} ) => { const response = await medicalImagingClient.send( new TagResourceCommand({ resourceArn: resourceArn, tags: tags }) ); console.log(response); // { // '$metadata': { // httpStatusCode: 204, // requestId: '8a6de9a3-ec8e-47ef-8643-473518b19d45', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // } // } return response; };
  • 有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 TagResource” 中的。

注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整实例,了解如何进行设置和运行。

Python
SDK适用于 Python (Boto3)
class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def tag_resource(self, resource_arn, tags): """ Tag a resource. :param resource_arn: The ARN of the resource. :param tags: The tags to apply. """ try: self.health_imaging_client.tag_resource(resourceArn=resource_arn, tags=tags) except ClientError as err: logger.error( "Couldn't tag 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详细信息,请参阅TagResource中的 AWS SDKPython (Boto3) API 参考。

注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整实例,了解如何进行设置和运行。