本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或DescribeSeverityLevels
一起使用 CLI
以下代码示例演示如何使用 DescribeSeverityLevels
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- .NET
-
- AWS SDK for .NET
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /// <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; }
-
有关API详细信息,请参阅 “AWS SDK for .NET API参考 DescribeSeverityLevels” 中的。
-
- CLI
-
- AWS CLI
-
列出可用的严重性级别
以下
describe-severity-levels
示例列出了支持案例的可用严重性级别。aws support describe-severity-levels
输出:
{ "severityLevels": [ { "code": "low", "name": "Low" }, { "code": "normal", "name": "Normal" }, { "code": "high", "name": "High" }, { "code": "urgent", "name": "Urgent" }, { "code": "critical", "name": "Critical" } ] }
有关更多信息,请参阅《AWS Support 用户指南》中的选择严重性。
-
有关API详细信息,请参阅 “DescribeSeverityLevels AWS CLI
命令参考”。
-
- Java
-
- SDK适用于 Java 2.x
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 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 ""; }
-
有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 DescribeSeverityLevels” 中的。
-
- JavaScript
-
- SDK对于 JavaScript (v3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 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); } };
-
有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 DescribeSeverityLevels” 中的。
-
- Kotlin
-
- SDK对于 Kotlin 来说
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 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 } }
-
有关API详细信息,请参阅DescribeSeverityLevels
中的 Kotlin AWS SDK API 参考。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:返回可分配给 Support 案例的 AWS 严重性级别列表。
Get-ASASeverityLevel
示例 2:返回可以分配给 Support 案例的 AWS 严重性级别列表。关卡名称以日语返回。
Get-ASASeverityLevel -Language "ja"
-
有关API详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考DescribeSeverityLevels中的。
-
- Python
-
- SDK适用于 Python (Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 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
-
有关API详细信息,请参阅DescribeSeverityLevels中的 AWS SDKPython (Boto3) API 参考。
-
有关 AWS SDK开发者指南和代码示例的完整列表,请参阅AWS Support 与 AWS SDK 一起使用。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。