UATExecutor support for k8sConnectionPlugin 92/131392/2
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Thu, 6 Oct 2022 16:03:09 +0000 (18:03 +0200)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Thu, 6 Oct 2022 18:41:42 +0000 (18:41 +0000)
Issue-ID: CCSDK-3785
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Change-Id: Ice34d61ac62fe8935a6df539376dcbb9e998beaf

ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt
ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt
ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt
ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt

index b9c45e4..f0f8e29 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright © 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright © 2019 IBM.
  * Modifications Copyright © 2021 Orange.
- * Modifications Copyright © 2020 Deutsche Telekom AG.
+ * Modifications Copyright © 2022 Deutsche Telekom AG.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s
 
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
 
 abstract class K8sAbstractRestClientService(
-    private val k8sConfiguration: K8sConnectionPluginConfiguration
+    private val k8sConfiguration: K8sConnectionPluginConfiguration,
+    clientName: String
 ) : BasicAuthRestClientService(BasicAuthRestClientProperties()) {
 
+    init {
+        val service: BluePrintRestLibPropertyService = BluePrintDependencyService.instance(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+        service.interceptExternalBlueprintWebClientService(this, clientName)
+    }
+
     protected val baseUrl: String = k8sConfiguration.getProperties().url
     private var restClientProperties: BasicAuthRestClientProperties? = null
 
index 0c95fe3..224c6a8 100644 (file)
@@ -26,7 +26,7 @@ open class K8sDefinitionRestClient(
     k8sConfiguration: K8sConnectionPluginConfiguration,
     private val definition: String,
     private val definitionVersion: String
-) : K8sAbstractRestClientService(k8sConfiguration) {
+) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-definition") {
 
     override fun apiUrl(): String {
         return "$baseUrl/v1/rb/definition/$definition/$definitionVersion"
index 4c4da62..9a28ed8 100644 (file)
@@ -25,7 +25,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginC
 open class K8sRbInstanceRestClient(
     k8sConfiguration: K8sConnectionPluginConfiguration,
     private val instanceId: String = ""
-) : K8sAbstractRestClientService(k8sConfiguration) {
+) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-instance") {
 
     override fun apiUrl(): String {
         return if (instanceId != "")
index 672a366..b28c56d 100644 (file)
@@ -23,7 +23,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginC
 
 open class K8sQueryRestClient(
     k8sConfiguration: K8sConnectionPluginConfiguration
-) : K8sAbstractRestClientService(k8sConfiguration) {
+) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-query") {
 
     override fun apiUrl(): String {
         return "$baseUrl/v1/query"
index 4f91e54..ac6cac2 100644 (file)
@@ -63,6 +63,14 @@ open class BluePrintRestLibPropertyService(private var bluePrintPropertiesServic
         return postInterceptor?.getInstance(selector, service) ?: service
     }
 
+    open fun interceptExternalBlueprintWebClientService(
+        externalService: BlueprintWebClientService,
+        selector: String
+    ): BlueprintWebClientService {
+        val service = preInterceptor?.getInstance(selector) ?: externalService
+        return postInterceptor?.getInstance(selector, service) ?: service
+    }
+
     fun restClientProperties(prefix: String): RestClientProperties {
         val type = bluePrintPropertiesService.propertyBeanType(
             "$prefix.type", String::class.java