import com.fasterxml.jackson.module.kotlin.readValue
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheck
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheckList
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.healthcheck.K8sRbInstanceHealthCheckSimple
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
}
}
- fun getInstanceHealthCheckList(instanceId: String): List<K8sRbInstanceHealthCheck>? {
+ fun getInstanceHealthCheckList(instanceId: String): K8sRbInstanceHealthCheckList? {
val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
)
log.debug(result.toString())
return if (result.status in 200..299) {
- val objectMapper = jacksonObjectMapper()
- val parsedObject: ArrayList<K8sRbInstanceHealthCheck>? = objectMapper.readValue(result.body)
+ val parsedObject: K8sRbInstanceHealthCheckList? = JacksonUtils.readValue(
+ result.body,
+ K8sRbInstanceHealthCheckList::class.java
+ )
parsedObject
} else if (result.status == 500 && result.body.contains("Error finding master table"))
null
}
}
- fun startInstanceHealthCheck(instanceId: String): K8sRbInstanceHealthCheck? {
+ fun startInstanceHealthCheck(instanceId: String): K8sRbInstanceHealthCheckSimple? {
val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
)
log.debug(result.toString())
return if (result.status in 200..299) {
- val parsedObject: K8sRbInstanceHealthCheck? = JacksonUtils.readValue(
+ val parsedObject: K8sRbInstanceHealthCheckSimple? = JacksonUtils.readValue(
result.body,
- K8sRbInstanceHealthCheck::class.java
+ K8sRbInstanceHealthCheckSimple::class.java
)
parsedObject
} else if (result.status == 500 && result.body.contains("Error finding master table"))
import com.fasterxml.jackson.annotation.JsonProperty
+class K8sRbInstanceHealthCheckSimple {
+
+ @get:JsonProperty("healthcheck-id")
+ var id: String? = null
+
+ @get:JsonProperty("status")
+ var status: String? = null
+
+ override fun toString(): String {
+ return "$id:$status"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return javaClass.hashCode()
+ }
+}
+
+class K8sRbInstanceHealthCheckList {
+
+ @get:JsonProperty("instance-id")
+ var instanceId: String? = null
+
+ @get:JsonProperty("healthcheck-summary")
+ var healthcheckSummary: List<K8sRbInstanceHealthCheckSimple>? = null
+
+ @get:JsonProperty("hooks")
+ var hooks: List<K8sRbInstanceHealthCheckHook>? = null
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return javaClass.hashCode()
+ }
+}
+
class K8sRbInstanceHealthCheck {
- @get:JsonProperty("Id")
+ @get:JsonProperty("healthcheck-id")
var id: String? = null
- @get:JsonProperty("StartedAt")
- var startedAt: String? = null
+ @get:JsonProperty("instance-id")
+ var instanceId: String? = null
- @get:JsonProperty("CompletedAt")
- var completedAt: String? = null
+ @get:JsonProperty("info")
+ var info: String? = null
- @get:JsonProperty("Status")
+ @get:JsonProperty("status")
var status: String? = null
- @get:JsonProperty("Tests")
- var tests: List<K8sHealthCheckTest>? = null
+ @get:JsonProperty("test-suite")
+ var testSuite: K8sHealthCheckTest? = null
override fun toString(): String {
return "$id:$status"
class K8sHealthCheckTest {
- @get:JsonProperty("Name")
- var name: String? = null
-
@get:JsonProperty("StartedAt")
var startedAt: String? = null
@get:JsonProperty("Status")
var status: String? = null
- @get:JsonProperty("Info")
- var info: String? = null
+ @get:JsonProperty("TestManifests")
+ var testManifests: List<String>? = null
- override fun toString(): String {
- return "$name:$status"
+ @get:JsonProperty("Results")
+ var results: List<Any>? = null
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return javaClass.hashCode()
}
+}
+
+class K8sRbInstanceHealthCheckHook {
+
+ @get:JsonProperty("name")
+ var name: String? = null
+
+ @get:JsonProperty("kind")
+ var kind: String? = null
+
+ @get:JsonProperty("path")
+ var path: String? = null
+
+ @get:JsonProperty("manifest")
+ var manifest: String? = null
+
+ @get:JsonProperty("events")
+ var events: List<Any>? = null
override fun equals(other: Any?): Boolean {
if (this === other) return true