Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use ListPrices
with an Amazon SDK or CLI
The following code examples show how to use ListPrices
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- .NET
-
- Amazon SDK for .NET
-
/// <summary>
/// List prices for domain type operations.
/// </summary>
/// <param name="domainTypes">Domain types to include in the results.</param>
/// <returns>The list of domain prices.</returns>
public async Task<List<DomainPrice>> ListPrices(List<string> domainTypes)
{
var results = new List<DomainPrice>();
var paginatePrices = _amazonRoute53Domains.Paginators.ListPrices(new ListPricesRequest());
// Get the entire list using the paginator.
await foreach (var prices in paginatePrices.Prices)
{
results.Add(prices);
}
return results.Where(p => domainTypes.Contains(p.Name)).ToList();
}
- Java
-
- SDK for Java 2.x
-
public static void listPrices(Route53DomainsClient route53DomainsClient, String domainType) {
try {
ListPricesRequest pricesRequest = ListPricesRequest.builder()
.tld(domainType)
.build();
ListPricesIterable listRes = route53DomainsClient.listPricesPaginator(pricesRequest);
listRes.stream()
.flatMap(r -> r.prices().stream())
.forEach(content -> System.out.println(" Name: " + content.name() +
" Registration: " + content.registrationPrice().price() + " "
+ content.registrationPrice().currency() +
" Renewal: " + content.renewalPrice().price() + " " + content.renewalPrice().currency()));
} catch (Route53Exception e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
- Kotlin
-
- SDK for Kotlin
-
suspend fun listAllPrices(domainType: String?) {
val pricesRequest =
ListPricesRequest {
tld = domainType
}
Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient ->
route53DomainsClient
.listPricesPaginated(pricesRequest)
.transform { it.prices?.forEach { obj -> emit(obj) } }
.collect { pr ->
println("Registration: ${pr.registrationPrice} ${pr.registrationPrice?.currency}")
println("Renewal: ${pr.renewalPrice?.price} ${pr.renewalPrice?.currency}")
println("Transfer: ${pr.transferPrice?.price} ${pr.transferPrice?.currency}")
println("Restoration: ${pr.restorationPrice?.price} ${pr.restorationPrice?.currency}")
}
}
}
For a complete list of Amazon SDK developer guides and code examples, see
Using Route 53 with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.