From fc7bbfac17f314379ab6bf10523808c170241812 Mon Sep 17 00:00:00 2001 From: Thilo Schwarz Date: Sun, 27 Oct 2024 12:07:35 +0100 Subject: [PATCH] Refactor zone import configuration and update docs --- README.adoc | 3 ++- docs/dyndrest-configuration.adoc | 23 +++++++++++++++---- .../model/config/ZoneImportConfig.java | 23 +++++++++++-------- src/main/resources/application.yml | 15 ++++++------ src/test/resources/application-test.yml | 9 +++++--- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/README.adoc b/README.adoc index dcfd00b..62a7431 100644 --- a/README.adoc +++ b/README.adoc @@ -117,7 +117,8 @@ dyndrest: - name: dynhost.info ns: ns.domain.info hosts: - - myhost:1234567890abcdef + - sld: myhost + api-token: 1234567890abcdef domainrobot: autodns: diff --git a/docs/dyndrest-configuration.adoc b/docs/dyndrest-configuration.adoc index a9850af..359bd32 100644 --- a/docs/dyndrest-configuration.adoc +++ b/docs/dyndrest-configuration.adoc @@ -117,12 +117,25 @@ spring: [source,yaml] ---- -spring: - security: - user: - name: oauthuser - password: oauthpasswd +domainrobot: + autodns: + user: userName + password: secretPwd +---- +That's the minimal setting for the domainrobot-api. For further fine adjustments, the following settings can be overwritten or changed: +[source,yaml] +---- +domainrobot: + default-ttl: 60 + # connection properties + autodns: + context: 4 + url: https://api.autodns.com/v1 + # custom headers + custom-header: + X-Domainrobot-WS: NONE ---- + [[backup_restore]] === Backup and Restore diff --git a/src/main/java/codes/thischwa/dyndrest/model/config/ZoneImportConfig.java b/src/main/java/codes/thischwa/dyndrest/model/config/ZoneImportConfig.java index 4e15e32..8279353 100644 --- a/src/main/java/codes/thischwa/dyndrest/model/config/ZoneImportConfig.java +++ b/src/main/java/codes/thischwa/dyndrest/model/config/ZoneImportConfig.java @@ -26,16 +26,10 @@ public List getHosts() { return enrichedHosts; } for (ZoneImportConfig.Zone zone : zones) { - for (String hostRaw : zone.hosts()) { - String[] parts = hostRaw.split(":"); - if (parts.length != 2) { - throw new IllegalArgumentException( - "The host entry must be in the following format: [sld|:[apiToken], but it was: " - + hostRaw); - } + for (Host host : zone.hosts()) { HostEnriched hostEnriched = new HostEnriched(); - hostEnriched.setName(parts[0]); - hostEnriched.setApiToken(parts[1]); + hostEnriched.setName(host.sld()); + hostEnriched.setApiToken(host.apiToken()); hostEnriched.setZone(zone.name); hostEnriched.setNs(zone.ns); enrichedHosts.add(hostEnriched); @@ -51,5 +45,14 @@ public List getHosts() { * @param ns name server * @param hosts host / subdomains */ - public record Zone(String name, String ns, List hosts) {} + public record Zone(String name, String ns, List hosts) {} + + + /** + * Represents a Host entity with an sld (second-level domain) and an apiToken. + * + * @param sld The second-level domain associated with the host. + * @param apiToken The API token for authentication or other purposes. + */ + public record Host(String sld, String apiToken) {} } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a75ae78..fdf639a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -36,13 +36,6 @@ dyndrest: path: ./restore dump-file: dump.sql -## disable springdoc endpoints and swagger-ui by default -springdoc: - api-docs: - enabled: false - swagger-ui: - enabled: false - ## configuration for the domain robot sdk domainrobot: default-ttl: 60 @@ -54,6 +47,14 @@ domainrobot: custom-header: X-Domainrobot-WS: NONE + +## disable springdoc endpoints and swagger-ui by default +springdoc: + api-docs: + enabled: false + swagger-ui: + enabled: false + ## import of the individual configuration settings spring: config: diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index b119ba1..b86cf6c 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -73,12 +73,15 @@ dyndrest: - name: dynhost0.info ns: ns0.domain.info hosts: - - my3:api1 + - sld: my3 + api-token: api1 - name: zone1.info ns: ns1.domain.info hosts: - - host1:abc - - host2:123 + - sld: host1 + api-token: abc + - sld: host2 + api-token: 123 domainrobot: default-ttl: 61