diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java index 7182edda7..f87bd12ca 100644 --- a/java/google/registry/config/RegistryConfig.java +++ b/java/google/registry/config/RegistryConfig.java @@ -331,6 +331,18 @@ public final class RegistryConfig { return config.datastore.eppResourceIndexBucketsNum; } + @Provides + @Config("cloudDnsRootUrl") + public static Optional getCloudDnsRootUrl(RegistryConfigSettings config) { + return Optional.fromNullable(config.cloudDns.rootUrl); + } + + @Provides + @Config("cloudDnsServicePath") + public static Optional getCloudDnsServicePath(RegistryConfigSettings config) { + return Optional.fromNullable(config.cloudDns.servicePath); + } + /** * Returns size of Google Cloud Storage client connection buffer in bytes. * diff --git a/java/google/registry/config/RegistryConfigSettings.java b/java/google/registry/config/RegistryConfigSettings.java index 44380106f..c6aa08647 100644 --- a/java/google/registry/config/RegistryConfigSettings.java +++ b/java/google/registry/config/RegistryConfigSettings.java @@ -25,6 +25,7 @@ public class RegistryConfigSettings { public OAuth oAuth; public RegistryPolicy registryPolicy; public Datastore datastore; + public CloudDns cloudDns; public Caching caching; public IcannReporting icannReporting; public Rde rde; @@ -96,6 +97,12 @@ public class RegistryConfigSettings { public String projectId; } + /** Configuration for Cloud DNS. */ + public static class CloudDns { + public String rootUrl; + public String servicePath; + } + /** Configuration for caching. */ public static class Caching { public int singletonCacheRefreshSeconds; diff --git a/java/google/registry/config/files/default-config.yaml b/java/google/registry/config/files/default-config.yaml index c773d8202..b4b3577ac 100644 --- a/java/google/registry/config/files/default-config.yaml +++ b/java/google/registry/config/files/default-config.yaml @@ -110,6 +110,15 @@ datastore: # doubles after each failure). baseOfyRetryMillis: 100 +cloudDns: + # The root url for the Cloud DNS API. Set this to a non-null value to + # override the default API server used by the googleapis library. + rootUrl: null + + # The service endpoint path for the Cloud DNS API. Set this to a non-null + # value to override the default API path used by the googleapis library. + servicePath: null + caching: # Length of time that a singleton should be cached before expiring. singletonCacheRefreshSeconds: 600 diff --git a/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java b/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java index c62bd54b8..a706e0d17 100644 --- a/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java +++ b/java/google/registry/dns/writer/clouddns/CloudDnsWriterModule.java @@ -20,6 +20,7 @@ import com.google.api.client.json.JsonFactory; import com.google.api.services.dns.Dns; import com.google.api.services.dns.DnsScopes; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.util.concurrent.RateLimiter; import dagger.Module; import dagger.Provides; @@ -40,10 +41,20 @@ public final class CloudDnsWriterModule { HttpTransport transport, JsonFactory jsonFactory, Function, ? extends HttpRequestInitializer> credential, - @Config("projectId") String projectId) { - return new Dns.Builder(transport, jsonFactory, credential.apply(DnsScopes.all())) - .setApplicationName(projectId) - .build(); + @Config("projectId") String projectId, + @Config("cloudDnsRootUrl") Optional rootUrl, + @Config("cloudDnsServicePath") Optional servicePath) { + Dns.Builder builder = new Dns.Builder(transport, jsonFactory, credential.apply(DnsScopes.all())) + .setApplicationName(projectId); + + if (rootUrl.isPresent()) { + builder.setRootUrl(rootUrl.get()); + } + if (servicePath.isPresent()) { + builder.setServicePath(servicePath.get()); + } + + return builder.build(); } @Provides