文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
ResolveCase
搭配 a AWS SDK 或 CLI 使用
下列程式碼範例示範如何使用 ResolveCase
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- .NET
-
- AWS SDK for .NET
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 /// <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; }
-
如需 API 詳細資訊,請參閱 ResolveCase AWS SDK for .NET 參考中的 API。
-
- CLI
-
- AWS CLI
-
若要解決支援案例
下列
resolve-case
範例會解決您 AWS 帳戶中的支援案例。aws support resolve-case \ --case-id
"case-12345678910-2013-c4c1d2bf33c5cf47"
輸出:
{ "finalCaseStatus": "resolved", "initialCaseStatus": "work-in-progress" }
如需詳細資訊,請參閱 AWS 支援使用者指南中的案例管理。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ResolveCase
。
-
- Java
-
- Java 2.x 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 public static void resolveSupportCase(SupportClient supportClient, String caseId) { try { ResolveCaseRequest caseRequest = ResolveCaseRequest.builder() .caseId(caseId) .build(); ResolveCaseResponse response = supportClient.resolveCase(caseRequest); System.out.println("The status of case " + caseId + " is " + response.finalCaseStatus()); } catch (SupportException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
-
如需 API 詳細資訊,請參閱 ResolveCase AWS SDK for Java 2.x 參考中的 API。
-
- JavaScript
-
- SDK for JavaScript (v3)
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 import { ResolveCaseCommand } from "@aws-sdk/client-support"; import { client } from "../libs/client.js"; const main = async () => { try { const response = await client.send( new ResolveCaseCommand({ caseId: "CASE_ID", }), ); console.log(response.finalCaseStatus); return response; } catch (err) { console.error(err); } };
-
如需 API 詳細資訊,請參閱 ResolveCase AWS SDK for JavaScript 參考中的 API。
-
- Kotlin
-
- Kotlin 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 suspend fun resolveSupportCase(caseIdVal: String) { val caseRequest = ResolveCaseRequest { caseId = caseIdVal } SupportClient { region = "us-west-2" }.use { supportClient -> val response = supportClient.resolveCase(caseRequest) println("The status of case $caseIdVal is ${response.finalCaseStatus}") } }
-
如需 API 詳細資訊,請參閱 ResolveCase
AWS for Kotlin SDK 參考中的 API。
-
- PowerShell
-
- for PowerShell 工具
-
範例 1:傳回指定案例的初始狀態,以及呼叫完成解決它後的目前狀態。
Resolve-ASACase -CaseId "case-12345678910-2013-c4c1d2bf33c5cf47"
-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 ResolveCase。
-
- Python
-
- SDK for Python (Boto3)
-
注意
還有更多 on 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 resolve_case(self, case_id): """ Resolve a support case by its caseId. :param case_id: The ID of the case to resolve. :return: The final status of the case. """ try: response = self.support_client.resolve_case(caseId=case_id) final_status = response["finalCaseStatus"] 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 resolve case. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return final_status
-
如需 API 詳細資訊,請參閱 ResolveCase AWS SDK for Python (Boto3) Word 參考中的 API。
-