AWS Support exemples d'utilisation SDK pour Java 2.x - Exemples de code de l'AWS SDK

D'autres AWS SDK exemples sont disponibles dans le GitHub dépôt AWS Doc SDK Examples.

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.

AWS Support exemples d'utilisation SDK pour Java 2.x

Les exemples de code suivants vous montrent comment effectuer des actions et implémenter des scénarios courants à l'aide du AWS SDK for Java 2.x with AWS Support.

Les principes de base sont des exemples de code qui vous montrent comment effectuer les opérations essentielles au sein d'un service.

Les actions sont des extraits de code de programmes plus larges et doivent être exécutées dans leur contexte. Les actions vous indiquent comment appeler des fonctions de service individuelles, mais vous pouvez les visualiser dans leur contexte dans les scénarios correspondants.

Chaque exemple inclut un lien vers le code source complet, où vous trouverez des instructions sur la façon de configurer et d'exécuter le code en contexte.

Mise en route

Les exemples de code suivants montrent comment démarrer avec AWS Support.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.support.SupportClient; import software.amazon.awssdk.services.support.model.Category; import software.amazon.awssdk.services.support.model.DescribeServicesRequest; import software.amazon.awssdk.services.support.model.DescribeServicesResponse; import software.amazon.awssdk.services.support.model.Service; import software.amazon.awssdk.services.support.model.SupportException; import java.util.ArrayList; import java.util.List; /** * Before running this Java (v2) code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html * * In addition, you must have the AWS Business Support Plan to use the AWS * Support Java API. For more information, see: * * https://aws.amazon.com/premiumsupport/plans/ * * This Java example performs the following task: * * 1. Gets and displays available services. * * * NOTE: To see multiple operations, see SupportScenario. */ public class HelloSupport { public static void main(String[] args) { Region region = Region.US_WEST_2; SupportClient supportClient = SupportClient.builder() .region(region) .build(); System.out.println("***** Step 1. Get and display available services."); displayServices(supportClient); } // Return a List that contains a Service name and Category name. public static void displayServices(SupportClient supportClient) { try { DescribeServicesRequest servicesRequest = DescribeServicesRequest.builder() .language("en") .build(); DescribeServicesResponse response = supportClient.describeServices(servicesRequest); List<Service> services = response.services(); System.out.println("Get the first 10 services"); int index = 1; for (Service service : services) { if (index == 11) break; System.out.println("The Service name is: " + service.name()); // Display the Categories for this service. List<Category> categories = service.categories(); for (Category cat : categories) { System.out.println("The category name is: " + cat.name()); } index++; } } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } }
  • Pour API plus de détails, voir DescribeServicesla section AWS SDK for Java 2.x APIRéférence.

Principes de base

L’exemple de code suivant illustre comment :

  • Obtenez et affichez les services disponibles et les niveaux de gravité des dossiers.

  • Créez un dossier de support en utilisant un service, une catégorie et un niveau de gravité sélectionnés.

  • Obtenez et affichez une liste des dossiers ouverts pour la journée en cours.

  • Ajoutez un ensemble de pièces jointes et une communication au nouveau dossier.

  • Décrivez la nouvelle pièce jointe et la nouvelle communication relatives au dossier.

  • Résolvez le dossier.

  • Obtenez et affichez la liste des dossiers ouverts pour la journée en cours.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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.

Exécutez diverses AWS Support opérations.

import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.support.SupportClient; import software.amazon.awssdk.services.support.model.AddAttachmentsToSetResponse; import software.amazon.awssdk.services.support.model.AddCommunicationToCaseRequest; import software.amazon.awssdk.services.support.model.AddCommunicationToCaseResponse; import software.amazon.awssdk.services.support.model.Attachment; import software.amazon.awssdk.services.support.model.AttachmentDetails; import software.amazon.awssdk.services.support.model.CaseDetails; import software.amazon.awssdk.services.support.model.Category; import software.amazon.awssdk.services.support.model.Communication; import software.amazon.awssdk.services.support.model.CreateCaseRequest; import software.amazon.awssdk.services.support.model.CreateCaseResponse; import software.amazon.awssdk.services.support.model.DescribeAttachmentRequest; import software.amazon.awssdk.services.support.model.DescribeAttachmentResponse; import software.amazon.awssdk.services.support.model.DescribeCasesRequest; import software.amazon.awssdk.services.support.model.DescribeCasesResponse; import software.amazon.awssdk.services.support.model.DescribeCommunicationsRequest; import software.amazon.awssdk.services.support.model.DescribeCommunicationsResponse; import software.amazon.awssdk.services.support.model.DescribeServicesRequest; import software.amazon.awssdk.services.support.model.DescribeServicesResponse; import software.amazon.awssdk.services.support.model.DescribeSeverityLevelsRequest; import software.amazon.awssdk.services.support.model.DescribeSeverityLevelsResponse; import software.amazon.awssdk.services.support.model.ResolveCaseRequest; import software.amazon.awssdk.services.support.model.ResolveCaseResponse; import software.amazon.awssdk.services.support.model.Service; import software.amazon.awssdk.services.support.model.SeverityLevel; import software.amazon.awssdk.services.support.model.SupportException; import software.amazon.awssdk.services.support.model.AddAttachmentsToSetRequest; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; /** * Before running this Java (v2) code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html * * In addition, you must have the AWS Business Support Plan to use the AWS * Support Java API. For more information, see: * * https://aws.amazon.com/premiumsupport/plans/ * * This Java example performs the following tasks: * * 1. Gets and displays available services. * 2. Gets and displays severity levels. * 3. Creates a support case by using the selected service, category, and * severity level. * 4. Gets a list of open cases for the current day. * 5. Creates an attachment set with a generated file. * 6. Adds a communication with the attachment to the support case. * 7. Lists the communications of the support case. * 8. Describes the attachment set included with the communication. * 9. Resolves the support case. * 10. Gets a list of resolved cases for the current day. */ public class SupportScenario { public static final String DASHES = new String(new char[80]).replace("\0", "-"); public static void main(String[] args) { final String usage = """ Usage: <fileAttachment>Where: fileAttachment - The file can be a simple saved .txt file to use as an email attachment.\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String fileAttachment = args[0]; Region region = Region.US_WEST_2; SupportClient supportClient = SupportClient.builder() .region(region) .build(); System.out.println(DASHES); System.out.println("***** Welcome to the AWS Support case example scenario."); System.out.println(DASHES); System.out.println(DASHES); System.out.println("1. Get and display available services."); List<String> sevCatList = displayServices(supportClient); System.out.println(DASHES); System.out.println(DASHES); System.out.println("2. Get and display Support severity levels."); String sevLevel = displaySevLevels(supportClient); System.out.println(DASHES); System.out.println(DASHES); System.out.println("3. Create a support case using the selected service, category, and severity level."); String caseId = createSupportCase(supportClient, sevCatList, sevLevel); if (caseId.compareTo("") == 0) { System.out.println("A support case was not successfully created!"); System.exit(1); } else System.out.println("Support case " + caseId + " was successfully created!"); System.out.println(DASHES); System.out.println(DASHES); System.out.println("4. Get open support cases."); getOpenCase(supportClient); System.out.println(DASHES); System.out.println(DASHES); System.out.println("5. Create an attachment set with a generated file to add to the case."); String attachmentSetId = addAttachment(supportClient, fileAttachment); System.out.println("The Attachment Set id value is" + attachmentSetId); System.out.println(DASHES); System.out.println(DASHES); System.out.println("6. Add communication with the attachment to the support case."); addAttachSupportCase(supportClient, caseId, attachmentSetId); System.out.println(DASHES); System.out.println(DASHES); System.out.println("7. List the communications of the support case."); String attachId = listCommunications(supportClient, caseId); System.out.println("The Attachment id value is" + attachId); System.out.println(DASHES); System.out.println(DASHES); System.out.println("8. Describe the attachment set included with the communication."); describeAttachment(supportClient, attachId); System.out.println(DASHES); System.out.println(DASHES); System.out.println("9. Resolve the support case."); resolveSupportCase(supportClient, caseId); System.out.println(DASHES); System.out.println(DASHES); System.out.println("10. Get a list of resolved cases for the current day."); getResolvedCase(supportClient); System.out.println(DASHES); System.out.println(DASHES); System.out.println("***** This Scenario has successfully completed"); System.out.println(DASHES); } public static void getResolvedCase(SupportClient supportClient) { try { // Specify the start and end time. Instant now = Instant.now(); java.time.LocalDate.now(); Instant yesterday = now.minus(1, ChronoUnit.DAYS); DescribeCasesRequest describeCasesRequest = DescribeCasesRequest.builder() .maxResults(30) .afterTime(yesterday.toString()) .beforeTime(now.toString()) .includeResolvedCases(true) .build(); DescribeCasesResponse response = supportClient.describeCases(describeCasesRequest); List<CaseDetails> cases = response.cases(); for (CaseDetails sinCase : cases) { if (sinCase.status().compareTo("resolved") == 0) System.out.println("The case status is " + sinCase.status()); } } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } public static void resolveSupportCase(SupportClient supportClient, String caseId) { try { ResolveCaseRequest caseRequest = ResolveCaseRequest.builder() .caseId(caseId) .build(); ResolveCaseResponse response = supportClient.resolveCase(caseRequest); System.out.println("The status of case " + caseId + " is " + response.finalCaseStatus()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } public static void describeAttachment(SupportClient supportClient, String attachId) { try { DescribeAttachmentRequest attachmentRequest = DescribeAttachmentRequest.builder() .attachmentId(attachId) .build(); DescribeAttachmentResponse response = supportClient.describeAttachment(attachmentRequest); System.out.println("The name of the file is " + response.attachment().fileName()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } 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 ""; } 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); } } public static String addAttachment(SupportClient supportClient, String fileAttachment) { try { File myFile = new File(fileAttachment); InputStream sourceStream = new FileInputStream(myFile); SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream); Attachment attachment = Attachment.builder() .fileName(myFile.getName()) .data(sourceBytes) .build(); AddAttachmentsToSetRequest setRequest = AddAttachmentsToSetRequest.builder() .attachments(attachment) .build(); AddAttachmentsToSetResponse response = supportClient.addAttachmentsToSet(setRequest); return response.attachmentSetId(); } catch (SupportException | FileNotFoundException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; } public static void getOpenCase(SupportClient supportClient) { try { // Specify the start and end time. Instant now = Instant.now(); java.time.LocalDate.now(); Instant yesterday = now.minus(1, ChronoUnit.DAYS); DescribeCasesRequest describeCasesRequest = DescribeCasesRequest.builder() .maxResults(20) .afterTime(yesterday.toString()) .beforeTime(now.toString()) .build(); DescribeCasesResponse response = supportClient.describeCases(describeCasesRequest); List<CaseDetails> cases = response.cases(); for (CaseDetails sinCase : cases) { System.out.println("The case status is " + sinCase.status()); System.out.println("The case Id is " + sinCase.caseId()); System.out.println("The case subject is " + sinCase.subject()); } } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } public static String createSupportCase(SupportClient supportClient, List<String> sevCatList, String sevLevel) { try { String serviceCode = sevCatList.get(0); String caseCat = sevCatList.get(1); CreateCaseRequest caseRequest = CreateCaseRequest.builder() .categoryCode(caseCat.toLowerCase()) .serviceCode(serviceCode.toLowerCase()) .severityCode(sevLevel.toLowerCase()) .communicationBody("Test issue with " + serviceCode.toLowerCase()) .subject("Test case, please ignore") .language("en") .issueType("technical") .build(); CreateCaseResponse response = supportClient.createCase(caseRequest); return response.caseId(); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; } public static String displaySevLevels(SupportClient supportClient) { try { DescribeSeverityLevelsRequest severityLevelsRequest = DescribeSeverityLevelsRequest.builder() .language("en") .build(); DescribeSeverityLevelsResponse response = supportClient.describeSeverityLevels(severityLevelsRequest); List<SeverityLevel> severityLevels = response.severityLevels(); String levelName = null; for (SeverityLevel sevLevel : severityLevels) { System.out.println("The severity level name is: " + sevLevel.name()); if (sevLevel.name().compareTo("High") == 0) levelName = sevLevel.name(); } return levelName; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; } // Return a List that contains a Service name and Category name. public static List<String> displayServices(SupportClient supportClient) { try { DescribeServicesRequest servicesRequest = DescribeServicesRequest.builder() .language("en") .build(); DescribeServicesResponse response = supportClient.describeServices(servicesRequest); String serviceCode = null; String catName = null; List<String> sevCatList = new ArrayList<>(); List<Service> services = response.services(); System.out.println("Get the first 10 services"); int index = 1; for (Service service : services) { if (index == 11) break; System.out.println("The Service name is: " + service.name()); if (service.name().compareTo("Account") == 0) serviceCode = service.code(); // Get the Categories for this service. List<Category> categories = service.categories(); for (Category cat : categories) { System.out.println("The category name is: " + cat.name()); if (cat.name().compareTo("Security") == 0) catName = cat.name(); } index++; } // Push the two values to the list. sevCatList.add(serviceCode); sevCatList.add(catName); return sevCatList; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return null; } }

Actions

L'exemple de code suivant montre comment utiliserAddAttachmentsToSet.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 String addAttachment(SupportClient supportClient, String fileAttachment) { try { File myFile = new File(fileAttachment); InputStream sourceStream = new FileInputStream(myFile); SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream); Attachment attachment = Attachment.builder() .fileName(myFile.getName()) .data(sourceBytes) .build(); AddAttachmentsToSetRequest setRequest = AddAttachmentsToSetRequest.builder() .attachments(attachment) .build(); AddAttachmentsToSetResponse response = supportClient.addAttachmentsToSet(setRequest); return response.attachmentSetId(); } catch (SupportException | FileNotFoundException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; }
  • Pour API plus de détails, voir AddAttachmentsToSetla section AWS SDK for Java 2.x APIRéférence.

L'exemple de code suivant montre comment utiliserAddCommunicationToCase.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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); } }

L'exemple de code suivant montre comment utiliserCreateCase.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 String createSupportCase(SupportClient supportClient, List<String> sevCatList, String sevLevel) { try { String serviceCode = sevCatList.get(0); String caseCat = sevCatList.get(1); CreateCaseRequest caseRequest = CreateCaseRequest.builder() .categoryCode(caseCat.toLowerCase()) .serviceCode(serviceCode.toLowerCase()) .severityCode(sevLevel.toLowerCase()) .communicationBody("Test issue with " + serviceCode.toLowerCase()) .subject("Test case, please ignore") .language("en") .issueType("technical") .build(); CreateCaseResponse response = supportClient.createCase(caseRequest); return response.caseId(); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; }
  • Pour API plus de détails, voir CreateCasela section AWS SDK for Java 2.x APIRéférence.

L'exemple de code suivant montre comment utiliserDescribeAttachment.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 describeAttachment(SupportClient supportClient, String attachId) { try { DescribeAttachmentRequest attachmentRequest = DescribeAttachmentRequest.builder() .attachmentId(attachId) .build(); DescribeAttachmentResponse response = supportClient.describeAttachment(attachmentRequest); System.out.println("The name of the file is " + response.attachment().fileName()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
  • Pour API plus de détails, voir DescribeAttachmentla section AWS SDK for Java 2.x APIRéférence.

L'exemple de code suivant montre comment utiliserDescribeCases.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 getOpenCase(SupportClient supportClient) { try { // Specify the start and end time. Instant now = Instant.now(); java.time.LocalDate.now(); Instant yesterday = now.minus(1, ChronoUnit.DAYS); DescribeCasesRequest describeCasesRequest = DescribeCasesRequest.builder() .maxResults(20) .afterTime(yesterday.toString()) .beforeTime(now.toString()) .build(); DescribeCasesResponse response = supportClient.describeCases(describeCasesRequest); List<CaseDetails> cases = response.cases(); for (CaseDetails sinCase : cases) { System.out.println("The case status is " + sinCase.status()); System.out.println("The case Id is " + sinCase.caseId()); System.out.println("The case subject is " + sinCase.subject()); } } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
  • Pour API plus de détails, voir DescribeCasesla section AWS SDK for Java 2.x APIRéférence.

L'exemple de code suivant montre comment utiliserDescribeCommunications.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 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 ""; }

L'exemple de code suivant montre comment utiliserDescribeServices.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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.

// Return a List that contains a Service name and Category name. public static List<String> displayServices(SupportClient supportClient) { try { DescribeServicesRequest servicesRequest = DescribeServicesRequest.builder() .language("en") .build(); DescribeServicesResponse response = supportClient.describeServices(servicesRequest); String serviceCode = null; String catName = null; List<String> sevCatList = new ArrayList<>(); List<Service> services = response.services(); System.out.println("Get the first 10 services"); int index = 1; for (Service service : services) { if (index == 11) break; System.out.println("The Service name is: " + service.name()); if (service.name().compareTo("Account") == 0) serviceCode = service.code(); // Get the Categories for this service. List<Category> categories = service.categories(); for (Category cat : categories) { System.out.println("The category name is: " + cat.name()); if (cat.name().compareTo("Security") == 0) catName = cat.name(); } index++; } // Push the two values to the list. sevCatList.add(serviceCode); sevCatList.add(catName); return sevCatList; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return null; }
  • Pour API plus de détails, voir DescribeServicesla section AWS SDK for Java 2.x APIRéférence.

L'exemple de code suivant montre comment utiliserDescribeSeverityLevels.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 String displaySevLevels(SupportClient supportClient) { try { DescribeSeverityLevelsRequest severityLevelsRequest = DescribeSeverityLevelsRequest.builder() .language("en") .build(); DescribeSeverityLevelsResponse response = supportClient.describeSeverityLevels(severityLevelsRequest); List<SeverityLevel> severityLevels = response.severityLevels(); String levelName = null; for (SeverityLevel sevLevel : severityLevels) { System.out.println("The severity level name is: " + sevLevel.name()); if (sevLevel.name().compareTo("High") == 0) levelName = sevLevel.name(); } return levelName; } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } return ""; }

L'exemple de code suivant montre comment utiliserResolveCase.

SDKpour Java 2.x
Note

Il y en a plus à ce sujet 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 resolveSupportCase(SupportClient supportClient, String caseId) { try { ResolveCaseRequest caseRequest = ResolveCaseRequest.builder() .caseId(caseId) .build(); ResolveCaseResponse response = supportClient.resolveCase(caseRequest); System.out.println("The status of case " + caseId + " is " + response.finalCaseStatus()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
  • Pour API plus de détails, voir ResolveCasela section AWS SDK for Java 2.x APIRéférence.