AWS Support examples using AWS SDK for .NET - AWS SDK for .NET

AWS Support examples using AWS SDK for .NET

The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for .NET with AWS Support.

Basics are code examples that show you how to perform the essential operations within a service.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Get started

The following code examples show how to get started using AWS Support.

AWS SDK for .NET
Note

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

using Amazon.AWSSupport; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; public static class HelloSupport { static async Task Main(string[] args) { // Use the AWS .NET Core Setup package to set up dependency injection for the AWS Support service. // Use your AWS profile name, or leave it blank to use the default profile. // You must have one of the following AWS Support plans: Business, Enterprise On-Ramp, or Enterprise. Otherwise, an exception will be thrown. using var host = Host.CreateDefaultBuilder(args) .ConfigureServices((_, services) => services.AddAWSService<IAmazonAWSSupport>() ).Build(); // Now the client is available for injection. var supportClient = host.Services.GetRequiredService<IAmazonAWSSupport>(); // You can use await and any of the async methods to get a response. var response = await supportClient.DescribeServicesAsync(); Console.WriteLine($"\tHello AWS Support! There are {response.Services.Count} services available."); } }

Basics

The following code example shows how to:

  • Get and display available services and severity levels for cases.

  • Create a support case using a selected service, category, and severity level.

  • Get and display a list of open cases for the current day.

  • Add an attachment set and a communication to the new case.

  • Describe the new attachment and communication for the case.

  • Resolve the case.

  • Get and display a list of resolved cases for the current day.

AWS SDK for .NET
Note

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

Run an interactive scenario at a command prompt.

/// <summary> /// Hello AWS Support example. /// </summary> public static class SupportCaseScenario { /* Before running this .NET code example, set up your development environment, including your credentials. To use the AWS Support API, you must have one of the following AWS Support plans: Business, Enterprise On-Ramp, or Enterprise. This .NET example performs the following tasks: 1. Get and display services. Select a service from the list. 2. Select a category from the selected service. 3. Get and display severity levels and select a severity level from the list. 4. Create a support case using the selected service, category, and severity level. 5. Get and display a list of open support cases for the current day. 6. Create an attachment set with a sample text file to add to the case. 7. Add a communication with the attachment to the support case. 8. List the communications of the support case. 9. Describe the attachment set. 10. Resolve the support case. 11. Get a list of resolved cases for the current day. */ private static SupportWrapper _supportWrapper = null!; static async Task Main(string[] args) { // Set up dependency injection for the AWS Support service. // Use your AWS profile name, or leave it blank to use the default profile. using var host = Host.CreateDefaultBuilder(args) .ConfigureLogging(logging => logging.AddFilter("System", LogLevel.Debug) .AddFilter<DebugLoggerProvider>("Microsoft", LogLevel.Information) .AddFilter<ConsoleLoggerProvider>("Microsoft", LogLevel.Trace)) .ConfigureServices((_, services) => services.AddAWSService<IAmazonAWSSupport>(new AWSOptions() { Profile = "default" }) .AddTransient<SupportWrapper>() ) .Build(); var logger = LoggerFactory.Create(builder => { builder.AddConsole(); }).CreateLogger(typeof(SupportCaseScenario)); _supportWrapper = host.Services.GetRequiredService<SupportWrapper>(); Console.WriteLine(new string('-', 80)); Console.WriteLine("Welcome to the AWS Support case example scenario."); Console.WriteLine(new string('-', 80)); try { var apiSupported = await _supportWrapper.VerifySubscription(); if (!apiSupported) { logger.LogError("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."); return; } var service = await DisplayAndSelectServices(); var category = DisplayAndSelectCategories(service); var severityLevel = await DisplayAndSelectSeverity(); var caseId = await CreateSupportCase(service, category, severityLevel); await DescribeTodayOpenCases(); var attachmentSetId = await CreateAttachmentSet(); await AddCommunicationToCase(attachmentSetId, caseId); var attachmentId = await ListCommunicationsForCase(caseId); await DescribeCaseAttachment(attachmentId); await ResolveCase(caseId); await DescribeTodayResolvedCases(); Console.WriteLine(new string('-', 80)); Console.WriteLine("AWS Support case example scenario complete."); Console.WriteLine(new string('-', 80)); } catch (Exception ex) { logger.LogError(ex, "There was a problem executing the scenario."); } } /// <summary> /// List some available services from AWS Support, and select a service for the example. /// </summary> /// <returns>The selected service.</returns> private static async Task<Service> DisplayAndSelectServices() { Console.WriteLine(new string('-', 80)); var services = await _supportWrapper.DescribeServices(); Console.WriteLine($"AWS Support client returned {services.Count} services."); Console.WriteLine($"1. Displaying first 10 services:"); for (int i = 0; i < 10 && i < services.Count; i++) { Console.WriteLine($"\t{i + 1}. {services[i].Name}"); } var choiceNumber = 0; while (choiceNumber < 1 || choiceNumber > services.Count) { Console.WriteLine( "Select an example support service by entering a number from the preceding list:"); var choice = Console.ReadLine(); Int32.TryParse(choice, out choiceNumber); } Console.WriteLine(new string('-', 80)); return services[choiceNumber - 1]; } /// <summary> /// List the available categories for a service and select a category for the example. /// </summary> /// <param name="service">Service to use for displaying categories.</param> /// <returns>The selected category.</returns> private static Category DisplayAndSelectCategories(Service service) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"2. Available support categories for Service \"{service.Name}\":"); for (int i = 0; i < service.Categories.Count; i++) { Console.WriteLine($"\t{i + 1}. {service.Categories[i].Name}"); } var choiceNumber = 0; while (choiceNumber < 1 || choiceNumber > service.Categories.Count) { Console.WriteLine( "Select an example support category by entering a number from the preceding list:"); var choice = Console.ReadLine(); Int32.TryParse(choice, out choiceNumber); } Console.WriteLine(new string('-', 80)); return service.Categories[choiceNumber - 1]; } /// <summary> /// List available severity levels from AWS Support, and select a level for the example. /// </summary> /// <returns>The selected severity level.</returns> private static async Task<SeverityLevel> DisplayAndSelectSeverity() { Console.WriteLine(new string('-', 80)); var severityLevels = await _supportWrapper.DescribeSeverityLevels(); Console.WriteLine($"3. Get and display available severity levels:"); for (int i = 0; i < 10 && i < severityLevels.Count; i++) { Console.WriteLine($"\t{i + 1}. {severityLevels[i].Name}"); } var choiceNumber = 0; while (choiceNumber < 1 || choiceNumber > severityLevels.Count) { Console.WriteLine( "Select an example severity level by entering a number from the preceding list:"); var choice = Console.ReadLine(); Int32.TryParse(choice, out choiceNumber); } Console.WriteLine(new string('-', 80)); return severityLevels[choiceNumber - 1]; } /// <summary> /// Create an example support case. /// </summary> /// <param name="service">Service to use for the new case.</param> /// <param name="category">Category to use for the new case.</param> /// <param name="severity">Severity to use for the new case.</param> /// <returns>The caseId of the new support case.</returns> private static async Task<string> CreateSupportCase(Service service, Category category, SeverityLevel severity) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"4. Create an example support case" + $" with the following settings:" + $" \n\tService: {service.Name}, Category: {category.Name} " + $"and Severity Level: {severity.Name}."); var caseId = await _supportWrapper.CreateCase(service.Code, category.Code, severity.Code, "Example case for testing, ignore.", "This is my example support case."); Console.WriteLine($"\tNew case created with ID {caseId}"); Console.WriteLine(new string('-', 80)); return caseId; } /// <summary> /// List open cases for the current day. /// </summary> /// <returns>Async task.</returns> private static async Task DescribeTodayOpenCases() { Console.WriteLine($"5. List the open support cases for the current day."); // Describe the cases. If it is empty, try again and allow time for the new case to appear. List<CaseDetails> currentOpenCases = null!; while (currentOpenCases == null || currentOpenCases.Count == 0) { Thread.Sleep(1000); currentOpenCases = await _supportWrapper.DescribeCases( new List<string>(), null, false, false, DateTime.UtcNow.Date, DateTime.UtcNow); } foreach (var openCase in currentOpenCases) { Console.WriteLine($"\tCase: {openCase.CaseId} created {openCase.TimeCreated}"); } Console.WriteLine(new string('-', 80)); } /// <summary> /// Create an attachment set for a support case. /// </summary> /// <returns>The attachment set id.</returns> private static async Task<string> CreateAttachmentSet() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"6. Create an attachment set for a support case."); var fileName = "example_attachment.txt"; // Create the file if it does not already exist. if (!File.Exists(fileName)) { await using StreamWriter sw = File.CreateText(fileName); await sw.WriteLineAsync( "This is a sample file for attachment to a support case."); } await using var ms = new MemoryStream(await File.ReadAllBytesAsync(fileName)); var attachmentSetId = await _supportWrapper.AddAttachmentToSet( ms, fileName); Console.WriteLine($"\tNew attachment set created with id: \n\t{attachmentSetId.Substring(0, 65)}..."); Console.WriteLine(new string('-', 80)); return attachmentSetId; } /// <summary> /// Add an attachment set and communication to a case. /// </summary> /// <param name="attachmentSetId">Id of the attachment set.</param> /// <param name="caseId">Id of the case to receive the attachment set.</param> /// <returns>Async task.</returns> private static async Task AddCommunicationToCase(string attachmentSetId, string caseId) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"7. Add attachment set and communication to {caseId}."); await _supportWrapper.AddCommunicationToCase( caseId, "This is an example communication added to a support case.", attachmentSetId); Console.WriteLine($"\tNew attachment set and communication added to {caseId}"); Console.WriteLine(new string('-', 80)); } /// <summary> /// List the communications for a case. /// </summary> /// <param name="caseId">Id of the case to describe.</param> /// <returns>An attachment id.</returns> private static async Task<string> ListCommunicationsForCase(string caseId) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"8. List communications for case {caseId}."); var communications = await _supportWrapper.DescribeCommunications(caseId); var attachmentId = ""; foreach (var communication in communications) { Console.WriteLine( $"\tCommunication created on: {communication.TimeCreated} has {communication.AttachmentSet.Count} attachments."); if (communication.AttachmentSet.Any()) { attachmentId = communication.AttachmentSet.First().AttachmentId; } } Console.WriteLine(new string('-', 80)); return attachmentId; } /// <summary> /// Describe an attachment by id. /// </summary> /// <param name="attachmentId">Id of the attachment to describe.</param> /// <returns>Async task.</returns> private static async Task DescribeCaseAttachment(string attachmentId) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"9. Describe the attachment set."); var attachment = await _supportWrapper.DescribeAttachment(attachmentId); var data = Encoding.ASCII.GetString(attachment.Data.ToArray()); Console.WriteLine($"\tAttachment includes {attachment.FileName} with data: \n\t{data}"); Console.WriteLine(new string('-', 80)); } /// <summary> /// Resolve the support case. /// </summary> /// <param name="caseId">Id of the case to resolve.</param> /// <returns>Async task.</returns> private static async Task ResolveCase(string caseId) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"10. Resolve case {caseId}."); var status = await _supportWrapper.ResolveCase(caseId); Console.WriteLine($"\tCase {caseId} has final status {status}"); Console.WriteLine(new string('-', 80)); } /// <summary> /// List resolved cases for the current day. /// </summary> /// <returns>Async Task.</returns> private static async Task DescribeTodayResolvedCases() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"11. List the resolved support cases for the current day."); var currentCases = await _supportWrapper.DescribeCases( new List<string>(), null, false, true, DateTime.UtcNow.Date, DateTime.UtcNow); foreach (var currentCase in currentCases) { if (currentCase.Status == "resolved") { Console.WriteLine( $"\tCase: {currentCase.CaseId}: status {currentCase.Status}"); } } Console.WriteLine(new string('-', 80)); } }

Wrapper methods used by the scenario for AWS Support actions.

/// <summary> /// Wrapper methods to use AWS Support for working with support cases. /// </summary> public class SupportWrapper { private readonly IAmazonAWSSupport _amazonSupport; public SupportWrapper(IAmazonAWSSupport amazonSupport) { _amazonSupport = amazonSupport; } /// <summary> /// Get the descriptions of AWS services. /// </summary> /// <param name="name">Optional language for services. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>The list of AWS service descriptions.</returns> public async Task<List<Service>> DescribeServices(string language = "en") { var response = await _amazonSupport.DescribeServicesAsync( new DescribeServicesRequest() { Language = language }); return response.Services; } /// <summary> /// Get the descriptions of support severity levels. /// </summary> /// <param name="name">Optional language for severity levels. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>The list of support severity levels.</returns> public async Task<List<SeverityLevel>> DescribeSeverityLevels(string language = "en") { var response = await _amazonSupport.DescribeSeverityLevelsAsync( new DescribeSeverityLevelsRequest() { Language = language }); return response.SeverityLevels; } /// <summary> /// Create a new support case. /// </summary> /// <param name="serviceCode">Service code for the new case.</param> /// <param name="categoryCode">Category for the new case.</param> /// <param name="severityCode">Severity code for the new case.</param> /// <param name="subject">Subject of the new case.</param> /// <param name="body">Body text of the new case.</param> /// <param name="language">Optional language support for your case. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <param name="attachmentSetId">Optional Id for an attachment set for the new case.</param> /// <param name="issueType">Optional issue type for the new case. Options are "customer-service" or "technical".</param> /// <returns>The caseId of the new support case.</returns> public async Task<string> CreateCase(string serviceCode, string categoryCode, string severityCode, string subject, string body, string language = "en", string? attachmentSetId = null, string issueType = "customer-service") { var response = await _amazonSupport.CreateCaseAsync( new CreateCaseRequest() { ServiceCode = serviceCode, CategoryCode = categoryCode, SeverityCode = severityCode, Subject = subject, Language = language, AttachmentSetId = attachmentSetId, IssueType = issueType, CommunicationBody = body }); return response.CaseId; } /// <summary> /// Add an attachment to a set, or create a new attachment set if one does not exist. /// </summary> /// <param name="data">The data for the attachment.</param> /// <param name="fileName">The file name for the attachment.</param> /// <param name="attachmentSetId">Optional setId for the attachment. Creates a new attachment set if empty.</param> /// <returns>The setId of the attachment.</returns> public async Task<string> AddAttachmentToSet(MemoryStream data, string fileName, string? attachmentSetId = null) { var response = await _amazonSupport.AddAttachmentsToSetAsync( new AddAttachmentsToSetRequest { AttachmentSetId = attachmentSetId, Attachments = new List<Attachment> { new Attachment { Data = data, FileName = fileName } } }); return response.AttachmentSetId; } /// <summary> /// Get description of a specific attachment. /// </summary> /// <param name="attachmentId">Id of the attachment, usually fetched by describing the communications of a case.</param> /// <returns>The attachment object.</returns> public async Task<Attachment> DescribeAttachment(string attachmentId) { var response = await _amazonSupport.DescribeAttachmentAsync( new DescribeAttachmentRequest() { AttachmentId = attachmentId }); return response.Attachment; } /// <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; } /// <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; } /// <summary> /// Get case details for a list of case ids, optionally with date filters. /// </summary> /// <param name="caseIds">The list of case IDs.</param> /// <param name="displayId">Optional display ID.</param> /// <param name="includeCommunication">True to include communication. Defaults to true.</param> /// <param name="includeResolvedCases">True to include resolved cases. Defaults to false.</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> /// <param name="language">Optional language support for your case. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>A list of CaseDetails.</returns> public async Task<List<CaseDetails>> DescribeCases(List<string> caseIds, string? displayId = null, bool includeCommunication = true, bool includeResolvedCases = false, DateTime? afterTime = null, DateTime? beforeTime = null, string language = "en") { var results = new List<CaseDetails>(); var paginateCases = _amazonSupport.Paginators.DescribeCases( new DescribeCasesRequest() { CaseIdList = caseIds, DisplayId = displayId, IncludeCommunications = includeCommunication, IncludeResolvedCases = includeResolvedCases, AfterTime = afterTime?.ToString("s"), BeforeTime = beforeTime?.ToString("s"), Language = language }); // Get the entire list using the paginator. await foreach (var cases in paginateCases.Cases) { results.Add(cases); } return results; } /// <summary> /// Resolve a support case by caseId. /// </summary> /// <param name="caseId">Id for the support case.</param> /// <returns>The final status of the case after resolving.</returns> public async Task<string> ResolveCase(string caseId) { var response = await _amazonSupport.ResolveCaseAsync( new ResolveCaseRequest() { CaseId = caseId }); return response.FinalCaseStatus; } /// <summary> /// Verify the support level for AWS Support API access. /// </summary> /// <returns>True if the subscription level supports API access.</returns> public async Task<bool> VerifySubscription() { try { var response = await _amazonSupport.DescribeServicesAsync( new DescribeServicesRequest() { Language = "en" }); return response.HttpStatusCode == HttpStatusCode.OK; } catch (Amazon.AWSSupport.AmazonAWSSupportException ex) { if (ex.ErrorCode == "SubscriptionRequiredException") { return false; } else throw; } } }

Actions

The following code example shows how to use AddAttachmentsToSet.

AWS SDK for .NET
Note

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

/// <summary> /// Add an attachment to a set, or create a new attachment set if one does not exist. /// </summary> /// <param name="data">The data for the attachment.</param> /// <param name="fileName">The file name for the attachment.</param> /// <param name="attachmentSetId">Optional setId for the attachment. Creates a new attachment set if empty.</param> /// <returns>The setId of the attachment.</returns> public async Task<string> AddAttachmentToSet(MemoryStream data, string fileName, string? attachmentSetId = null) { var response = await _amazonSupport.AddAttachmentsToSetAsync( new AddAttachmentsToSetRequest { AttachmentSetId = attachmentSetId, Attachments = new List<Attachment> { new Attachment { Data = data, FileName = fileName } } }); return response.AttachmentSetId; }

The following code example shows how to use AddCommunicationToCase.

AWS SDK for .NET
Note

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

/// <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; }

The following code example shows how to use CreateCase.

AWS SDK for .NET
Note

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

/// <summary> /// Create a new support case. /// </summary> /// <param name="serviceCode">Service code for the new case.</param> /// <param name="categoryCode">Category for the new case.</param> /// <param name="severityCode">Severity code for the new case.</param> /// <param name="subject">Subject of the new case.</param> /// <param name="body">Body text of the new case.</param> /// <param name="language">Optional language support for your case. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <param name="attachmentSetId">Optional Id for an attachment set for the new case.</param> /// <param name="issueType">Optional issue type for the new case. Options are "customer-service" or "technical".</param> /// <returns>The caseId of the new support case.</returns> public async Task<string> CreateCase(string serviceCode, string categoryCode, string severityCode, string subject, string body, string language = "en", string? attachmentSetId = null, string issueType = "customer-service") { var response = await _amazonSupport.CreateCaseAsync( new CreateCaseRequest() { ServiceCode = serviceCode, CategoryCode = categoryCode, SeverityCode = severityCode, Subject = subject, Language = language, AttachmentSetId = attachmentSetId, IssueType = issueType, CommunicationBody = body }); return response.CaseId; }
  • For API details, see CreateCase in AWS SDK for .NET API Reference.

The following code example shows how to use DescribeAttachment.

AWS SDK for .NET
Note

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

/// <summary> /// Get description of a specific attachment. /// </summary> /// <param name="attachmentId">Id of the attachment, usually fetched by describing the communications of a case.</param> /// <returns>The attachment object.</returns> public async Task<Attachment> DescribeAttachment(string attachmentId) { var response = await _amazonSupport.DescribeAttachmentAsync( new DescribeAttachmentRequest() { AttachmentId = attachmentId }); return response.Attachment; }

The following code example shows how to use DescribeCases.

AWS SDK for .NET
Note

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

/// <summary> /// Get case details for a list of case ids, optionally with date filters. /// </summary> /// <param name="caseIds">The list of case IDs.</param> /// <param name="displayId">Optional display ID.</param> /// <param name="includeCommunication">True to include communication. Defaults to true.</param> /// <param name="includeResolvedCases">True to include resolved cases. Defaults to false.</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> /// <param name="language">Optional language support for your case. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>A list of CaseDetails.</returns> public async Task<List<CaseDetails>> DescribeCases(List<string> caseIds, string? displayId = null, bool includeCommunication = true, bool includeResolvedCases = false, DateTime? afterTime = null, DateTime? beforeTime = null, string language = "en") { var results = new List<CaseDetails>(); var paginateCases = _amazonSupport.Paginators.DescribeCases( new DescribeCasesRequest() { CaseIdList = caseIds, DisplayId = displayId, IncludeCommunications = includeCommunication, IncludeResolvedCases = includeResolvedCases, AfterTime = afterTime?.ToString("s"), BeforeTime = beforeTime?.ToString("s"), Language = language }); // Get the entire list using the paginator. await foreach (var cases in paginateCases.Cases) { results.Add(cases); } return results; }
  • For API details, see DescribeCases in AWS SDK for .NET API Reference.

The following code example shows how to use DescribeCommunications.

AWS SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS 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("s"), BeforeTime = beforeTime?.ToString("s") }); // Get the entire list using the paginator. await foreach (var communications in paginateCommunications.Communications) { results.Add(communications); } return results; }

The following code example shows how to use DescribeServices.

AWS SDK for .NET
Note

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

/// <summary> /// Get the descriptions of AWS services. /// </summary> /// <param name="name">Optional language for services. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>The list of AWS service descriptions.</returns> public async Task<List<Service>> DescribeServices(string language = "en") { var response = await _amazonSupport.DescribeServicesAsync( new DescribeServicesRequest() { Language = language }); return response.Services; }

The following code example shows how to use DescribeSeverityLevels.

AWS SDK for .NET
Note

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

/// <summary> /// Get the descriptions of support severity levels. /// </summary> /// <param name="name">Optional language for severity levels. /// Currently Chinese (“zh”), English ("en"), Japanese ("ja") and Korean (“ko”) are supported.</param> /// <returns>The list of support severity levels.</returns> public async Task<List<SeverityLevel>> DescribeSeverityLevels(string language = "en") { var response = await _amazonSupport.DescribeSeverityLevelsAsync( new DescribeSeverityLevelsRequest() { Language = language }); return response.SeverityLevels; }

The following code example shows how to use ResolveCase.

AWS SDK for .NET
Note

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

/// <summary> /// Resolve a support case by caseId. /// </summary> /// <param name="caseId">Id for the support case.</param> /// <returns>The final status of the case after resolving.</returns> public async Task<string> ResolveCase(string caseId) { var response = await _amazonSupport.ResolveCaseAsync( new ResolveCaseRequest() { CaseId = caseId }); return response.FinalCaseStatus; }
  • For API details, see ResolveCase in AWS SDK for .NET API Reference.