Add limit to list_domains command

This allows list_domains to continue working for large TLDs.

TESTED=Deploys to alpha and it works to list the most recently created domains even
on a TLD with a huge number of domains on it (much more than .app has currently).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196717389
This commit is contained in:
mcilwain 2018-05-15 13:12:34 -07:00 committed by jianglai
parent e4f25c08e8
commit 9c0d3b6db3
11 changed files with 243 additions and 198 deletions

View file

@ -33,17 +33,22 @@ final class ListDomainsCommand extends ListObjectsCommand {
required = true)
private List<String> tlds;
@Parameter(
names = {"-n", "--limit"},
description = "Max number of domains to list, most recent first; defaults to no limit."
)
private int maxDomains = Integer.MAX_VALUE;
@Override
String getCommandPath() {
return ListDomainsAction.PATH;
}
/** Returns a map of parameters to be sent to the server
* (in addition to the usual ones). */
/** Returns a map of parameters to be sent to the server (in addition to the usual ones). */
@Override
ImmutableMap<String, Object> getParameterMap() {
String tldsParam = Joiner.on(',').join(tlds);
checkArgument(tldsParam.length() < 1024, "Total length of TLDs is too long for URL parameter");
return ImmutableMap.of("tlds", tldsParam);
return ImmutableMap.of("tlds", tldsParam, "limit", maxDomains);
}
}