mirror of
https://github.com/dalbodeule/sh0rt.kr-pdns.git
synced 2025-06-08 18:58:20 +00:00
fix pdns api clients (retry 18x)
fix controllers.
This commit is contained in:
parent
f3857bae59
commit
506d62e5f0
@ -32,11 +32,14 @@ class DomainController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = domainService.getAllDomains().map { it.toDTO() })
|
return ApiResponseDTO(result = domainService.getAllDomains().map { it.toDTO() })
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,11 +57,14 @@ class DomainController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = domainService.getDomainById(cfid!!).toDTO())
|
return ApiResponseDTO(result = domainService.getDomainById(cfid!!).toDTO())
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,11 +80,14 @@ class DomainController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = domainService.createDomain(domain).toDTO())
|
return ApiResponseDTO(result = domainService.createDomain(domain).toDTO())
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,16 +105,14 @@ class DomainController(
|
|||||||
|
|
||||||
return ApiResponseDTO(result = DeleteResponseWithId(domain_id))
|
return ApiResponseDTO(result = DeleteResponseWithId(domain_id))
|
||||||
} catch (e: PowerDNSAPIException) {
|
} catch (e: PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
throw ResponseStatusException(
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
HttpStatus.EXPECTATION_FAILED,
|
e.errors.forEach{
|
||||||
ApiResponseDTO(
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
false,
|
}
|
||||||
errors = errors.map { ErrorOrMessage(idx++, it ?: "") },
|
|
||||||
result = listOf(null)
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,14 @@ class RecordController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = recordService.getRecordsByDomain(zone_id)?.map{ it } ?: listOf())
|
return ApiResponseDTO(result = recordService.getRecordsByDomain(zone_id)?.map{ it } ?: listOf())
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,11 +53,14 @@ class RecordController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = recordService.getRecord(zone_id, dns_record_id))
|
return ApiResponseDTO(result = recordService.getRecord(zone_id, dns_record_id))
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,11 +76,14 @@ class RecordController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = recordService.createRecord(zone_id, record))
|
return ApiResponseDTO(result = recordService.createRecord(zone_id, record))
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,11 +100,14 @@ class RecordController(
|
|||||||
val record_id = recordService.deleteRecord(zone_id, dns_record_id)
|
val record_id = recordService.deleteRecord(zone_id, dns_record_id)
|
||||||
return ApiResponseDTO(result = DeleteResponseWithId(record_id))
|
return ApiResponseDTO(result = DeleteResponseWithId(record_id))
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,11 +123,14 @@ class RecordController(
|
|||||||
try {
|
try {
|
||||||
return ApiResponseDTO(result = recordService.updateRecord(zone_id, dns_record_id, record))
|
return ApiResponseDTO(result = recordService.updateRecord(zone_id, dns_record_id, record))
|
||||||
} catch(e : PowerDNSAPIException) {
|
} catch(e : PowerDNSAPIException) {
|
||||||
val errors = mutableListOf(e.message)
|
|
||||||
errors.addAll(e.errors)
|
|
||||||
var idx = 0
|
var idx = 0
|
||||||
|
val errors = mutableListOf(ErrorOrMessage(idx, e.message ?: ""))
|
||||||
|
e.errors.forEach{
|
||||||
|
errors.add(ErrorOrMessage(idx++, it))
|
||||||
|
}
|
||||||
|
|
||||||
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
throw ResponseStatusException(HttpStatus.EXPECTATION_FAILED,
|
||||||
ApiResponseDTO(false, errors = errors.map { ErrorOrMessage(idx++, it ?: "") }, result = listOf(null)).toString()
|
ApiResponseDTO(false, errors = errors, result = listOf(null)).toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user