Add a property in Registry to disable invoicing (#644)

The added property will by default be null for existing entities and false for new entities. We could write a temporary MapReduce to set it to false for all existing ones, but it seems easier to just modify the query to account for the nullness of the column. The need to check for null won't exist once we migrate the Registry entity to Cloud SQL.

TESTED=deployed to alpha, set the property for tld zombo to true and triggered an export, verified that the column is null for all rows other than the row for zombo.
This commit is contained in:
Lai Jiang 2020-06-24 16:21:38 -04:00 committed by GitHub
parent 071800ae50
commit a65a3fd8b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 2 deletions

View file

@ -56,7 +56,8 @@ FROM (
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRY_TABLE%` `%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRY_TABLE%`
WHERE WHERE
-- TODO(b/18092292): Add a filter for tldState (not PDT/PREDELEGATION) -- TODO(b/18092292): Add a filter for tldState (not PDT/PREDELEGATION)
tldType = 'REAL') ) AS BillingEvent tldType = 'REAL'
AND disableInvoicing is not TRUE) ) AS BillingEvent
-- Gather billing ID from registrar table -- Gather billing ID from registrar table
-- This is a 'JOIN' as opposed to 'LEFT JOIN' to filter out -- This is a 'JOIN' as opposed to 'LEFT JOIN' to filter out
-- non-billable registrars -- non-billable registrars

View file

@ -339,6 +339,14 @@ public class Registry extends ImmutableObject implements Buildable {
/** The type of the TLD, whether it's real or for testing. */ /** The type of the TLD, whether it's real or for testing. */
TldType tldType = TldType.REAL; TldType tldType = TldType.REAL;
/**
* Whether to disable invoicing for a {@link TldType#REAL} TLD.
*
* <p>Note that invoicing is always disabled for {@link TldType#TEST} TLDs. Setting this field has
* no effect for {@link TldType#TEST} TLDs.
*/
boolean disableInvoicing = false;
/** /**
* A property that transitions to different TldStates at different times. Stored as a list of * A property that transitions to different TldStates at different times. Stored as a list of
* TldStateTransition embedded objects using the @Mapify annotation. * TldStateTransition embedded objects using the @Mapify annotation.
@ -637,6 +645,11 @@ public class Registry extends ImmutableObject implements Buildable {
return this; return this;
} }
public Builder setDisableInvoicing(boolean disableInvoicing) {
getInstance().disableInvoicing = disableInvoicing;
return this;
}
/** Sets the TLD state to transition to the specified states at the specified times. */ /** Sets the TLD state to transition to the specified states at the specified times. */
public Builder setTldStateTransitions(ImmutableSortedMap<DateTime, TldState> tldStatesMap) { public Builder setTldStateTransitions(ImmutableSortedMap<DateTime, TldState> tldStatesMap) {
checkNotNull(tldStatesMap, "TLD states map cannot be null"); checkNotNull(tldStatesMap, "TLD states map cannot be null");

View file

@ -116,6 +116,13 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
description = "Tld type (REAL or TEST)") description = "Tld type (REAL or TEST)")
private TldType tldType; private TldType tldType;
@Nullable
@Parameter(
names = "--disable_invoicing",
description = "Whether invoicing is disabled for a REAL tld.",
arity = 1)
private Boolean disableInvoicing;
@Nullable @Nullable
@Parameter( @Parameter(
names = "--create_billing_cost", names = "--create_billing_cost",
@ -320,6 +327,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
Optional.ofNullable(serverStatusChangeCost) Optional.ofNullable(serverStatusChangeCost)
.ifPresent(builder::setServerStatusChangeBillingCost); .ifPresent(builder::setServerStatusChangeBillingCost);
Optional.ofNullable(tldType).ifPresent(builder::setTldType); Optional.ofNullable(tldType).ifPresent(builder::setTldType);
Optional.ofNullable(disableInvoicing).ifPresent(builder::setDisableInvoicing);
Optional.ofNullable(lordnUsername).ifPresent(u -> builder.setLordnUsername(u.orElse(null))); Optional.ofNullable(lordnUsername).ifPresent(u -> builder.setLordnUsername(u.orElse(null)));
Optional.ofNullable(claimsPeriodEnd).ifPresent(builder::setClaimsPeriodEnd); Optional.ofNullable(claimsPeriodEnd).ifPresent(builder::setClaimsPeriodEnd);
Optional.ofNullable(numDnsPublishShards).ifPresent(builder::setNumDnsPublishLocks); Optional.ofNullable(numDnsPublishShards).ifPresent(builder::setNumDnsPublishLocks);

View file

@ -56,7 +56,8 @@ FROM (
`my-project-id.latest_datastore_export.Registry` `my-project-id.latest_datastore_export.Registry`
WHERE WHERE
-- TODO(b/18092292): Add a filter for tldState (not PDT/PREDELEGATION) -- TODO(b/18092292): Add a filter for tldState (not PDT/PREDELEGATION)
tldType = 'REAL') ) AS BillingEvent tldType = 'REAL'
AND disableInvoicing is not TRUE) ) AS BillingEvent
-- Gather billing ID from registrar table -- Gather billing ID from registrar table
-- This is a 'JOIN' as opposed to 'LEFT JOIN' to filter out -- This is a 'JOIN' as opposed to 'LEFT JOIN' to filter out
-- non-billable registrars -- non-billable registrars

View file

@ -494,6 +494,7 @@ enum google.registry.model.registrar.RegistrarContact$Type {
class google.registry.model.registry.Registry { class google.registry.model.registry.Registry {
@Id java.lang.String tldStrId; @Id java.lang.String tldStrId;
@Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent; @Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent;
boolean disableInvoicing;
boolean dnsPaused; boolean dnsPaused;
boolean escrowEnabled; boolean escrowEnabled;
com.googlecode.objectify.Key<google.registry.model.registry.label.PremiumList> premiumList; com.googlecode.objectify.Key<google.registry.model.registry.label.PremiumList> premiumList;