Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation AddCommunicationToCase
avec un AWS SDK ou une CLI
Les exemples de code suivants illustrent comment utiliser AddCommunicationToCase
.
Les exemples d’actions sont des extraits de code de programmes de plus grande envergure et doivent être exécutés en contexte. Vous pouvez voir cette action en contexte dans l’exemple de code suivant :
- .NET
-
- AWS SDK for .NET
-
Note
Il y en a plus sur GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code 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; }
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCaseà la section Référence des AWS SDK for .NET API.
-
- CLI
-
- AWS CLI
-
Pour ajouter une communication à un dossier
L'
add-communication-to-case
exemple suivant ajoute des communications à une demande d'assistance dans votre AWS compte.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"
Sortie :
{ "result": true }
Pour plus d'informations, consultez la section Gestion des dossiers dans le Guide de l'utilisateur du AWS Support.
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCase
à la section Référence des AWS CLI commandes.
-
- Java
-
- SDK pour Java 2.x
-
Note
Il y en a plus sur GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code 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); } }
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCaseà la section Référence des AWS SDK for Java 2.x API.
-
- JavaScript
-
- SDK pour JavaScript (v3)
-
Note
Il y en a plus sur GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code 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); } };
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCaseà la section Référence des AWS SDK for JavaScript API.
-
- Kotlin
-
- SDK pour Kotlin
-
Note
Il y en a plus sur GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code 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") } } }
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCase
à la section AWS SDK pour la référence de l'API Kotlin.
-
- PowerShell
-
- Outils pour PowerShell
-
Exemple 1 : ajoute le corps d'une communication par e-mail au cas spécifié.
Add-ASACommunicationToCase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47" -CommunicationBody "Some text about the case"
Exemple 2 : ajoute le corps d'une communication par e-mail au cas spécifié, plus une ou plusieurs adresses e-mail contenues dans la ligne CC de l'e-mail.
Add-ASACommunicationToCase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47" -CcEmailAddress @("email1@address.com", "email2@address.com") -CommunicationBody "Some text about the case"
-
Pour plus de détails sur l'API, reportez-vous AddCommunicationToCaseà la section Référence des AWS Tools for PowerShell applets de commande.
-
- Python
-
- SDK pour Python (Boto3)
-
Note
Il y en a plus sur GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code 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
-
Pour plus de détails sur l'API, consultez AddCommunicationToCasele AWS manuel de référence de l'API SDK for Python (Boto3).
-
Pour obtenir la liste complète des guides de développement du AWS SDK et des exemples de code, consultezUtilisation AWS Support avec un AWS SDK. Cette rubrique comprend également des informations sur le démarrage et sur les versions précédentes de SDK.