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.controllerblueprints.core.dsl
19 import com.fasterxml.jackson.databind.JsonNode
20 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
21 import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
23 fun serviceTemplate(name: String, version: String, author: String, tags: String,
24 block: ServiceTemplateBuilder.() -> Unit): ServiceTemplate {
25 return ServiceTemplateBuilder(name, version, author, tags).apply(block).build()
30 fun getInput(inputKey: String): JsonNode {
31 return """{"get_input": "$inputKey"}""".jsonAsJsonType()
34 fun getAttribute(attributeName: String): JsonNode {
35 return """{"get_attribute": ["SELF", "$attributeName"]}""".jsonAsJsonType()
38 fun getAttribute(attributeName: String, jsonPath: String): JsonNode {
39 return """{"get_attribute": ["SELF", "$attributeName", "$jsonPath"]}""".jsonAsJsonType()
42 fun getNodeTemplateAttribute(nodeTemplateName: String, attributeName: String): JsonNode {
43 return """{"get_attribute": ["$nodeTemplateName", "$attributeName"]}""".jsonAsJsonType()
46 fun getNodeTemplateAttribute(nodeTemplateName: String, attributeName: String, jsonPath: String): JsonNode {
47 return """{"get_attribute": ["$nodeTemplateName", "$attributeName", "$jsonPath]}""".jsonAsJsonType()
52 fun getProperty(propertyName: String): JsonNode {
53 return """{"get_property": ["SELF", "$propertyName"]}""".jsonAsJsonType()
56 fun getProperty(propertyName: String, jsonPath: String): JsonNode {
57 return """{"get_property": ["SELF", "$propertyName", "$jsonPath"]}""".jsonAsJsonType()
60 fun getNodeTemplateProperty(nodeTemplateName: String, propertyName: String): JsonNode {
61 return """{"get_property": ["$nodeTemplateName", "$propertyName"]}""".jsonAsJsonType()
64 fun getNodeTemplateProperty(nodeTemplateName: String, propertyName: String, jsonPath: String): JsonNode {
65 return """{"get_property": ["$nodeTemplateName", "$propertyName", "$jsonPath]}""".jsonAsJsonType()
70 fun getArtifact(artifactName: String): JsonNode {
71 return """{"get_artifact": ["SELF", "$artifactName"]}""".jsonAsJsonType()
74 fun getNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): JsonNode {
75 return """{"get_artifact": ["$nodeTemplateName", "$artifactName"]}""".jsonAsJsonType()