CreateCase与 S Amazon DK 或命令行工具配合使用 - Amazon Web Services Support
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

CreateCase与 S Amazon DK 或命令行工具配合使用

以下代码示例显示了如何使用CreateCase

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

.NET
Amazon SDK for .NET
注意

还有更多相关信息 GitHub。在 Amazon 代码示例存储库中查找完整示例,了解如何进行设置和运行。

/// <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 的详细信息,请参阅 Amazon SDK for .NET API 参考CreateCase中的。

CLI
Amazon CLI

创建案例

以下create-case示例为您的 Amazon 账户创建了一个支持案例。

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" }

有关更多信息,请参阅《Amazon Support 用户指南》中的案例管理

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateCase中的。

Java
适用于 Java 2.x 的 SDK
注意

还有更多相关信息 GitHub。在 Amazon 代码示例存储库中查找完整示例,了解如何进行设置和运行。

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 的详细信息,请参阅 Amazon SDK for Java 2.x API 参考CreateCase中的。

JavaScript
适用于 JavaScript (v3) 的软件开发工具包
注意

还有更多相关信息 GitHub。在 Amazon 代码示例存储库中查找完整示例,了解如何进行设置和运行。

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 的详细信息,请参阅 Amazon SDK for JavaScript API 参考CreateCase中的。

Kotlin
适用于 Kotlin 的 SDK
注意

还有更多相关信息 GitHub。在 Amazon 代码示例存储库中查找完整示例,了解如何进行设置和运行。

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于 K otlin 的Amazon SDK API 参考

PowerShell
用于 PowerShell

示例 1:在 Su Amazon pport Center 中创建新案例。-ServiceCode 和-CategoryCode 参数的值可以使用 Get-asaService cmdlet 获取。-SeverityCode 参数的值可以使用 get-asa cmdlet SeverityLevel 获得。-IssueType 参数值可以是 “客户服务” 或 “技术”。如果成功,则 Amazon 输出 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 的详细信息,请参阅 Amazon Tools for PowerShell Cmdlet 参考CreateCase中的。

Python
SDK for Python (Boto3)
注意

还有更多相关信息 GitHub。在 Amazon 代码示例存储库中查找完整示例,了解如何进行设置和运行。

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 的详细信息,请参阅适用CreateCasePython 的Amazon SDK (Boto3) API 参考

有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅将 Amazon Web Services Support 与 Amazon 开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。