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.*
21 import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
24 fun blueprint(name: String, version: String, author: String, tags: String,
25 block: DSLBluePrintBuilder.() -> Unit): DSLBluePrint {
26 return DSLBluePrintBuilder(name, version, author, tags).apply(block).build()
30 fun serviceTemplate(name: String, version: String, author: String, tags: String,
31 block: ServiceTemplateBuilder.() -> Unit): ServiceTemplate {
32 return ServiceTemplateBuilder(name, version, author, tags).apply(block).build()
35 fun workflow(id: String, description: String, block: WorkflowBuilder.() -> Unit): Workflow {
36 return WorkflowBuilder(id, description).apply(block).build()
39 fun nodeTemplate(id: String, type: String, description: String,
40 block: NodeTemplateBuilder.() -> Unit): NodeTemplate {
41 return NodeTemplateBuilder(id, type, description).apply(block).build()
44 fun nodeType(id: String, version: String, derivedFrom: String, description: String,
45 block: NodeTypeBuilder.() -> Unit): NodeType {
46 return NodeTypeBuilder(id, version, derivedFrom, description).apply(block).build()
49 fun dataType(id: String, version: String, derivedFrom: String, description: String,
50 block: DataTypeBuilder.() -> Unit): DataType {
51 return DataTypeBuilder(id, version, derivedFrom, description).apply(block).build()
54 fun artifactType(id: String, version: String, derivedFrom: String, description: String,
55 block: ArtifactTypeBuilder.() -> Unit): ArtifactType {
56 return ArtifactTypeBuilder(id, version, derivedFrom, description).apply(block).build()
61 fun getInput(inputKey: String): JsonNode {
62 return """{"get_input": "$inputKey"}""".jsonAsJsonType()
65 fun getAttribute(attributeId: String): JsonNode {
66 return """{"get_attribute": ["SELF", "$attributeId"]}""".jsonAsJsonType()
69 fun getAttribute(attributeId: String, jsonPath: String): JsonNode {
70 return """{"get_attribute": ["SELF", "$attributeId", "$jsonPath"]}""".jsonAsJsonType()
73 fun getNodeTemplateAttribute(nodeTemplateId: String, attributeId: String): JsonNode {
74 return """{"get_attribute": ["$nodeTemplateId", "$attributeId"]}""".jsonAsJsonType()
77 fun getNodeTemplateAttribute(nodeTemplateId: String, attributeId: String, jsonPath: String): JsonNode {
78 return """{"get_attribute": ["$nodeTemplateId", "$attributeId", "$jsonPath]}""".jsonAsJsonType()
83 fun getProperty(propertyId: String): JsonNode {
84 return """{"get_property": ["SELF", "$propertyId"]}""".jsonAsJsonType()
87 fun getProperty(propertyId: String, jsonPath: String): JsonNode {
88 return """{"get_property": ["SELF", "$propertyId", "$jsonPath"]}""".jsonAsJsonType()
91 fun getNodeTemplateProperty(nodeTemplateName: String, propertyId: String): JsonNode {
92 return """{"get_property": ["$nodeTemplateName", "$propertyId"]}""".jsonAsJsonType()
95 fun getNodeTemplateProperty(nodeTemplateName: String, propertyId: String, jsonPath: String): JsonNode {
96 return """{"get_property": ["$nodeTemplateName", "$propertyId", "$jsonPath]}""".jsonAsJsonType()
101 fun getArtifact(artifactId: String): JsonNode {
102 return """{"get_artifact": ["SELF", "$artifactId"]}""".jsonAsJsonType()
105 fun getNodeTemplateArtifact(nodeTemplateName: String, artifactId: String): JsonNode {
106 return """{"get_artifact": ["$nodeTemplateName", "$artifactId"]}""".jsonAsJsonType()