Describe Amazon Web Services Support communications for a case using an Amazon SDK - Amazon Web Services Support
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Describe Amazon Web Services Support communications for a case using an Amazon SDK

The following code examples show how to describe Amazon Web Services Support communications for a case.

.NET
Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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("G"), BeforeTime = beforeTime?.ToString("G") }); // Get the entire list using the paginator. await foreach (var communications in paginateCommunications.Communications) { results.Add(communications); } return results; }
Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

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 ""; }
JavaScript
SDK for JavaScript V3
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

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); } };
Kotlin
SDK for Kotlin
Note

This is prerelease documentation for a feature in preview release. It is subject to change.

Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

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 "" }

For a complete list of Amazon SDK developer guides and code examples, see Using Amazon Web Services Support with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.