summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-02-19 19:23:11 +0100
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-02-19 19:24:06 +0100
commit06e30271064052de497480d17a046b49a58c5711 (patch)
treedf483825eefac6015c51d4a84f8f61f7b85cde37 /ms
parent29455ba616f0958f102fec008d4f8e46d7c14bbb (diff)
K8sPlugin Query API endpoint added
K8sPlugin Query API endpoint added Issue-ID: CCSDK-3146 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I10abfd986de0df0069b258276fe0ec0fc9b76bff
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt29
1 files changed, 29 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt
index 120c38044..e0366f994 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt
@@ -120,6 +120,35 @@ class K8sPluginInstanceApi(
}
}
+ fun queryInstanceStatus(instanceId: String, kind: String, apiVersion: String, name: String?, labels: String?): K8sRbInstanceStatus? {
+ val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ try {
+ var path: String = "/query?ApiVersion=$apiVersion&Kind=$kind"
+ if (name != null)
+ path = path.plus("&Name=$name")
+ if (labels != null)
+ path = path.plus("&Labels=$labels")
+ val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
+ GET.name,
+ path,
+ ""
+ )
+ log.debug(result.toString())
+ return if (result.status in 200..299) {
+ val parsedObject: K8sRbInstanceStatus? = JacksonUtils.readValue(
+ result.body, K8sRbInstanceStatus::class.java
+ )
+ parsedObject
+ } else if (result.status == 500 && result.body.contains("Error finding master table"))
+ null
+ else
+ throw BlueprintProcessorException(result.body)
+ } catch (e: Exception) {
+ log.error("Caught exception trying to get k8s rb instance")
+ throw BlueprintProcessorException("${e.message}")
+ }
+ }
+
fun getInstanceHealthCheckList(instanceId: String): List<K8sRbInstanceHealthCheck>? {
val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {