mirror of
https://github.com/dalbodeule/sh0rt.kr-pdns.git
synced 2025-06-08 18:58:20 +00:00
fix pdns api clients.
This commit is contained in:
parent
4d8323e888
commit
46967bbe6b
@ -26,7 +26,7 @@ class PowerDNSApiClient {
|
||||
}
|
||||
|
||||
fun createDomain(name: String): ResponseEntity<String> {
|
||||
val url = "$apiUrl/servers/localhost/zones"
|
||||
val url = "$apiUrl/api/v1/servers/localhost/zones"
|
||||
val headers = createHeaders()
|
||||
val domainRequest = DomainRequest("$name.", "Master", arrayOf(), arrayOf())
|
||||
val body = gson.toJson(domainRequest)
|
||||
@ -35,7 +35,7 @@ class PowerDNSApiClient {
|
||||
}
|
||||
|
||||
fun createRecord(domainName: String, recordRequest: RecordRequestDTO): ResponseEntity<String> {
|
||||
val url = "$apiUrl/servers/localhost/zones/$domainName."
|
||||
val url = "$apiUrl/api/v1/servers/localhost/zones/$domainName."
|
||||
val headers = createHeaders()
|
||||
val record = RecordRequest(
|
||||
name = "${recordRequest.name}.$domainName.",
|
||||
@ -50,7 +50,7 @@ class PowerDNSApiClient {
|
||||
}
|
||||
|
||||
fun deleteDomain(name: String): ResponseEntity<String> {
|
||||
val url = "$apiUrl/servers/localhost/zones/$name."
|
||||
val url = "$apiUrl/api/v1/servers/localhost/zones/$name."
|
||||
val headers = createHeaders()
|
||||
val entity = HttpEntity<String>(headers)
|
||||
return restTemplate.exchange(url, HttpMethod.DELETE, entity, String::class.java)
|
||||
|
@ -5,16 +5,12 @@ import org.springframework.stereotype.Service
|
||||
import space.mori.dnsapi.PowerDNSApiClient
|
||||
import space.mori.dnsapi.db.Domain
|
||||
import space.mori.dnsapi.db.DomainRepository
|
||||
import space.mori.dnsapi.db.UserRepository
|
||||
import space.mori.dnsapi.dto.DomainRequestDTO
|
||||
import space.mori.dnsapi.filter.getCurrentUser
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Service
|
||||
class DomainService(
|
||||
@Autowired
|
||||
private val userRepository: UserRepository,
|
||||
@Autowired
|
||||
private val domainRepository: DomainRepository,
|
||||
@Autowired
|
||||
@ -49,6 +45,11 @@ class DomainService(
|
||||
}
|
||||
|
||||
fun deleteDomain(domain_id: String): String {
|
||||
val domain = domainRepository.findByCfid(domain_id).orElseThrow {
|
||||
throw RuntimeException("Domain with CFID $domain_id not found")
|
||||
}
|
||||
|
||||
powerDNSApiClient.deleteDomain(domain.name)
|
||||
val count = domainRepository.deleteByCfid(domain_id)
|
||||
|
||||
if(count > 0) throw RuntimeException("Domain with CFID $domain_id not found")
|
||||
|
Loading…
x
Reference in New Issue
Block a user