Renaming Files having BluePrint to have Blueprint
[ccsdk/cds.git] / components / model-catalog / blueprint-model / test-blueprint / capability_cli / Scripts / kotlin / cba / capability / cli / CapabilityCliDefinitions.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package cba.capability.cli
18
19 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTemplateComponentScriptExecutor
20 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeComponentScriptExecutor
21 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.relationshipTemplateSshClient
22 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.relationshipTypeConnectsToSshClient
23 import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
24 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
25 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.artifactTypeTemplateVelocity
26 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getAttribute
27 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getInput
28 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeTypeComponent
29 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
30 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
31 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBlueprintDefinitions
32
33 class CapabilityCliDefinitions : AbstractBlueprintDefinitions() {
34
35     override fun serviceTemplate(): ServiceTemplate {
36         return defaultServiceTemplate()
37     }
38 }
39
40 fun CapabilityCliDefinitions.defaultServiceTemplate() =
41     serviceTemplate(
42         name = "capability-cli",
43         version = "1.0.0",
44         author = "Brinda Santh Muthuramalingam",
45         tags = "brinda, tosca"
46     ) {
47         topologyTemplate {
48             workflow(id = "check", description = "CLI Check Workflow") {
49                 inputs {
50                     property(id = "hostname", type = "string", required = true, description = "")
51                     property(id = "username", type = "string", required = true, description = "")
52                     property(id = "password", type = "string", required = true, description = "")
53                     property(id = "data", type = "json", required = true, description = "")
54                 }
55                 outputs {
56                     property(id = "status", required = true, type = "string", description = "") {
57                         value("success")
58                     }
59                 }
60                 step(id = "check", target = "check", description = "Calling check script node")
61             }
62
63             /** Check component Node Template */
64             nodeTemplateComponentScriptExecutor(id = "check", description = "") {
65                 definedOperation(description = "") {
66                     inputs {
67                         type(BlueprintConstants.SCRIPT_KOTLIN)
68                         scriptClassReference(Check::class)
69                     }
70                     outputs {
71                         status(getAttribute("status"))
72                         responseData("""{ "data" : "Here I am "}""")
73                     }
74                 }
75                 artifact(
76                     id = "command-template",
77                     type = "artifact-template-velocity",
78                     file = "Templates/check-command-template.vtl"
79                 )
80             }
81
82             /** Connection Configuration through Relationship **/
83             relationshipTemplateSshClient("ssh-connection-config", "Device connection config") {
84                 basicAuth {
85                     host(getInput("hostname"))
86                     password(getInput("password"))
87                     username(getInput("username"))
88                 }
89             }
90         }
91
92         /** Artifact Types */
93         artifactTypeTemplateVelocity()
94         /** Node Types */
95         nodeTypeComponent()
96         nodeTypeComponentScriptExecutor()
97         /** Relationship Types */
98         relationshipTypeConnectsToSshClient()
99         relationshipTypeConnectsTo()
100     }