Delete the BackfillRegistrarBillingAccounts scrap command (#1722)

This commit is contained in:
Ben McIlwain 2022-07-29 11:40:11 -04:00 committed by GitHub
parent 8862c8510d
commit 8138d73399
3 changed files with 0 additions and 61 deletions

View file

@ -15,7 +15,6 @@
package google.registry.tools; package google.registry.tools;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.tools.javascrap.BackfillRegistrarBillingAccountsCommand;
import google.registry.tools.javascrap.CompareEscrowDepositsCommand; import google.registry.tools.javascrap.CompareEscrowDepositsCommand;
/** Container class to create and run remote commands against a Datastore instance. */ /** Container class to create and run remote commands against a Datastore instance. */
@ -30,7 +29,6 @@ public final class RegistryTool {
public static final ImmutableMap<String, Class<? extends Command>> COMMAND_MAP = public static final ImmutableMap<String, Class<? extends Command>> COMMAND_MAP =
new ImmutableMap.Builder<String, Class<? extends Command>>() new ImmutableMap.Builder<String, Class<? extends Command>>()
.put("ack_poll_messages", AckPollMessagesCommand.class) .put("ack_poll_messages", AckPollMessagesCommand.class)
.put("backfill_registrar_billing_accounts", BackfillRegistrarBillingAccountsCommand.class)
.put("canonicalize_labels", CanonicalizeLabelsCommand.class) .put("canonicalize_labels", CanonicalizeLabelsCommand.class)
.put("check_domain", CheckDomainCommand.class) .put("check_domain", CheckDomainCommand.class)
.put("check_domain_claims", CheckDomainClaimsCommand.class) .put("check_domain_claims", CheckDomainClaimsCommand.class)

View file

@ -41,7 +41,6 @@ import google.registry.request.Modules.UrlConnectionServiceModule;
import google.registry.request.Modules.UrlFetchServiceModule; import google.registry.request.Modules.UrlFetchServiceModule;
import google.registry.request.Modules.UserServiceModule; import google.registry.request.Modules.UserServiceModule;
import google.registry.tools.AuthModule.LocalCredentialModule; import google.registry.tools.AuthModule.LocalCredentialModule;
import google.registry.tools.javascrap.BackfillRegistrarBillingAccountsCommand;
import google.registry.tools.javascrap.CompareEscrowDepositsCommand; import google.registry.tools.javascrap.CompareEscrowDepositsCommand;
import google.registry.util.UtilsModule; import google.registry.util.UtilsModule;
import google.registry.whois.NonCachingWhoisModule; import google.registry.whois.NonCachingWhoisModule;
@ -86,8 +85,6 @@ import javax.inject.Singleton;
interface RegistryToolComponent { interface RegistryToolComponent {
void inject(AckPollMessagesCommand command); void inject(AckPollMessagesCommand command);
void inject(BackfillRegistrarBillingAccountsCommand command);
void inject(CheckDomainClaimsCommand command); void inject(CheckDomainClaimsCommand command);
void inject(CheckDomainCommand command); void inject(CheckDomainCommand command);

View file

@ -1,56 +0,0 @@
// Copyright 2021 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.tools.javascrap;
import static com.google.common.base.Preconditions.checkState;
import static google.registry.model.OteAccountBuilder.DEFAULT_BILLING_ACCOUNT_MAP;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import com.beust.jcommander.Parameters;
import google.registry.config.RegistryEnvironment;
import google.registry.model.registrar.Registrar;
import google.registry.tools.CommandWithRemoteApi;
/**
* Backfills the billing account maps on all Registrars that don't have any set.
*
* <p>This should not (and cannot) be used on production. Its purpose is to backfill these values on
* sandbox, where most registrars have an empty billing account map, including all that were created
* for OT&amp;E. The same default billing account map is used for all registrars, and includes
* values for USD and JPY. The actual values here don't matter as we don't do invoicing on sandbox
* anyway.
*/
@Parameters(separators = " =", commandDescription = "Backfill registrar billing account maps.")
public class BackfillRegistrarBillingAccountsCommand implements CommandWithRemoteApi {
@Override
public void run() throws Exception {
checkState(
RegistryEnvironment.get() != RegistryEnvironment.PRODUCTION,
"Do not run this on production");
System.out.println("Populating billing account maps on all registrars missing them ...");
tm().transact(
() ->
tm().loadAllOfStream(Registrar.class)
.filter(r -> r.getBillingAccountMap().isEmpty())
.forEach(
r ->
tm().update(
r.asBuilder()
.setBillingAccountMap(DEFAULT_BILLING_ACCOUNT_MAP)
.build())));
System.out.println("Done!");
}
}