mirror of
https://github.com/google/nomulus
synced 2026-09-19 06:32:00 +00:00
Add renewal logic in allocation token related commands (#1596)
* Add renewal price behavior to allocation token related command * Add details to renewal price behavior
This commit is contained in:
@@ -17,6 +17,7 @@ package google.registry.tools;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
@@ -37,6 +38,7 @@ import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.io.Files;
|
||||
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||
@@ -141,6 +143,16 @@ class GenerateAllocationTokensCommand implements CommandWithRemoteApi {
|
||||
+ " form <time>=<status>[,<time>=<status>]* where each status represents the status.")
|
||||
private ImmutableSortedMap<DateTime, TokenStatus> tokenStatusTransitions;
|
||||
|
||||
@Parameter(
|
||||
names = {"--renewal_price_behavior"},
|
||||
description =
|
||||
"The type of renewal price behavior, either DEFAULT (default), NONPREMIUM, or SPECIFIED."
|
||||
+ " This indicates how a domain should be charged for renewal. By default, a domain"
|
||||
+ " will be renewed at the renewal price from the pricing engine. If the renewal"
|
||||
+ " price behavior is set to SPECIFIED, it means that the renewal cost will be the"
|
||||
+ " same as the domain's calculated create price.")
|
||||
private RenewalPriceBehavior renewalPriceBehavior = DEFAULT;
|
||||
|
||||
@Parameter(
|
||||
names = {"--dry_run"},
|
||||
description = "Do not actually persist the tokens; defaults to false")
|
||||
@@ -184,6 +196,7 @@ class GenerateAllocationTokensCommand implements CommandWithRemoteApi {
|
||||
AllocationToken.Builder token =
|
||||
new AllocationToken.Builder()
|
||||
.setToken(t)
|
||||
.setRenewalPriceBehavior(renewalPriceBehavior)
|
||||
.setTokenType(tokenType == null ? SINGLE_USE : tokenType)
|
||||
.setAllowedRegistrarIds(
|
||||
ImmutableSet.copyOf(nullToEmpty(allowedClientIds)))
|
||||
|
||||
@@ -23,10 +23,12 @@ import static google.registry.persistence.transaction.TransactionManagerUtil.tra
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.internal.Nullable;
|
||||
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 google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.tools.params.TransitionListParameter.TokenStatusTransitions;
|
||||
@@ -88,6 +90,17 @@ final class UpdateAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
|
||||
+ "form <time>=<status>[,<time>=<status>]* where each status represents the status.")
|
||||
private ImmutableSortedMap<DateTime, TokenStatus> tokenStatusTransitions;
|
||||
|
||||
@Parameter(
|
||||
names = {"--renewal_price_behavior"},
|
||||
description =
|
||||
"The type of renewal price behavior, either DEFAULT (default), NONPREMIUM, or SPECIFIED."
|
||||
+ " This indicates how a domain should be charged for renewal. By default, a domain"
|
||||
+ " will be renewed at the renewal price from the pricing engine. If the renewal"
|
||||
+ " price behavior is set to SPECIFIED, it means that the renewal cost will be the"
|
||||
+ " same as the domain's calculated create price.")
|
||||
@Nullable
|
||||
private RenewalPriceBehavior renewalPriceBehavior;
|
||||
|
||||
private static final int BATCH_SIZE = 20;
|
||||
private static final Joiner JOINER = Joiner.on(", ");
|
||||
|
||||
@@ -142,6 +155,8 @@ final class UpdateAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
|
||||
Optional.ofNullable(discountPremiums).ifPresent(builder::setDiscountPremiums);
|
||||
Optional.ofNullable(discountYears).ifPresent(builder::setDiscountYears);
|
||||
Optional.ofNullable(tokenStatusTransitions).ifPresent(builder::setTokenStatusTransitions);
|
||||
Optional.ofNullable(renewalPriceBehavior)
|
||||
.ifPresent(behavior -> builder.setRenewalPriceBehavior(renewalPriceBehavior));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user