または DescribeAttachmentAWS SDKで を使用する CLI - AWS SDK コード例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

または DescribeAttachmentAWS SDKで を使用する CLI

以下のコード例は、DescribeAttachment の使用方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

.NET
AWS SDK for .NET
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

/// <summary> /// Get description of a specific attachment. /// </summary> /// <param name="attachmentId">Id of the attachment, usually fetched by describing the communications of a case.</param> /// <returns>The attachment object.</returns> public async Task<Attachment> DescribeAttachment(string attachmentId) { var response = await _amazonSupport.DescribeAttachmentAsync( new DescribeAttachmentRequest() { AttachmentId = attachmentId }); return response.Attachment; }
  • API 詳細については、「 リファレンスDescribeAttachment」の「」を参照してください。 AWS SDK for .NET API

CLI
AWS CLI

添付ファイルについて説明する

次の describe-attachment の例では、指定された ID の添付ファイルに関する情報を返します。

aws support describe-attachment \ --attachment-id "attachment-KBnjRNrePd9D6Jx0-Mm00xZuDEaL2JAj_0-gJv9qqDooTipsz3V1Nb19rCfkZneeQeDPgp8X1iVJyHH7UuhZDdNeqGoduZsPrAhyMakqlc60-iJjL5HqyYGiT1FG8EXAMPLE"

出力:

{ "attachment": { "fileName": "troubleshoot-screenshot.png", "data": "base64-blob" } }

詳細については、「AWS サポートユーザーガイド」の「ケース管理」を参照してください。

  • API 詳細については、「 コマンドリファレンスDescribeAttachment」の「」を参照してください。 AWS CLI

Java
SDK for Java 2.x
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

public static void describeAttachment(SupportClient supportClient, String attachId) { try { DescribeAttachmentRequest attachmentRequest = DescribeAttachmentRequest.builder() .attachmentId(attachId) .build(); DescribeAttachmentResponse response = supportClient.describeAttachment(attachmentRequest); System.out.println("The name of the file is " + response.attachment().fileName()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
  • API 詳細については、「 リファレンスDescribeAttachment」の「」を参照してください。 AWS SDK for Java 2.x API

JavaScript
SDK の JavaScript (v3)
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

import { DescribeAttachmentCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; export const main = async () => { try { // Get the metadata and content of an attachment. const response = await client.send( new DescribeAttachmentCommand({ // Set value to an existing attachment id. // Use DescribeCommunications or DescribeCases to find an attachment id. attachmentId: "ATTACHMENT_ID", }), ); console.log(response.attachment?.fileName); return response; } catch (err) { console.error(err); } };
  • API 詳細については、「 リファレンスDescribeAttachment」の「」を参照してください。 AWS SDK for JavaScript API

Kotlin
SDK Kotlin 用
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

suspend fun describeAttachment(attachId: String?) { val attachmentRequest = DescribeAttachmentRequest { attachmentId = attachId } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.describeAttachment(attachmentRequest) println("The name of the file is ${response.attachment?.fileName}") } }
  • API 詳細については、Kotlin リファレンス DescribeAttachmentの「」の「」を参照してください。 AWS SDK API

Python
SDK for Python (Boto3)
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

class SupportWrapper: """Encapsulates Support actions.""" def __init__(self, support_client): """ :param support_client: A Boto3 Support client. """ self.support_client = support_client @classmethod def from_client(cls): """ Instantiates this class from a Boto3 client. """ support_client = boto3.client("support") return cls(support_client) def describe_attachment(self, attachment_id): """ Get information about an attachment by its attachmentID. :param attachment_id: The ID of the attachment. :return: The name of the attached file. """ try: response = self.support_client.describe_attachment( attachmentId=attachment_id ) attached_file = response["attachment"]["fileName"] except ClientError as err: if err.response["Error"]["Code"] == "SubscriptionRequiredException": logger.info( "You must have a Business, Enterprise On-Ramp, or Enterprise Support " "plan to use the AWS Support API. \n\tPlease upgrade your subscription to run these " "examples." ) else: logger.error( "Couldn't get attachment description. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return attached_file
  • API 詳細については、「 for Python (Boto3) リファレンスDescribeAttachment」の「」を参照してください。 AWS SDK API