summaryrefslogtreecommitdiffstats
path: root/runtime/src/main/resources/clds/camel
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2021-06-09 14:24:00 +0100
committersaul.gill <saul.gill@est.tech>2021-06-11 13:46:42 +0100
commitee7faff4b6e292237ccdac5e19cd0b438ea91e52 (patch)
tree605243de9fa8de87447daa2027c78ace949ecfcf /runtime/src/main/resources/clds/camel
parentd7226091d3435926271c3d3443e6986f4c985803 (diff)
Create camel endpoint to get tosca from runtime
Endpoint points to Runtime Tosca Service Template endpoint Added new authorization role for control loop Credentials in configuration file Issue-ID: POLICY-3222 Change-Id: I86f8cc5751547abfa15e10903d7e2fb2854f1ece Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'runtime/src/main/resources/clds/camel')
-rw-r--r--runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml38
-rw-r--r--runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml33
2 files changed, 71 insertions, 0 deletions
diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 4659a90bf..6a5da8710 100644
--- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -1461,6 +1461,44 @@
</route>
</post>
+ <get uri="/v2/toscaControlLoop/getToscaTemplate" outType="java.lang.String" bindingMode="off" produces="application/json">
+ <route>
+ <removeHeaders pattern="*"
+ excludePattern="name|version"/>
+ <doTry>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Tosca Service Template ')"/>
+ <to
+ uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setProperty name="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ <to uri="direct:get-service-template"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/>
+ <log loggingLevel="ERROR"
+ message="GET Tosca Service Template JSON request failed: ${exception.stacktrace}"/>
+ <setHeader name="CamelHttpResponseCode">
+ <constant>500</constant>
+ </setHeader>
+ <setBody>
+ <simple>GET Tosca Service Template JSON FAILED</simple>
+ </setBody>
+ </doCatch>
+ </doTry>
+ </route>
+ </get>
+
<get uri="/v2/clampInformation" outType="org.onap.policy.clamp.clds.model.ClampInformation"
produces="application/json">
<route>
diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
new file mode 100644
index 000000000..b1fad103b
--- /dev/null
+++ b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
@@ -0,0 +1,33 @@
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route id="get-service-template">
+ <from uri="direct:get-service-template"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting the tosca service template"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Controlloop', 'Getting the tosca service template')"/>
+ <setHeader name="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setProperty name="name">
+ <simple>${header.name}</simple>
+ </setProperty>
+ <setProperty name="version">
+ <simple>${header.version}</simple>
+ </setProperty>
+ <log loggingLevel="INFO"
+ message="Endpoint to get Tosca Service Template: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/toscaservicetemplate"></log>
+ <toD
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/toscaservicetemplate?name=${exchangeProperty[name]}&amp;version=${exchangeProperty[version]}&amp;bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.controlloop.runtime.userName}}&amp;authPassword={{clamp.config.controlloop.runtime.password}}&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
+</routes>