fix pdns api clients (retry 2x)

This commit is contained in:
dalbodeule 2024-06-06 23:58:18 +09:00
parent 46967bbe6b
commit bbe4b93b89
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
2 changed files with 6 additions and 3 deletions

View File

@ -15,6 +15,9 @@ class PowerDNSApiClient {
@Value("\${pdns.api.key}")
private lateinit var apiKey: String
@Value("\${pdns.ns}")
private lateinit var ns: String
private val restTemplate = RestTemplate()
private val gson = Gson()
@ -28,7 +31,7 @@ class PowerDNSApiClient {
fun createDomain(name: String): ResponseEntity<String> {
val url = "$apiUrl/api/v1/servers/localhost/zones"
val headers = createHeaders()
val domainRequest = DomainRequest("$name.", "Master", arrayOf(), arrayOf())
val domainRequest = DomainRequest("$name.", "Native", arrayOf(), ns.split(",").toTypedArray())
val body = gson.toJson(domainRequest)
val entity = HttpEntity(body, headers)
return restTemplate.exchange(url, HttpMethod.POST, entity, String::class.java)

View File

@ -11,6 +11,6 @@ springdoc.swagger-ui.enabled=false
springdoc.api-docs.path=/api-docs
springdoc.default-consumes-media-type= application/json
springdoc.default-produces-media-type= application/json
springdoc.version= '@project.version@'
pdns.api.key=${PDNS_API_KEY}
pdns.api.url=${PDNS_API_URL}
pdns.ns=${PDNS_NS}