本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或AddCommunicationToCase
一起使用 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详细信息,请参阅 “AWS SDK for .NET API参考 AddCommunicationToCase” 中的。
-
- 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 Support 用户指南》中的案例管理。
-
有关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详细信息,请参阅 “AWS SDK for Java 2.x API参考 AddCommunicationToCase” 中的。
-
- 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详细信息,请参阅 “AWS SDK for JavaScript API参考 AddCommunicationToCase” 中的。
-
- 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
中的 Kotlin AWS SDK API 参考。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:将电子邮件的正文添加到指定案例中。
Add-ASACommunicationToCase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47" -CommunicationBody "Some text about the case"
示例 2:将电子邮件通信的正文添加到指定案例中,再加上电子邮件抄送行中包含的一个或多个电子邮件地址。
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适用于 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 SDKPython (Boto3) API 参考。
-
有关 AWS SDK开发者指南和代码示例的完整列表,请参阅AWS Support 与 AWS SDK 一起使用。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。