Use DescribeSeverityLevels with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeSeverityLevels with an AWS SDK or CLI

The following code examples show how to use DescribeSeverityLevels.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

.NET
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; }
CLI
AWS CLI

To list the available severity levels

The following describe-severity-levels example lists the available severity levels for a support case.

aws support describe-severity-levels

Output:

{ "severityLevels": [ { "code": "low", "name": "Low" }, { "code": "normal", "name": "Normal" }, { "code": "high", "name": "High" }, { "code": "urgent", "name": "Urgent" }, { "code": "critical", "name": "Critical" } ] }

For more information, see Choosing a severity in the AWS Support User Guide.

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 AWS Code Examples Repository.

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 ""; }
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 AWS Code Examples Repository.

import { DescribeSeverityLevelsCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; export const main = async () => { try { // Get the list of severity levels. // The available values depend on the support plan for the account. const response = await client.send(new DescribeSeverityLevelsCommand({})); console.log(response.severityLevels); return response; } catch (err) { console.error(err); } };
Kotlin
SDK for Kotlin
Note

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

suspend fun displaySevLevels(): String { var levelName = "" val severityLevelsRequest = DescribeSeverityLevelsRequest { language = "en" } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.describeSeverityLevels(severityLevelsRequest) response.severityLevels?.forEach { sevLevel -> println("The severity level name is: ${sevLevel.name}") if (sevLevel.name == "High") { levelName = sevLevel.name!! } } return levelName } }
PowerShell
Tools for PowerShell

Example 1: Returns the list of severity levels that can be assigned to an AWS Support case.

Get-ASASeverityLevel

Example 2: Returns the list of severity levels that can be assigned to an AWS Support case. The names of the levels are returned in Japanese.

Get-ASASeverityLevel -Language "ja"
Python
SDK for Python (Boto3)
Note

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

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_severity_levels(self, language): """ Get the descriptions of available severity levels for support cases for a language. :param language: The language for support severity levels. Currently, only "en" (English) and "ja" (Japanese) are supported. :return: The list of severity levels. """ try: response = self.support_client.describe_severity_levels(language=language) severity_levels = response["severityLevels"] 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 get severity levels for language %s. Here's why: %s: %s", language, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return severity_levels