mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Refactor CreateDomainCommand and add UpdateDomainCommand
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160282921
This commit is contained in:
parent
30d5d05fdf
commit
bbdf9bfc38
18 changed files with 944 additions and 80 deletions
82
java/google/registry/tools/CreateOrUpdateDomainCommand.java
Normal file
82
java/google/registry/tools/CreateOrUpdateDomainCommand.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
// Copyright 2017 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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.util.CollectionUtils.findDuplicates;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** Shared base class for commands to create or update a Domain via EPP. */
|
||||
abstract class CreateOrUpdateDomainCommand extends MutatingEppToolCommand {
|
||||
|
||||
@Parameter(
|
||||
names = {"-c", "--client"},
|
||||
description = "Client identifier of the registrar to execute the command as",
|
||||
required = true
|
||||
)
|
||||
String clientId;
|
||||
|
||||
@Parameter(description = "Names of the domains", required = true)
|
||||
private List<String> mainParameters;
|
||||
|
||||
@Parameter(
|
||||
names = {"-n", "--nameservers"},
|
||||
description = "Comma-separated list of nameservers, up to 13."
|
||||
)
|
||||
List<String> nameservers = new ArrayList<>();
|
||||
|
||||
@Parameter(
|
||||
names = {"-r", "--registrant"},
|
||||
description = "Domain registrant."
|
||||
)
|
||||
String registrant;
|
||||
|
||||
@Parameter(
|
||||
names = {"-a", "--admins"},
|
||||
description = "Comma-separated list of admin contacts."
|
||||
)
|
||||
List<String> admins = new ArrayList<>();
|
||||
|
||||
@Parameter(
|
||||
names = {"-t", "--techs"},
|
||||
description = "Comma-separated list of technical contacts."
|
||||
)
|
||||
List<String> techs = new ArrayList<>();
|
||||
|
||||
@Parameter(
|
||||
names = {"-p", "--password"},
|
||||
description = "Password."
|
||||
)
|
||||
String password;
|
||||
|
||||
Set<String> domains;
|
||||
|
||||
@Override
|
||||
protected void initEppToolCommand() throws Exception {
|
||||
checkArgument(nameservers.size() <= 13, "There can be at most 13 nameservers.");
|
||||
|
||||
String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters));
|
||||
checkArgument(duplicates.isEmpty(), "Duplicate arguments found: '%s'", duplicates);
|
||||
domains = ImmutableSet.copyOf(mainParameters);
|
||||
|
||||
initMutatingEppToolCommand();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue