2 * Copyright © 2019 IBM.
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.functions.resource.resolution
19 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
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.data.NodeType
24 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeType
26 fun BluePrintTypes.nodeTypeSourceInput(): NodeType {
27 return nodeType(id = "source-input", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
28 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
29 description = "This is Input Resource Source Node Type") {}
32 fun BluePrintTypes.nodeTypeSourceDefault(): NodeType {
33 return nodeType(id = "source-default", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
34 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
35 description = "This is Default Resource Source Node Type") {}
38 fun BluePrintTypes.nodeTypeSourceDb(): NodeType {
39 return nodeType(id = "source-db", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
40 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
41 description = "This is Database Resource Source Node Type") {
42 property("type", BluePrintConstants.DATA_TYPE_STRING,
44 defaultValue("SQL".asJsonPrimitive())
46 validValues(arrayListOf("SQL".asJsonPrimitive(), "PLSQL".asJsonPrimitive()))
49 property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
51 property("query", BluePrintConstants.DATA_TYPE_STRING,
53 property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
55 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
57 property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
59 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
61 property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
62 true, "Resource Resolution dependency dictionary names.") {
63 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
68 fun BluePrintTypes.nodeTypeSourceRest(): NodeType {
69 return nodeType(id = "source-rest", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
70 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
71 description = "This is Rest Resource Source Node Type") {
72 property("type", BluePrintConstants.DATA_TYPE_STRING,
74 defaultValue("JSON".asJsonPrimitive())
76 validValues(arrayListOf("JSON".asJsonPrimitive(), "XML".asJsonPrimitive()))
79 property("verb", BluePrintConstants.DATA_TYPE_STRING,
81 defaultValue("GET".asJsonPrimitive())
83 validValues(arrayListOf("GET".asJsonPrimitive(), "POST".asJsonPrimitive(),
84 "DELETE".asJsonPrimitive(), "PUT".asJsonPrimitive()))
87 property("payload", BluePrintConstants.DATA_TYPE_STRING,
89 defaultValue("".asJsonPrimitive())
91 property("endpoint-selector", BluePrintConstants.DATA_TYPE_STRING,
93 property("url-path", BluePrintConstants.DATA_TYPE_STRING,
95 property("path", BluePrintConstants.DATA_TYPE_STRING,
97 property("expression-type", BluePrintConstants.DATA_TYPE_STRING,
99 defaultValue("JSON_PATH".asJsonPrimitive())
101 validValues(arrayListOf("JSON_PATH".asJsonPrimitive(), "JSON_POINTER".asJsonPrimitive()))
104 property("input-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
106 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
108 property("output-key-mapping", BluePrintConstants.DATA_TYPE_MAP,
110 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
112 property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
113 true, "Resource Resolution dependency dictionary names.") {
114 entrySchema(BluePrintConstants.DATA_TYPE_STRING)
119 fun BluePrintTypes.nodeTypeSourceCapability(): NodeType {
120 return nodeType(id = "source-capability", version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
121 derivedFrom = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
122 description = "This is Component Resource Source Node Type") {
123 property(ComponentScriptExecutor.INPUT_SCRIPT_TYPE, BluePrintConstants.DATA_TYPE_STRING,
124 true, "Request Id, Unique Id for the request.") {
125 defaultValue(BluePrintConstants.SCRIPT_KOTLIN)
127 validValues(arrayListOf(BluePrintConstants.SCRIPT_KOTLIN.asJsonPrimitive(),
128 BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive(),
129 BluePrintConstants.SCRIPT_JYTHON.asJsonPrimitive()))
132 property(ComponentScriptExecutor.INPUT_SCRIPT_CLASS_REFERENCE, BluePrintConstants.DATA_TYPE_STRING,
133 true, "Kotlin Script class name or jython script name.")
134 property(ComponentScriptExecutor.INPUT_DYNAMIC_PROPERTIES, BluePrintConstants.DATA_TYPE_JSON,
135 false, "Dynamic Json Content or DSL Json reference.")
136 property("key-dependencies", BluePrintConstants.DATA_TYPE_LIST,
137 true, "Resource Resolution dependency dictionary names.") {
138 entrySchema(BluePrintConstants.DATA_TYPE_STRING)