GetOperationDetail与 AWS SDK 或 CLI 配合使用 - Amazon Route 53

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

GetOperationDetail与 AWS SDK 或 CLI 配合使用

以下代码示例演示如何使用 GetOperationDetail

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

.NET
AWS SDK for .NET
注意

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

/// <summary> /// Get details for a domain action operation. /// </summary> /// <param name="operationId">The operational Id.</param> /// <returns>A string describing the operational details.</returns> public async Task<string> GetOperationDetail(string? operationId) { if (operationId == null) return "Unable to get operational details because ID is null."; try { var operationDetails = await _amazonRoute53Domains.GetOperationDetailAsync( new GetOperationDetailRequest { OperationId = operationId } ); var details = $"\tOperation {operationId}:\n" + $"\tFor domain {operationDetails.DomainName} on {operationDetails.SubmittedDate.ToShortDateString()}.\n" + $"\tMessage is {operationDetails.Message}.\n" + $"\tStatus is {operationDetails.Status}.\n"; return details; } catch (AmazonRoute53DomainsException ex) { return $"Unable to get operation details. Here's why: {ex.Message}."; } }
CLI
AWS CLI

获取操作的当前状态

某些域名注册操作异步运行,并在完成之前返回响应。这些操作会返回一个操作 ID,您可以使用它来获取当前状态。以下get-operation-detail命令返回指定操作的状态。

此命令仅在us-east-1区域中运行。如果您的默认区域设置为us-east-1,则可以省略该region参数。

aws route53domains get-operation-detail \ --region us-east-1 \ --operation-id edbd8d63-7fe7-4343-9bc5-54033example

输出:

{ "OperationId": "edbd8d63-7fe7-4343-9bc5-54033example", "Status": "SUCCESSFUL", "DomainName": "example.com", "Type": "DOMAIN_LOCK", "SubmittedDate": 1573749367.864 }
Java
适用于 Java 2.x 的 SDK
注意

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

public static void getOperationalDetail(Route53DomainsClient route53DomainsClient, String operationId) { try { GetOperationDetailRequest detailRequest = GetOperationDetailRequest.builder() .operationId(operationId) .build(); GetOperationDetailResponse response = route53DomainsClient.getOperationDetail(detailRequest); System.out.println("Operation detail message is " + response.message()); } catch (Route53Exception e) { System.err.println(e.getMessage()); System.exit(1); } }
Kotlin
适用于 Kotlin 的 SDK
注意

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

suspend fun getOperationalDetail(opId: String?) { val detailRequest = GetOperationDetailRequest { operationId = opId } Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient -> val response = route53DomainsClient.getOperationDetail(detailRequest) println("Operation detail message is ${response.message}") } }

有关 S AWS DK 开发者指南和代码示例的完整列表,请参阅将 Route 53 与 S AWS DK 一起使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。