Link the Registrar's RDAP server from RDAP domain replies

To do this we add a field of "rdapServers" in the Registrar object. Currently, we can only set this field manually, but a subsequent CL will add a cron-job to read these values from the ICANN servers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=252438618
This commit is contained in:
guyben 2019-06-10 10:54:19 -07:00 committed by jianglai
parent 7c64992c73
commit 4110cae814
14 changed files with 186 additions and 30 deletions

View file

@ -254,6 +254,11 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
description = "Hostname of registrar WHOIS server. (Default: whois.nic.google)")
String whoisServer;
@Parameter(
names = "--rdap_servers",
description = "Comma-delimited list of RDAP servers. An empty argument clears the list")
List<String> rdapServers = new ArrayList<>();
/** Returns the existing registrar (for update) or null (for creates). */
@Nullable
abstract Registrar getOldRegistrar(String clientId);
@ -389,6 +394,15 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
Optional.ofNullable(icannReferralEmail).ifPresent(builder::setIcannReferralEmail);
Optional.ofNullable(whoisServer).ifPresent(builder::setWhoisServer);
if (!rdapServers.isEmpty()) {
// If we only have empty strings, then remove all the RDAP servers
// This is to differentiate between "I didn't set the rdapServers because I don't want to
// change them" and "I set the RDAP servers to an empty string because I want no RDAP
// servers".
builder.setRdapBaseUrls(
rdapServers.stream().filter(server -> !server.isEmpty()).collect(toImmutableSet()));
}
// If the registrarName is being set, verify that it is either null or it normalizes uniquely.
String oldRegistrarName = (oldRegistrar == null) ? null : oldRegistrar.getRegistrarName();
if (registrarName != null && !registrarName.equals(oldRegistrarName)) {