From f43125bb0444e3a2c0a94f2ae19a3a7b168c4b9b Mon Sep 17 00:00:00 2001 From: mcilwain Date: Wed, 17 Oct 2018 08:42:24 -0700 Subject: [PATCH] Add a RESERVED billing event flag for creates of reserved domains This is an additional signal we can use for the billing/invoicing pipeline that will be helfpul in targeting invoice rows that may need adjustment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217524250 --- .../registry/flows/domain/DomainCreateFlow.java | 15 ++++++++++++++- .../registry/flows/domain/DomainFlowUtils.java | 2 +- .../registry/model/billing/BillingEvent.java | 8 ++++++++ .../flows/domain/DomainCreateFlowTest.java | 4 ++-- .../google/registry/model/testdata/schema.txt | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/java/google/registry/flows/domain/DomainCreateFlow.java b/java/google/registry/flows/domain/DomainCreateFlow.java index 894d2421f..3feb56153 100644 --- a/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/java/google/registry/flows/domain/DomainCreateFlow.java @@ -23,6 +23,7 @@ import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReference import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse; import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes; import static google.registry.flows.domain.DomainFlowUtils.isAnchorTenant; +import static google.registry.flows.domain.DomainFlowUtils.isReserved; import static google.registry.flows.domain.DomainFlowUtils.isValidReservedCreate; import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers; import static google.registry.flows.domain.DomainFlowUtils.validateDomainAllowedOnCreateRestrictedTld; @@ -320,7 +321,14 @@ public class DomainCreateFlow implements TransactionalFlow { // Bill for the create. BillingEvent.OneTime createBillingEvent = createOneTimeBillingEvent( - registry, isAnchorTenant, isSunriseCreate, years, feesAndCredits, historyEntry, now); + registry, + isAnchorTenant, + isSunriseCreate, + isReserved(domainName, isSunriseCreate), + years, + feesAndCredits, + historyEntry, + now); // Create a new autorenew billing event and poll message starting at the expiration time. BillingEvent.Recurring autorenewBillingEvent = createAutorenewBillingEvent(historyEntry, registrationExpirationTime); @@ -507,6 +515,7 @@ public class DomainCreateFlow implements TransactionalFlow { Registry registry, boolean isAnchorTenant, boolean isSunriseCreate, + boolean isReserved, int years, FeesAndCredits feesAndCredits, HistoryEntry historyEntry, @@ -518,6 +527,10 @@ public class DomainCreateFlow implements TransactionalFlow { } if (isAnchorTenant) { flagsBuilder.add(Flag.ANCHOR_TENANT); + } else if (isReserved) { + // Don't add this flag if the domain is an anchor tenant (which are also reserved); only add + // it if it's reserved for other reasons. + flagsBuilder.add(Flag.RESERVED); } return new BillingEvent.OneTime.Builder() .setReason(Reason.CREATE) diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index 85843db84..8830a032a 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -453,7 +453,7 @@ public class DomainFlowUtils { private static final ImmutableSet RESERVED_TYPES = ImmutableSet.of(RESERVED_FOR_SPECIFIC_USE, RESERVED_FOR_ANCHOR_TENANT, FULLY_BLOCKED); - private static boolean isReserved(InternetDomainName domainName, boolean isSunrise) { + static boolean isReserved(InternetDomainName domainName, boolean isSunrise) { ImmutableSet types = getReservationTypes(domainName); return !Sets.intersection(types, RESERVED_TYPES).isEmpty() || !(isSunrise || intersection(TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE, types).isEmpty()); diff --git a/java/google/registry/model/billing/BillingEvent.java b/java/google/registry/model/billing/BillingEvent.java index 4d3c364dc..934eefd95 100644 --- a/java/google/registry/model/billing/BillingEvent.java +++ b/java/google/registry/model/billing/BillingEvent.java @@ -71,6 +71,14 @@ public abstract class BillingEvent extends ImmutableObject ANCHOR_TENANT, AUTO_RENEW, LANDRUSH, + /** + * This flag is used on create {@link OneTime} billing events for domains that were reserved. + * + *

This can happen when allocation tokens are used or superusers override a domain + * reservation. These cases can need special handling in billing/invoicing. Anchor tenants will + * never have this flag applied; they will have ANCHOR_TENANT instead. + */ + RESERVED, SUNRISE, /** * This flag will be added to any {@link OneTime} events that are created via, e.g., an diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index da4f3a562..e7fff05bd 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -1060,7 +1060,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase