AWS 文档 SDK 示例
将 ListDomains 与 AWS SDK 或 CLI 配合使用
以下代码示例演示如何使用 ListDomains。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- .NET
-
- 适用于 .NET 的 SDK
-
注意
查看 GitHub,了解更多信息。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// List the domains for the account. /// </summary> /// <returns>A collection of domain summary records.</returns> public async Task<List<DomainSummary>> ListDomains() { var results = new List<DomainSummary>(); var paginateDomains = _amazonRoute53Domains.Paginators.ListDomains( new ListDomainsRequest()); // Get the entire list using the paginator. await foreach (var domain in paginateDomains.Domains) { results.Add(domain); } return results; }-
有关 API 详细信息,请参阅《适用于 .NET 的 AWS SDK API Reference》中的 ListDomains。
-
- CLI
-
- AWS CLI
-
列出使用当前 AWS 账户注册的域
以下
list-domains命令列出了与使用当前 AWS 账户注册的域相关的摘要信息。此命令仅在
us-east-1区域中运行。如果您的默认区域设置为us-east-1,则可以省略region参数。aws route53domains list-domains --regionus-east-1输出:
{ "Domains": [ { "DomainName": "example.com", "AutoRenew": true, "TransferLock": true, "Expiry": 1602712345.0 }, { "DomainName": "example.net", "AutoRenew": true, "TransferLock": true, "Expiry": 1602723456.0 }, { "DomainName": "example.org", "AutoRenew": true, "TransferLock": true, "Expiry": 1602734567.0 } ] }-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListDomains
。
-
- Java
-
- 适用于 Java 的 SDK 2.x
-
注意
查看 GitHub,了解更多信息。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 public static void listDomains(Route53DomainsClient route53DomainsClient) { try { ListDomainsIterable listRes = route53DomainsClient.listDomainsPaginator(); listRes.stream() .flatMap(r -> r.domains().stream()) .forEach(content -> System.out.println("The domain name is " + content.domainName())); } catch (Route53Exception e) { System.err.println(e.getMessage()); System.exit(1); } }-
有关 API 详细信息,请参阅《AWS SDK for Java 2.x API Reference》中的 ListDomains。
-
- Kotlin
-
- 适用于 Kotlin 的 SDK
-
注意
查看 GitHub,了解更多信息。在 AWS 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 suspend fun listDomains() { Route53DomainsClient.fromEnvironment { region = "us-east-1" }.use { route53DomainsClient -> route53DomainsClient .listDomainsPaginated(ListDomainsRequest {}) .transform { it.domains?.forEach { obj -> emit(obj) } } .collect { content -> println("The domain name is ${content.domainName}") } } }-
有关 API 详细信息,请参阅《AWS SDK for Kotlin API Reference》中的 ListDomains
。
-
GetOperationDetail
ListOperations