Refactor rest clients and support timeouts
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / rest-lib / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / rest / BluePrintRestLibConfiguration.kt
index 05143f3..6e9e4b5 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright © 2019 IBM.
+ * Modifications Copyright © 2019 Huawei.
  *
  * 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.rest
 
+import com.fasterxml.jackson.databind.JsonNode
+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
 import org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.context.annotation.ComponentScan
 import org.springframework.context.annotation.Configuration
@@ -26,14 +31,31 @@ import org.springframework.context.annotation.Configuration
 @EnableConfigurationProperties
 open class BluePrintRestLibConfiguration
 
+/**
+ * Exposed Dependency Service by this Rest Lib Module
+ */
+fun BluePrintDependencyService.restLibPropertyService(): BluePrintRestLibPropertyService =
+    instance(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+
+fun BluePrintDependencyService.restClientService(selector: String): BlueprintWebClientService {
+    return restLibPropertyService().blueprintWebClientService(selector)
+}
+
+fun BluePrintDependencyService.restClientService(jsonNode: JsonNode): BlueprintWebClientService {
+    return restLibPropertyService().blueprintWebClientService(jsonNode)
+}
 
 class RestLibConstants {
     companion object {
+
         const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
+        const val PROPERTY_REST_CLIENT_PREFIX = "blueprintsprocessor.restclient."
+        const val PROPERTY_TYPE = "type"
         const val TYPE_TOKEN_AUTH = "token-auth"
         const val TYPE_BASIC_AUTH = "basic-auth"
         const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
-        const val TYPE_DME2_PROXY = "dme2-proxy"
+        const val TYPE_SSL_TOKEN_AUTH = "ssl-token-auth"
+        const val TYPE_SSL_NO_AUTH = "ssl-no-auth"
         const val TYPE_POLICY_MANAGER = "policy-manager"
     }
-}
\ No newline at end of file
+}