本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AddCommunicationToCase
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 AddCommunicationToCase
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 /// <summary> /// Add communication to a case, including optional attachment set ID and CC email addresses. /// </summary> /// <param name="caseId">Id for the support case.</param> /// <param name="body">Body text of the communication.</param> /// <param name="attachmentSetId">Optional Id for an attachment set.</param> /// <param name="ccEmailAddresses">Optional list of CC email addresses.</param> /// <returns>True if successful.</returns> public async Task<bool> AddCommunicationToCase(string caseId, string body, string? attachmentSetId = null, List<string>? ccEmailAddresses = null) { var response = await _amazonSupport.AddCommunicationToCaseAsync( new AddCommunicationToCaseRequest() { CaseId = caseId, CommunicationBody = body, AttachmentSetId = attachmentSetId, CcEmailAddresses = ccEmailAddresses }); return response.Result; }
-
如需API詳細資訊,請參閱 參考 AddCommunicationToCase中的 。 AWS SDK for .NET API
-
- CLI
-
- AWS CLI
-
將通訊新增至案例
下列
add-communication-to-case
範例會將通訊新增至您 AWS 帳戶中的支援案例。aws support add-communication-to-case \ --case-id
"case-12345678910-2013-c4c1d2bf33c5cf47"
\ --communication-body"I'm attaching a set of images to this case."
\ --cc-email-addresses"myemail@example.com"
\ --attachment-set-id"as-2f5a6faa2a4a1e600-mu-nk5xQlBr70-G1cUos5LZkd38KOAHZa9BMDVzNEXAMPLE"
輸出:
{ "result": true }
如需詳細資訊,請參閱 AWS 支援使用者指南 中的案例管理。
-
如需API詳細資訊,請參閱 命令參考 AddCommunicationToCase
中的 。 AWS CLI
-
- Java
-
- SDK 適用於 Java 2.x
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 public static void addAttachSupportCase(SupportClient supportClient, String caseId, String attachmentSetId) { try { AddCommunicationToCaseRequest caseRequest = AddCommunicationToCaseRequest.builder() .caseId(caseId) .attachmentSetId(attachmentSetId) .communicationBody("Please refer to attachment for details.") .build(); AddCommunicationToCaseResponse response = supportClient.addCommunicationToCase(caseRequest); if (response.result()) System.out.println("You have successfully added a communication to an AWS Support case"); else System.out.println("There was an error adding the communication to an AWS Support case"); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
-
如需API詳細資訊,請參閱 參考 AddCommunicationToCase中的 。 AWS SDK for Java 2.x API
-
- JavaScript
-
- SDK 適用於 JavaScript (v3)
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 import { AddCommunicationToCaseCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; export const main = async () => { let attachmentSetId; try { // Add a communication to a case. const response = await client.send( new AddCommunicationToCaseCommand({ communicationBody: "Adding an attachment.", // Set value to an existing support case id. caseId: "CASE_ID", // Optional. Set value to an existing attachment set id to add attachments to the case. attachmentSetId, }), ); console.log(response); return response; } catch (err) { console.error(err); } };
-
如需API詳細資訊,請參閱 參考 AddCommunicationToCase中的 。 AWS SDK for JavaScript API
-
- Kotlin
-
- SDK 適用於 Kotlin
-
注意
還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 suspend fun addAttachSupportCase( caseIdVal: String?, attachmentSetIdVal: String?, ) { val caseRequest = AddCommunicationToCaseRequest { caseId = caseIdVal attachmentSetId = attachmentSetIdVal communicationBody = "Please refer to attachment for details." } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.addCommunicationToCase(caseRequest) if (response.result) { println("You have successfully added a communication to an AWS Support case") } else { println("There was an error adding the communication to an AWS Support case") } } }
-
如需API詳細資訊,請參閱AddCommunicationToCase
中的 AWS SDK for Kotlin API參考 。
-
- PowerShell
-
- 適用於 的工具 PowerShell
-
範例 1:將電子郵件通訊的內文新增至指定的案例。
Add-ASACommunicationToCase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47" -CommunicationBody "Some text about the case"
範例 2:將電子郵件通訊的內文新增至指定的案例,以及電子郵件 CC 行中包含的一或多個電子郵件地址。
Add-ASACommunicationToCase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47" -CcEmailAddress @("email1@address.com", "email2@address.com") -CommunicationBody "Some text about the case"
-
如需API詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 AddCommunicationToCase中的 。
-
- 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 add_communication_to_case(self, attachment_set_id, case_id): """ Add a communication and an attachment set to a case. :param attachment_set_id: The ID of an existing attachment set. :param case_id: The ID of the case. """ try: self.support_client.add_communication_to_case( caseId=case_id, communicationBody="This is an example communication added to a support case.", attachmentSetId=attachment_set_id, ) 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 add communication. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise
-
如需API詳細資訊,請參閱 AddCommunicationToCase 中的 AWS SDK for Python (Boto3) API參考 。
-
如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 搭 AWS Support 配 AWS SDK 使用。本主題也包含有關入門的資訊,以及先前SDK版本的詳細資訊。