2 * Copyright © 2018-2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
19 import com.fasterxml.jackson.databind.JsonNode
20 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
21 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
22 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
23 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
24 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
25 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
26 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.AbstractNodeTemplateOperationImplBuilder
27 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
28 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
30 /** Component Extensions **/
32 fun BluePrintTypes.nodeTypeComponentRemoteScriptExecutor(): NodeType {
34 id = "component-remote-script-executor", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
35 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
36 description = "Generic Remote Script Component Executor"
38 /** Attribute definitions */
40 ComponentRemoteScriptExecutor.ATTRIBUTE_RESPONSE_DATA, BluePrintConstants.DATA_TYPE_JSON, false,
41 "Remote executed response data."
44 ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.DATA_TYPE_STRING, true,
45 "Remote execution status."
48 /** Operation definitions */
49 operation("ComponentRemoteScriptExecutor", "ComponentRemoteScriptExecutor Operation") {
52 ComponentRemoteScriptExecutor.INPUT_SELECTOR, BluePrintConstants.DATA_TYPE_JSON,
53 true, "Remote GRPC selector or DSL reference or GRPC Json config."
56 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME, BluePrintConstants.DATA_TYPE_STRING,
57 true, "Blueprint name."
60 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION, BluePrintConstants.DATA_TYPE_STRING,
61 true, "Blueprint version."
64 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION, BluePrintConstants.DATA_TYPE_STRING,
65 true, "Blueprint action name."
68 ComponentRemoteScriptExecutor.INPUT_TIMEOUT, BluePrintConstants.DATA_TYPE_INTEGER,
69 true, "Remote execution timeout in sec."
74 ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, BluePrintConstants.DATA_TYPE_JSON,
75 false, "Dynamic Json Content or DSL Json reference."
80 ComponentRemoteScriptExecutor.OUTPUT_STATUS, BluePrintConstants.DATA_TYPE_STRING,
81 true, "Status of the Component Execution ( success or failure )"
88 /** Component Builder */
89 fun BluePrintTypes.nodeTemplateComponentRemoteScriptExecutor(
92 block: ComponentRemoteScriptExecutorNodeTemplateBuilder.() -> Unit
95 return ComponentRemoteScriptExecutorNodeTemplateBuilder(id, description).apply(block).build()
98 class ComponentRemoteScriptExecutorNodeTemplateBuilder(id: String, description: String) :
99 AbstractNodeTemplateOperationImplBuilder<PropertiesAssignmentBuilder,
100 ComponentRemoteScriptExecutorNodeTemplateBuilder.InputsBuilder,
101 ComponentRemoteScriptExecutorNodeTemplateBuilder.OutputsBuilder>(
102 id, "component-remote-script-executor",
103 "ComponentRemoteScriptExecutor",
107 class InputsBuilder : PropertiesAssignmentBuilder() {
109 fun selector(selector: String) = selector(selector.asJsonPrimitive())
111 fun selector(selector: JsonNode) = property(ComponentRemoteScriptExecutor.INPUT_SELECTOR, selector)
113 fun blueprintName(blueprintName: String) = property(
114 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_NAME,
115 blueprintName.asJsonPrimitive()
118 fun blueprintVersion(blueprintVersion: String) = property(
119 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_VERSION,
120 blueprintVersion.asJsonPrimitive()
123 fun blueprintAction(blueprintAction: String) = property(
124 ComponentRemoteScriptExecutor.INPUT_BLUEPRINT_ACTION,
125 blueprintAction.asJsonPrimitive()
128 fun timeout(timeout: Int) = property(
129 ComponentRemoteScriptExecutor.INPUT_TIMEOUT,
130 timeout.asJsonPrimitive()
133 fun requestData(requestData: String) = requestData(requestData.asJsonType())
135 fun requestData(requestData: JsonNode) {
136 property(ComponentRemoteScriptExecutor.INPUT_REQUEST_DATA, requestData)
140 class OutputsBuilder : PropertiesAssignmentBuilder() {
142 fun status(status: String) = status(status.asJsonPrimitive())
144 fun status(status: JsonNode) {
145 property(ComponentRemoteScriptExecutor.OUTPUT_STATUS, status)