Beschreiben von AWS Support-Mitteilungen für einen Fall mithilfe eines AWS-SDK - AWS SDK-Codebeispiele

Weitere AWS SDK-Beispiele finden Sie im AWS Doc SDK Examples GitHub Repo.

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

Beschreiben von AWS Support-Mitteilungen für einen Fall mithilfe eines AWS-SDK

Die folgenden Codebeispiele veranschaulichen, wie Sie AWS Support-Mitteilungen beschreiben.

Beispiele für Aktionen sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Im folgenden Codebeispiel können Sie diese Aktion im Kontext sehen:

.NET
AWS SDK for .NET
Anmerkung

Auf gibt es mehr GitHub. Sie sehen das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel-Repository einrichten und ausführen.

/// <summary> /// Describe the communications for a case, optionally with a date filter. /// </summary> /// <param name="caseId">The ID of the support case.</param> /// <param name="afterTime">The optional start date for a filtered search.</param> /// <param name="beforeTime">The optional end date for a filtered search.</param> /// <returns>The list of communications for the case.</returns> public async Task<List<Communication>> DescribeCommunications(string caseId, DateTime? afterTime = null, DateTime? beforeTime = null) { var results = new List<Communication>(); var paginateCommunications = _amazonSupport.Paginators.DescribeCommunications( new DescribeCommunicationsRequest() { CaseId = caseId, AfterTime = afterTime?.ToString("s"), BeforeTime = beforeTime?.ToString("s") }); // Get the entire list using the paginator. await foreach (var communications in paginateCommunications.Communications) { results.Add(communications); } return results; }
  • Weitere API-Informationen finden Sie unter DescribeCommunications in der APIAWS SDK for .NET-Referenz für .

CLI
AWS CLI

So beschreiben Sie die neueste Kommunikation für einen Fall

Im folgenden describe-communications Beispiel wird die neueste Kommunikation für den angegebenen Support-Fall in Ihrem AWS Konto zurückgegeben.

aws support describe-communications \ --case-id "case-12345678910-2013-c4c1d2bf33c5cf47" \ --after-time "2020-03-23T21:31:47.774Z" \ --max-item 1

Ausgabe:

{ "communications": [ { "body": "I want to learn more about an AWS service.", "attachmentSet": [], "caseId": "case-12345678910-2013-c4c1d2bf33c5cf47", "timeCreated": "2020-05-12T23:12:35.000Z", "submittedBy": "Amazon Web Services" } ], "NextToken": "eyJuZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQEXAMPLE==" }

Weitere Informationen finden Sie unter Fallverwaltung im AWS Support-Benutzerhandbuch für .

Java
SDK für Java 2.x
Anmerkung

Auf gibt es mehr GitHub. Sie sehen das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel-Repository einrichten und ausführen.

public static String listCommunications(SupportClient supportClient, String caseId) { try { String attachId = null; DescribeCommunicationsRequest communicationsRequest = DescribeCommunicationsRequest.builder() .caseId(caseId) .maxResults(10) .build(); DescribeCommunicationsResponse response = supportClient.describeCommunications(communicationsRequest); List<Communication> communications = response.communications(); for (Communication comm : communications) { System.out.println("the body is: " + comm.body()); // Get the attachment id value. List<AttachmentDetails> attachments = comm.attachmentSet(); for (AttachmentDetails detail : attachments) { attachId = detail.attachmentId(); } } return attachId; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; }
  • Weitere API-Informationen finden Sie unter DescribeCommunications in der APIAWS SDK for Java 2.x-Referenz für .

JavaScript
SDK für JavaScript (v3)
Anmerkung

Auf gibt es mehr GitHub. Sie sehen das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel-Repository einrichten und ausführen.

import { DescribeCommunicationsCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; export const main = async () => { try { // Get all communications for the support case. // Filter results by providing parameters to the DescribeCommunicationsCommand. Refer // to the TypeScript definition and the API doc for more information on possible parameters. // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-support/interfaces/describecommunicationscommandinput.html const response = await client.send( new DescribeCommunicationsCommand({ // Set value to an existing case id. caseId: "CASE_ID", }), ); const text = response.communications.map((item) => item.body).join("\n"); console.log(text); return response; } catch (err) { console.error(err); } };
  • Weitere API-Informationen finden Sie unter DescribeCommunications in der APIAWS SDK for JavaScript-Referenz für .

Kotlin
SDK für Kotlin
Anmerkung

Auf gibt es mehr GitHub. Sie sehen das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel-Repository einrichten und ausführen.

suspend fun listCommunications(caseIdVal: String?): String? { val communicationsRequest = DescribeCommunicationsRequest { caseId = caseIdVal maxResults = 10 } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.describeCommunications(communicationsRequest) response.communications?.forEach { comm -> println("the body is: " + comm.body) comm.attachmentSet?.forEach { detail -> return detail.attachmentId } } } return "" }
  • Weitere API-Informationen finden Sie unter DescribeCommunications in der AWS API-Referenz zum -SDK für Kotlin.

Python
SDK für Python (Boto3)
Anmerkung

Auf gibt es mehr GitHub. Sie sehen das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel-Repository einrichten und ausführen.

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_all_case_communications(self, case_id): """ Describe all the communications for a case using a paginator. :param case_id: The ID of the case. :return: The communications for the case. """ try: communications = [] paginator = self.support_client.get_paginator("describe_communications") for page in paginator.paginate(caseId=case_id): communications += page["communications"] 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 describe communications. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return communications
  • Weitere API-Informationen finden Sie unter DescribeCommunications in der AWS API-Referenz zum -SDK für Python (Boto3).