Allocation tokens that have been redeemed cannot be deleted. To delete a single allocation
- * token, specify the entire token as the prefix.
+ *
Note that all multi-use tokens and redeemed single-use tokens cannot be deleted.
*/
@Parameters(
separators = " =",
- commandDescription = "Deletes the unused AllocationTokens with a given prefix.")
-final class DeleteAllocationTokensCommand extends ConfirmingCommand
- implements CommandWithRemoteApi {
-
- @Parameter(
- names = {"-p", "--prefix"},
- description = "Allocation token prefix; if blank, deletes all unused tokens",
- required = true)
- private String prefix;
+ commandDescription =
+ "Deletes the unused AllocationTokens with a given prefix (or specified tokens).")
+final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokensCommand {
@Parameter(
names = {"--with_domains"},
description = "Allow deletion of allocation tokens with specified domains; defaults to false")
- boolean withDomains;
-
- @Parameter(
- names = {"--dry_run"},
- description = "Do not actually delete the tokens; defaults to false")
- boolean dryRun;
+ private boolean withDomains;
private static final int BATCH_SIZE = 20;
private static final Joiner JOINER = Joiner.on(", ");
@@ -64,12 +51,7 @@ final class DeleteAllocationTokensCommand extends ConfirmingCommand
@Override
public void init() {
- Query query =
- ofy().load().type(AllocationToken.class).filter("redemptionHistoryEntry", null);
- tokensToDelete =
- query.keys().list().stream()
- .filter(key -> key.getName().startsWith(prefix))
- .collect(toImmutableSet());
+ tokensToDelete = getTokenKeys();
}
@Override
diff --git a/java/google/registry/tools/UpdateAllocationTokensCommand.java b/java/google/registry/tools/UpdateAllocationTokensCommand.java
index 8455568ee..171b9e760 100644
--- a/java/google/registry/tools/UpdateAllocationTokensCommand.java
+++ b/java/google/registry/tools/UpdateAllocationTokensCommand.java
@@ -14,8 +14,6 @@
package google.registry.tools;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.Iterables.partition;
@@ -28,7 +26,6 @@ import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
-import com.googlecode.objectify.Key;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
import google.registry.tools.params.TransitionListParameter.TokenStatusTransitions;
@@ -42,49 +39,30 @@ import org.joda.time.DateTime;
@Parameters(
separators = " =",
commandDescription =
- "Updates AllocationTokens with the given prefix, modifying some subset of their allowed"
- + " client IDs, allowed TLDs, discount fraction, or status transitions")
-public final class UpdateAllocationTokensCommand extends ConfirmingCommand
- implements CommandWithRemoteApi {
-
- @Parameter(
- names = {"-p", "--prefix"},
- description =
- "Update all allocation tokens with this prefix; otherwise use '--tokens' to specify"
- + " exact tokens(s) to update")
- private String prefix;
-
- @Parameter(
- names = {"--tokens"},
- description =
- "Comma-separated list of tokens to update; otherwise use '--prefix' to update all tokens"
- + " with a given prefix")
- private List tokens;
-
- @Parameter(
- names = {"--dry_run"},
- description = "Do not actually update the tokens; defaults to false")
- private boolean dryRun;
+ "Updates AllocationTokens with the given prefix (or specified tokens), modifying some "
+ + "subset of their allowed client IDs, allowed TLDs, discount fraction, or status "
+ + "transitions")
+final class UpdateAllocationTokensCommand extends UpdateOrDeleteAllocationTokensCommand {
@Parameter(
names = {"--allowed_client_ids"},
description =
- "Comma-separated list of allowed client IDs. Use the empty string to clear the"
- + " existing list.")
+ "Comma-separated list of allowed client IDs. Use the empty string to clear the "
+ + "existing list.")
private List allowedClientIds;
@Parameter(
names = {"--allowed_tlds"},
description =
- "Comma-separated list of allowed TLDs. Use the empty string to clear the"
- + " existing list.")
+ "Comma-separated list of allowed TLDs. Use the empty string to clear the "
+ + "existing list.")
private List allowedTlds;
@Parameter(
names = {"--discount_fraction"},
description =
- "A discount off the base price for the first year between 0.0 and 1.0. Default is 0.0,"
- + " i.e. no discount.")
+ "A discount off the base price for the first year between 0.0 and 1.0. Default is 0.0, "
+ + "i.e. no discount.")
private Double discountFraction;
@Parameter(
@@ -92,8 +70,8 @@ public final class UpdateAllocationTokensCommand extends ConfirmingCommand
converter = TokenStatusTransitions.class,
validateWith = TokenStatusTransitions.class,
description =
- "Comma-delimited list of token status transitions effective on specific dates, of the"
- + " form