本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或CreateCase
一起使用 CLI
以下代码示例演示如何使用 CreateCase
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- .NET
-
- AWS SDK for .NET
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /// <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; }
-
有关API详细信息,请参阅 “AWS SDK for .NET API参考 CreateCase” 中的。
-
- CLI
-
- AWS CLI
-
创建案例
以下
create-case
示例为您的 AWS 账户创建了一个支持案例。aws support create-case \ --category-code
"using-aws"
\ --cc-email-addresses"myemail@example.com"
\ --communication-body"I want to learn more about an AWS service."
\ --issue-type"technical"
\ --language"en"
\ --service-code"general-info"
\ --severity-code"low"
\ --subject"Question about my account"
输出:
{ "caseId": "case-12345678910-2013-c4c1d2bf33c5cf47" }
有关更多信息,请参阅《AWS Support 用户指南》中的案例管理。
-
有关API详细信息,请参阅 “CreateCase AWS CLI
命令参考”。
-
- Java
-
- SDK适用于 Java 2.x
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 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 ""; }
-
有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 CreateCase” 中的。
-
- JavaScript
-
- SDK对于 JavaScript (v3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 import { CreateCaseCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; export const main = async () => { try { // Create a new case and log the case id. // Important: This creates a real support case in your account. const response = await client.send( new CreateCaseCommand({ // The subject line of the case. subject: "IGNORE: Test case", // Use DescribeServices to find available service codes for each service. serviceCode: "service-quicksight-end-user", // Use DescribeSecurityLevels to find available severity codes for your support plan. severityCode: "low", // Use DescribeServices to find available category codes for each service. categoryCode: "end-user-support", // The main description of the support case. communicationBody: "This is a test. Please ignore.", }), ); console.log(response.caseId); return response; } catch (err) { console.error(err); } };
-
有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 CreateCase” 中的。
-
- Kotlin
-
- SDK对于 Kotlin 来说
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 suspend fun createSupportCase( sevCatListVal: List<String>, sevLevelVal: String, ): String? { val serCode = sevCatListVal[0] val caseCategory = sevCatListVal[1] val caseRequest = CreateCaseRequest { categoryCode = caseCategory.lowercase(Locale.getDefault()) serviceCode = serCode.lowercase(Locale.getDefault()) severityCode = sevLevelVal.lowercase(Locale.getDefault()) communicationBody = "Test issue with ${serCode.lowercase(Locale.getDefault())}" subject = "Test case, please ignore" language = "en" issueType = "technical" } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.createCase(caseRequest) return response.caseId } }
-
有关API详细信息,请参阅CreateCase
中的 Kotlin AWS SDK API 参考。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:在 Su AWS pport Center 中创建新案例。-ServiceCode 和-CategoryCode 参数的值可以使用 Get-ASAService cmdlet 获取。-SeverityCode 参数的值可以使用 Get-ASASeverityLevel cmdlet 获得。-IssueType 参数值可以是 “客户服务” 或 “技术”。如果成功,则 AWS 输出 Support 案例编号。默认情况下,案例将用英语处理,要使用日语,请添加-Language “ja” 参数。-ServiceCode、-CategoryCode、-主题和-CommunicationBody 参数是必需的。
New-ASACase -ServiceCode "amazon-cloudfront" -CategoryCode "APIs" -SeverityCode "low" -Subject "subject text" -CommunicationBody "description of the case" -CcEmailAddress @("email1@domain.com", "email2@domain.com") -IssueType "technical"
-
有关API详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考CreateCase中的。
-
- 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 create_case(self, service, category, severity): """ Create a new support case. :param service: The service to use for the new case. :param category: The category to use for the new case. :param severity: The severity to use for the new case. :return: The caseId of the new case. """ try: response = self.support_client.create_case( subject="Example case for testing, ignore.", serviceCode=service["code"], severityCode=severity["code"], categoryCode=category["code"], communicationBody="Example support case body.", language="en", issueType="customer-service", ) case_id = response["caseId"] 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 create case. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return case_id
-
有关API详细信息,请参阅CreateCase中的 AWS SDKPython (Boto3) API 参考。
-
有关 AWS SDK开发者指南和代码示例的完整列表,请参阅AWS Support 与 AWS SDK 一起使用。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。