summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
authorFrank Kimmlingen <frank.kimmlingen@telekom.de>2023-03-21 16:18:16 +0100
committerFrank Kimmlingen <frank.kimmlingen@telekom.de>2023-03-29 07:45:50 +0000
commit97c07491d6dfb1fca6e4aeebaf7318324c1d3eb4 (patch)
tree754d0c92e6d3b9dc653dfa58006d44687df0eac9 /ms/blueprintsprocessor/functions
parent4d906e5210c570678bba6db82d85b16ff2ebaaf8 (diff)
K8sPlugin: support UAT functionality
K8sAbstractRestClientService and all derived classes K8sQueryRestClient K8sRbInstanceRestClient K8sDefinitionRestClient K8sUploadFileRestClientService does not support the spy / verify functionality of UatExecutor / UatServices Issue-ID: CCSDK-3872 Signed-off-by: Frank Kimmlingen <frank.kimmlingen@telekom.de> Change-Id: Iee30f48e9d86efd07a2ab6dde0d5743e4657934f
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt14
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt22
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sPluginDefinitionApi.kt101
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sUploadFileRestClientService.kt61
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sPluginInstanceApi.kt47
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt16
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sPluginQueryApi.kt3
-rw-r--r--ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt16
8 files changed, 154 insertions, 126 deletions
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt
index f0f8e298d..e979a21c1 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/K8sAbstractRestClientService.kt
@@ -23,6 +23,7 @@ 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.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
abstract class K8sAbstractRestClientService(
@@ -65,4 +66,17 @@ abstract class K8sAbstractRestClientService(
}
abstract fun apiUrl(): String
+
+ companion object {
+ fun getInterceptedWebclientService(
+ service: K8sAbstractRestClientService,
+ clientName: String
+ ): BlueprintWebClientService {
+ val restLibPropertyService: BluePrintRestLibPropertyService =
+ BluePrintDependencyService.instance(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+ return restLibPropertyService.interceptExternalBlueprintWebClientService(
+ service, clientName
+ )
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt
index 224c6a884..051c025f4 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sDefinitionRestClient.kt
@@ -21,13 +21,31 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sAbstractRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
open class K8sDefinitionRestClient(
k8sConfiguration: K8sConnectionPluginConfiguration,
private val definition: String,
- private val definitionVersion: String
-) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-definition") {
+ private val definitionVersion: String,
+ private val clientName: String = CLIENT_NAME
+) : K8sAbstractRestClientService(k8sConfiguration, CLIENT_NAME) {
+ companion object {
+ public const val CLIENT_NAME = "k8s-plugin-definition"
+
+ fun getK8sDefinitionRestClient(
+ k8sConfiguration: K8sConnectionPluginConfiguration,
+ definition: String,
+ definitionVersion: String
+ ): BlueprintWebClientService {
+ val rbDefinitionService = K8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
+ return getInterceptedWebclientService(rbDefinitionService, CLIENT_NAME)
+ }
+ }
override fun apiUrl(): String {
return "$baseUrl/v1/rb/definition/$definition/$definitionVersion"
}
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sPluginDefinitionApi.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sPluginDefinitionApi.kt
index ed0b164ef..86c019aed 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sPluginDefinitionApi.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sPluginDefinitionApi.kt
@@ -22,6 +22,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.profile.K8sProfile
import com.fasterxml.jackson.module.kotlin.readValue
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.K8sDefinitionRestClient.Companion.getK8sDefinitionRestClient
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.template.K8sTemplate
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
@@ -41,12 +42,12 @@ class K8sPluginDefinitionApi(
private val objectMapper = ObjectMapper()
fun hasDefinition(definition: String, definitionVersion: String): Boolean {
- val rbDefinitionService = K8sDefinitionRestClient(
- k8sConfiguration,
- definition,
- definitionVersion
- )
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
GET.name,
"",
@@ -61,12 +62,12 @@ class K8sPluginDefinitionApi(
}
fun hasProfile(definition: String, definitionVersion: String, profileName: String): Boolean {
- val rbDefinitionService = K8sDefinitionRestClient(
- k8sConfiguration,
- definition,
- definitionVersion
- )
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
GET.name,
"/profile/$profileName",
@@ -81,12 +82,12 @@ class K8sPluginDefinitionApi(
}
fun getProfile(definition: String, definitionVersion: String, profileName: String): K8sProfile? {
- val rbDefinitionService = K8sDefinitionRestClient(
- k8sConfiguration,
- definition,
- definitionVersion
- )
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
GET.name,
"/profile/$profileName",
@@ -107,13 +108,13 @@ class K8sPluginDefinitionApi(
}
fun createProfile(definition: String, definitionVersion: String, profile: K8sProfile) {
- val rbDefinitionService = K8sDefinitionRestClient(
- k8sConfiguration,
- definition,
- definitionVersion
- )
val profileJsonString: String = objectMapper.writeValueAsString(profile)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
POST.name,
"/profile",
@@ -129,13 +130,13 @@ class K8sPluginDefinitionApi(
}
fun updateProfile(profile: K8sProfile) {
- val rbDefinitionService = K8sDefinitionRestClient(
- k8sConfiguration,
- profile.rbName!!,
- profile.rbVersion!!
- )
val profileJsonString: String = objectMapper.writeValueAsString(profile)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ profile.rbName!!,
+ profile.rbVersion!!
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
PUT.name,
"/profile/${profile.profileName}",
@@ -151,8 +152,12 @@ class K8sPluginDefinitionApi(
}
fun deleteProfile(definition: String, definitionVersion: String, profileName: String) {
- val rbDefinitionService = K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
DELETE.name,
"/profile/$profileName",
@@ -169,12 +174,12 @@ class K8sPluginDefinitionApi(
}
fun uploadProfileContent(definition: String, definitionVersion: String, profile: K8sProfile, filePath: Path) {
- val fileUploadService = K8sUploadFileRestClientService(
- k8sConfiguration,
- definition,
- definitionVersion
- )
try {
+ val fileUploadService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = fileUploadService.uploadBinaryFile(
"/profile/${profile.profileName}/content",
filePath
@@ -191,9 +196,13 @@ class K8sPluginDefinitionApi(
}
fun createTemplate(definition: String, definitionVersion: String, template: K8sTemplate) {
- val rbDefinitionService = K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion)
val templateJsonString: String = objectMapper.writeValueAsString(template)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
POST.name,
"/config-template",
@@ -210,8 +219,12 @@ class K8sPluginDefinitionApi(
}
fun uploadConfigTemplateContent(definition: String, definitionVersion: String, template: K8sTemplate, filePath: Path) {
- val fileUploadService = K8sUploadFileRestClientService(k8sConfiguration, definition, definitionVersion)
try {
+ val fileUploadService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = fileUploadService.uploadBinaryFile(
"/config-template/${template.templateName}/content",
filePath
@@ -227,8 +240,12 @@ class K8sPluginDefinitionApi(
}
fun deleteTemplate(definition: String, definitionVersion: String, templateName: String) {
- val rbDefinitionService = K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = rbDefinitionService.exchangeResource(
DELETE.name,
"/config-template/$templateName",
@@ -245,8 +262,12 @@ class K8sPluginDefinitionApi(
}
fun getTemplate(definition: String, definitionVersion: String, templateName: String): K8sTemplate {
- val rbDefinitionService = K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion)
try {
+ val rbDefinitionService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
val result: BlueprintWebClientService.WebClientResponse<String> = getTemplateRequest(rbDefinitionService, templateName)
log.debug(result.toString())
return objectMapper.readValue(result.body)
@@ -257,9 +278,13 @@ class K8sPluginDefinitionApi(
}
fun hasTemplate(definition: String, definitionVersion: String, templateName: String): Boolean {
- val rbDefinitionService = K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion)
try {
- val result: BlueprintWebClientService.WebClientResponse<String> = getTemplateRequest(rbDefinitionService, templateName)
+ val interceptedService = getK8sDefinitionRestClient(
+ k8sConfiguration,
+ definition,
+ definitionVersion
+ )
+ val result: BlueprintWebClientService.WebClientResponse<String> = getTemplateRequest(interceptedService, templateName)
log.debug(result.toString())
return result.status in 200..299
} catch (e: Exception) {
@@ -268,7 +293,7 @@ class K8sPluginDefinitionApi(
}
}
- private fun getTemplateRequest(rbDefinitionService: K8sDefinitionRestClient, templateName: String): BlueprintWebClientService.WebClientResponse<String> {
+ private fun getTemplateRequest(rbDefinitionService: BlueprintWebClientService, templateName: String): BlueprintWebClientService.WebClientResponse<String> {
return rbDefinitionService.exchangeResource(
GET.name,
"/config-template/$templateName",
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sUploadFileRestClientService.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sUploadFileRestClientService.kt
deleted file mode 100644
index e44c4eb04..000000000
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/definition/K8sUploadFileRestClientService.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- * Modifications Copyright © 2020 Orange.
- * Modifications Copyright © 2020 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition
-
-import org.apache.commons.io.IOUtils
-import org.apache.http.client.ClientProtocolException
-import org.apache.http.client.entity.EntityBuilder
-import org.apache.http.client.methods.HttpPost
-import org.apache.http.client.methods.HttpUriRequest
-import org.apache.http.message.BasicHeader
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.RestLoggerService
-import java.io.IOException
-import java.nio.charset.Charset
-import java.nio.file.Files
-import java.nio.file.Path
-
-class K8sUploadFileRestClientService(
- k8sConfiguration: K8sConnectionPluginConfiguration,
- definition: String,
- definitionVersion: String
-) : K8sDefinitionRestClient(k8sConfiguration, definition, definitionVersion) {
-
- @Throws(IOException::class, ClientProtocolException::class)
- private fun performHttpCall(httpUriRequest: HttpUriRequest): BlueprintWebClientService.WebClientResponse<String> {
- val httpResponse = httpClient().execute(httpUriRequest)
- val statusCode = httpResponse.statusLine.statusCode
- httpResponse.entity.content.use {
- val body = IOUtils.toString(it, Charset.defaultCharset())
- return BlueprintWebClientService.WebClientResponse(statusCode, body)
- }
- }
-
- fun uploadBinaryFile(path: String, filePath: Path): BlueprintWebClientService.WebClientResponse<String> {
- val convertedHeaders: Array<BasicHeader> = convertToBasicHeaders(defaultHeaders())
- val httpPost = HttpPost(host(path))
- val entity = EntityBuilder.create().setBinary(Files.readAllBytes(filePath)).build()
- httpPost.setEntity(entity)
- RestLoggerService.httpInvoking(convertedHeaders)
- httpPost.setHeaders(convertedHeaders)
- return performHttpCall(httpPost)
- }
-}
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 a99179599..b58a7eaf4 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
@@ -22,6 +22,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
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.K8sRbInstanceRestClient.Companion.getK8sRbInstanceRestClient
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
@@ -40,7 +41,7 @@ class K8sPluginInstanceApi(
private val log = LoggerFactory.getLogger(K8sPluginInstanceApi::class.java)!!
fun getInstanceList(): List<K8sRbInstance>? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -63,7 +64,7 @@ class K8sPluginInstanceApi(
}
fun getInstanceById(instanceId: String): K8sRbInstance? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -85,7 +86,7 @@ class K8sPluginInstanceApi(
}
fun getFullInstanceById(instanceId: String): K8sRbInstanceFull? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -122,7 +123,7 @@ class K8sPluginInstanceApi(
}
fun getInstanceStatus(instanceId: String): K8sRbInstanceStatus? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -152,7 +153,7 @@ class K8sPluginInstanceApi(
name: String? = null,
labels: Map<String, String>? = null
): K8sRbInstanceStatus? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
var path: String = "/query?ApiVersion=$apiVersion&Kind=$kind"
if (name != null)
@@ -185,7 +186,7 @@ class K8sPluginInstanceApi(
}
fun getInstanceHealthCheckList(instanceId: String): K8sRbInstanceHealthCheckList? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -210,7 +211,7 @@ class K8sPluginInstanceApi(
}
fun getInstanceHealthCheck(instanceId: String, healthCheckId: String): K8sRbInstanceHealthCheck? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -235,7 +236,7 @@ class K8sPluginInstanceApi(
}
fun startInstanceHealthCheck(instanceId: String): K8sRbInstanceHealthCheckSimple? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
POST.name,
@@ -260,7 +261,7 @@ class K8sPluginInstanceApi(
}
fun createConfigurationValues(configValues: K8sConfigValueRequest, instanceId: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
POST.name,
@@ -282,7 +283,7 @@ class K8sPluginInstanceApi(
}
fun editConfigurationValues(configValues: K8sConfigValueRequest, instanceId: String, configName: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
PUT.name,
@@ -304,7 +305,7 @@ class K8sPluginInstanceApi(
}
fun editConfigurationValuesByDelete(instanceId: String, configName: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
POST.name,
@@ -326,7 +327,7 @@ class K8sPluginInstanceApi(
}
fun hasConfigurationValues(instanceId: String, configName: String): Boolean {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -342,7 +343,7 @@ class K8sPluginInstanceApi(
}
fun hasConfigurationValuesVersion(instanceId: String, configName: String, version: String): Boolean {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -358,7 +359,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValues(instanceId: String, configName: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -380,7 +381,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValuesVersion(instanceId: String, configName: String, version: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -402,7 +403,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValuesVersionByTag(instanceId: String, configName: String, tag: String): K8sConfigValueResponse? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -424,7 +425,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValuesList(instanceId: String): List<K8sConfigValueResponse>? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -447,7 +448,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValuesVersionList(instanceId: String, configName: String): List<K8sConfigValueResponse>? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -470,7 +471,7 @@ class K8sPluginInstanceApi(
}
fun getConfigurationValuesTagList(instanceId: String, configName: String): List<K8sConfigValueTag>? {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
GET.name,
@@ -493,7 +494,7 @@ class K8sPluginInstanceApi(
}
fun deleteConfigurationValues(instanceId: String, configName: String, deleteConfigOnly: Boolean) {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
var path: String = "/config/$configName"
if (deleteConfigOnly)
@@ -513,7 +514,7 @@ class K8sPluginInstanceApi(
}
fun rollbackConfigurationValues(instanceId: String, configName: String, configVersion: String?, configTag: String?) {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val configValues = hashMapOf<String, String>()
if (configVersion != null)
@@ -535,7 +536,7 @@ class K8sPluginInstanceApi(
}
fun tagConfigurationValues(instanceId: String, configName: String, tagName: String) {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val configValues = hashMapOf<String, String>()
configValues["tag-name"] = tagName
@@ -554,7 +555,7 @@ class K8sPluginInstanceApi(
}
fun deleteInstanceHealthCheck(instanceId: String, healthCheckId: String) {
- val rbInstanceService = K8sRbInstanceRestClient(k8sConfiguration, instanceId)
+ val rbInstanceService = getK8sRbInstanceRestClient(k8sConfiguration, instanceId)
try {
val result: BlueprintWebClientService.WebClientResponse<String> = rbInstanceService.exchangeResource(
DELETE.name,
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt
index 9a28ed854..6e43d31b1 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/instance/K8sRbInstanceRestClient.kt
@@ -21,12 +21,28 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sAbstractRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
open class K8sRbInstanceRestClient(
k8sConfiguration: K8sConnectionPluginConfiguration,
private val instanceId: String = ""
) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-instance") {
+ companion object {
+ public const val CLIENT_NAME = "k8s-plugin-instance"
+
+ fun getK8sRbInstanceRestClient(
+ k8sConfiguration: K8sConnectionPluginConfiguration,
+ instanceId: String = ""
+ ): BlueprintWebClientService {
+ val rbInstanceService = K8sRbInstanceRestClient(
+ k8sConfiguration,
+ instanceId
+ )
+ return getInterceptedWebclientService(rbInstanceService, CLIENT_NAME)
+ }
+ }
+
override fun apiUrl(): String {
return if (instanceId != "")
"$baseUrl/v1/instance/$instanceId"
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sPluginQueryApi.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sPluginQueryApi.kt
index 36ebe1133..227ed6730 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sPluginQueryApi.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sPluginQueryApi.kt
@@ -1,6 +1,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.query
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.query.K8sQueryRestClient.Companion.getK8sQueryRestClient
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
@@ -20,7 +21,7 @@ public class K8sPluginQueryApi(
namespace: String? = null,
labels: Map<String, String>? = null
): K8sResourceStatus? {
- val rbQueryService = K8sQueryRestClient(k8sConfiguration)
+ val rbQueryService = getK8sQueryRestClient(k8sConfiguration)
try {
var path: String = "?CloudRegion=$cloudRegion&ApiVersion=$apiVersion&Kind=$kind"
if (name != null)
diff --git a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt
index b28c56d2d..9f97f9a3a 100644
--- a/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt
+++ b/ms/blueprintsprocessor/functions/k8s-connection-plugin/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/query/K8sQueryRestClient.kt
@@ -20,10 +20,24 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.query
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sAbstractRestClientService
import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
open class K8sQueryRestClient(
k8sConfiguration: K8sConnectionPluginConfiguration
-) : K8sAbstractRestClientService(k8sConfiguration, "k8s-plugin-query") {
+) : K8sAbstractRestClientService(k8sConfiguration, CLIENT_NAME) {
+
+ companion object {
+ public const val CLIENT_NAME = "k8s-plugin-query"
+
+ fun getK8sQueryRestClient(
+ k8sConfiguration: K8sConnectionPluginConfiguration
+ ): BlueprintWebClientService {
+ val rbQueryService = K8sQueryRestClient(
+ k8sConfiguration
+ )
+ return getInterceptedWebclientService(rbQueryService, CLIENT_NAME)
+ }
+ }
override fun apiUrl(): String {
return "$baseUrl/v1/query"