2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2018-2019 IBM.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 @file:Suppress("unused")
19 package org.onap.ccsdk.cds.controllerblueprints.core.data
21 import com.fasterxml.jackson.annotation.JsonIgnore
22 import com.fasterxml.jackson.annotation.JsonProperty
23 import com.fasterxml.jackson.annotation.JsonPropertyOrder
24 import com.fasterxml.jackson.databind.JsonNode
25 import io.swagger.annotations.ApiModelProperty
26 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
27 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
32 * @author Brinda Santh
34 open class EntityType {
37 var id: String? = null
38 var description: String? = null
39 var version: String = "1.0.0"
40 var metadata: MutableMap<String, String>? = null
41 @get:JsonProperty("derived_from")
42 lateinit var derivedFrom: String
43 var attributes: MutableMap<String, AttributeDefinition>? = null
44 var properties: MutableMap<String, PropertyDefinition>? = null
48 5.3.2 tosca.datatypes.Credential
49 The Credential type is a complex TOSCA data Type used when describing
50 authorization credentials used to access network accessible resources.
55 var id: String? = null
56 var protocol: String? = null
57 @get:JsonProperty("token_type")
58 lateinit var tokenType: String
59 lateinit var token: String
60 var keys: MutableMap<String, String>? = null
61 lateinit var user: String
65 3.5.2 Constraint clause
66 A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities.
68 class ConstraintClause {
70 var equal: JsonNode? = null
71 @get:JsonProperty("greater_than")
72 var greaterThan: JsonNode? = null
73 @get:JsonProperty("greater_or_equal")
74 var greaterOrEqual: JsonNode? = null
75 @get:JsonProperty("less_than")
76 var lessThan: JsonNode? = null
77 @get:JsonProperty("less_or_equal")
78 var lessOrEqual: JsonNode? = null
79 @get:JsonProperty("in_range")
80 var inRange: MutableList<JsonNode>? = null
81 @get:JsonProperty("valid_values")
82 var validValues: MutableList<JsonNode>? = null
83 var length: JsonNode? = null
84 @get:JsonProperty("min_length")
85 var minLength: JsonNode? = null
86 @get:JsonProperty("max_length")
87 var maxLength: JsonNode? = null
88 var pattern: String? = null
89 var schema: String? = null
93 3.5.4 Node Filter definition
94 A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties.
97 class NodeFilterDefinition {
98 var properties: MutableMap<String, PropertyDefinition>? = null
99 var capabilities: MutableList<String>? = null
103 3.5.5 Repository definition
104 A repository definition defines a named external repository which contains deployment
105 and implementation artifacts that are referenced within the TOSCA Service Template.
107 class RepositoryDefinition {
110 var id: String? = null
111 var description: String? = null
112 lateinit var url: String
113 var credential: Credential? = null
117 3.5.6 Artifact definition
118 An artifact definition defines a named, typed file that can be associated with Node Type
119 or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.
121 class ArtifactDefinition {
124 var id: String? = null
125 lateinit var type: String
126 lateinit var file: String
127 var repository: String? = null
128 var description: String? = null
129 @get:JsonProperty("deploy_Path")
130 var deployPath: String? = null
131 var properties: MutableMap<String, JsonNode>? = null
135 3.5.7 Import definition
136 An import definition is used within a TOSCA Service Template to locate and uniquely name
137 another TOSCA Service Template file which has type and template definitions to be imported (included)
138 and referenced within another Service Template.
140 class ImportDefinition {
143 var id: String? = null
144 lateinit var file: String
145 var repository: String? = null
146 @get:JsonProperty("namespace_uri")
147 var namespaceUri: String? = null
148 @get:JsonProperty("namespace_prefix")
149 var namespacePrefix: String? = null
153 3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an
154 entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.).
155 Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are
156 instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates.
158 class PropertyDefinition {
161 var id: String? = null
162 var description: String? = null
163 var required: Boolean? = null
164 lateinit var type: String
165 @get:JsonProperty("default")
166 var defaultValue: JsonNode? = null
167 var status: String? = null
168 var constraints: MutableList<ConstraintClause>? = null
169 @get:JsonProperty("entry_schema")
170 var entrySchema: EntrySchema? = null
171 @get:JsonProperty("external-schema")
172 var externalSchema: String? = null
173 var metadata: MutableMap<String, String>? = null
174 // Mainly used in Workflow Outputs
175 @get:ApiModelProperty(notes = "Property Value, It may be Expression or Json type values")
176 var value: JsonNode? = null
180 3.5.10 Attribute definition
182 An attribute definition defines a named, typed value that can be associated with an entity defined in this
183 specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the
184 “actual state” of some property of a TOSCA entity after it has been deployed and instantiated
185 (as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function
186 from the instance model and used as values to other entities within TOSCA Service Templates.
189 class AttributeDefinition {
191 var id: String? = null
192 var description: String? = null
193 var required: Boolean? = null
194 lateinit var type: String
195 @JsonProperty("default")
196 var defaultValue: JsonNode? = null
197 var status: String? = null
198 var constraints: MutableList<ConstraintClause>? = null
199 @JsonProperty("entry_schema")
200 var entrySchema: EntrySchema? = null
201 // Mainly used in DSL definitions
202 @get:ApiModelProperty(notes = "Attribute Value, It may be Expression or Json type values")
203 var value: JsonNode? = null
207 3.5.13 Operation definition
208 An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).
210 class OperationDefinition {
213 var id: String? = null
214 var description: String? = null
215 var implementation: Implementation? = null
216 var inputs: MutableMap<String, PropertyDefinition>? = null
217 var outputs: MutableMap<String, PropertyDefinition>? = null
220 class Implementation {
221 var primary: String? = null
222 var dependencies: MutableList<String>? = null
223 @get:JsonProperty("operation_host")
224 var operationHost: String = BluePrintConstants.PROPERTY_SELF
225 // Timeout value in seconds
226 var timeout: Int = 180
227 var lock: LockAssignment? = null
230 class LockAssignment {
231 lateinit var key: JsonNode
232 var acquireTimeout: JsonNode = Integer(180).asJsonType()
236 3.5.14 Interface definition
237 An interface definition defines a named interface that can be associated with a Node or Relationship Type
239 class InterfaceDefinition {
242 var id: String? = null
243 var type: String? = null
244 var operations: MutableMap<String, OperationDefinition>? = null
245 var inputs: MutableMap<String, PropertyDefinition>? = null
249 3.5.15 Event Filter definition
250 An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities.
252 class EventFilterDefinition {
255 var id: String? = null
256 lateinit var node: String
257 var requirement: String? = null
258 var capability: String? = null
262 3.5.16 Trigger definition TODO
263 A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.
265 class TriggerDefinition {
268 var id: String? = null
269 var description: String? = null
270 @get:JsonProperty("event_type")
271 lateinit var eventType: String
272 @get:JsonProperty("target_filter")
273 var targetFilter: EventFilterDefinition? = null
274 var condition: ConditionClause? = null
275 var constraint: ConditionClause? = null
276 var method: String? = null
277 lateinit var action: String
281 3.5.17 Workflow activity definition
282 A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to:
283 · Delegate the workflow for a node expected to be provided by the orchestrator
284 · Set the state of a node
285 · Call an operation defined on a TOSCA interface of a node, relationship or group
286 · Inline another workflow defined in the topology (to allow reusability)
290 var delegate: String? = null
291 @get:JsonProperty("set_state")
292 var setState: String? = null
293 @get:JsonProperty("call_operation")
294 var callOperation: String? = null
295 var inlines: ArrayList<String>? = null
299 3.5.20 Workflow precondition definition
300 A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered.
302 class PreConditionDefinition {
305 var id: String? = null
306 lateinit var target: String
307 @get:JsonProperty("target_relationship")
308 lateinit var targetRelationship: String
309 lateinit var condition: ArrayList<ConditionClause>
313 3.5.21 Workflow step definition
314 A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow.
319 var id: String? = null
320 var description: String? = null
321 var target: String? = null
322 @JsonProperty("target_relationship")
323 var targetRelationship: String? = null
324 @JsonProperty("operation_host")
325 var operationHost: String? = null
326 var activities: ArrayList<Activity>? = null
327 @get:JsonProperty("on_success")
328 var onSuccess: ArrayList<String>? = null
329 @get:JsonProperty("on_failure")
330 var onFailure: ArrayList<String>? = null
334 3.6.2 Capability definition
335 A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes.
338 class CapabilityDefinition {
340 var id: String? = null
341 lateinit var type: String
342 var description: String? = null
343 var properties: MutableMap<String, PropertyDefinition>? = null
344 @get:JsonProperty("valid_source_types")
345 var validSourceTypes: MutableList<String>? = null
346 var occurrences: MutableList<Any>? = null
350 3.6.3 Requirement definition
351 The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity. The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly).
353 class RequirementDefinition {
356 var id: String? = null
357 var description: String? = null
358 var capability: String? = null
359 var node: String? = null
360 var relationship: String? = null
361 var occurrences: MutableList<Any>? = null
366 An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations.
368 class ArtifactType : EntityType() {
370 @get:JsonProperty("mime_type")
371 var mimeType: String? = null
372 @get:JsonProperty("file_ext")
373 var fileExt: MutableList<String>? = null
378 A Data Type definition defines the schema for new named datatypes in TOSCA.
381 class DataType : EntityType() {
382 var constraints: MutableList<ConstraintClause>? = null
387 A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a Node Type defines the structure of observable properties via a Properties Definition, the Requirements and Capabilities of the node as well as its supported interfaces.
391 class NodeType : EntityType() {
392 var capabilities: MutableMap<String, CapabilityDefinition>? = null
393 var requirements: MutableMap<String, RequirementDefinition>? = null
394 var interfaces: MutableMap<String, InterfaceDefinition>? = null
395 var artifacts: MutableMap<String, ArtifactDefinition>? = null
399 3.6.8 Requirement Type
400 A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose.
401 The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types
402 from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types
403 along with a named Feature notation.
406 class RequirementType : EntityType() {
407 var requirements: MutableMap<String, RequirementDefinition>? = null
408 var capabilities: MutableMap<String, CapabilityDefinition>? = null
409 var interfaces: MutableMap<String, InterfaceDefinition>? = null
410 var artifacts: MutableMap<String, ArtifactDefinition>? = null
414 3.6.10 Relationship Type
415 A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.
418 class RelationshipType : EntityType() {
419 var interfaces: MutableMap<String, InterfaceDefinition>? = null
420 @get:JsonProperty("valid_target_types")
421 var validTargetTypes: MutableList<String>? = null
426 A Group Type defines logical grouping types for nodes, typically for different management purposes.
427 Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology
428 of an application, yet can have capabilities and the ability to attach policies and interfaces
429 that can be applied (depending on the group type) to its member nodes.
432 class GroupType : EntityType() {
433 var members: MutableList<String>? = null
434 var requirements: ArrayList<RequirementDefinition>? = null
435 var capabilities: MutableMap<String, CapabilityDefinition>? = null
436 var interfaces: MutableMap<String, InterfaceDefinition>? = null
441 A Policy Type defines a type of requirement that affects or governs an application or service’s
442 topology at some stage of its lifecycle, but is not explicitly part of the topology itself
443 (i.e., it does not prevent the application or service from being deployed or run if it did not exist).
445 class PolicyType : EntityType() {
447 lateinit var targets: MutableList<String>
451 3.7.1 Capability assignment
452 A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition.
454 class CapabilityAssignment {
457 var id: String? = null
458 var attributes: MutableMap<String, JsonNode>? = null
459 var properties: MutableMap<String, JsonNode>? = null
463 3.7.4 Relationship Template
464 A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations.
466 class GroupDefinition {
469 var id: String? = null
470 lateinit var type: String
471 var description: String? = null
472 var metadata: MutableMap<String, String>? = null
473 var properties: MutableMap<String, JsonNode>? = null
474 var members = ArrayList<String>()
475 var interfaces: MutableMap<String, InterfaceDefinition>? = null
479 3.7.6 Policy definition
480 A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.).
482 class PolicyDefinition {
485 var id: String? = null
486 lateinit var type: String
487 var description: String? = null
488 var metadata: MutableMap<String, String>? = null
489 var properties: MutableMap<String, JsonNode>? = null
490 var targets: MutableList<String>? = null
494 3.8 Topology Template definition
495 This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively. Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates.
497 class TopologyTemplate {
500 var id: String? = null
501 var description: String? = null
502 var inputs: MutableMap<String, PropertyDefinition>? = null
503 @get:JsonProperty("node_templates")
504 var nodeTemplates: MutableMap<String, NodeTemplate>? = null
505 @get:JsonProperty("relationship_templates")
506 var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
507 var policies: MutableMap<String, PolicyDefinition>? = null
508 var outputs: MutableMap<String, PropertyDefinition>? = null
509 @get:JsonProperty("substitution_mappings")
510 var substitutionMappings: Any? = null
511 var workflows: MutableMap<String, Workflow>? = null
514 class SubstitutionMapping {
515 @get:JsonProperty("node_type")
516 lateinit var nodeType: String
517 lateinit var capabilities: ArrayList<String>
518 lateinit var requirements: ArrayList<String>
522 lateinit var type: String
523 var constraints: MutableList<ConstraintClause>? = null
526 class InterfaceAssignment {
528 var id: String? = null
529 var operations: MutableMap<String, OperationAssignment>? = null
530 var inputs: MutableMap<String, JsonNode>? = null
535 A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations.
538 open class NodeTemplate {
540 var id: String? = null
541 var description: String? = null
542 lateinit var type: String
543 var metadata: MutableMap<String, String>? = null
544 var directives: MutableList<String>? = null
545 // @get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
546 var properties: MutableMap<String, JsonNode>? = null
547 var attributes: MutableMap<String, JsonNode>? = null
548 var capabilities: MutableMap<String, CapabilityAssignment>? = null
549 var requirements: MutableMap<String, RequirementAssignment>? = null
550 var interfaces: MutableMap<String, InterfaceAssignment>? = null
551 var artifacts: MutableMap<String, ArtifactDefinition>? = null
552 @get:JsonProperty("node_filter")
553 var nodeFilter: NodeFilterDefinition? = null
554 var copy: String? = null
557 class OperationAssignment {
559 var id: String? = null
560 var description: String? = null
561 var implementation: Implementation? = null
562 var inputs: MutableMap<String, JsonNode>? = null
563 var outputs: MutableMap<String, JsonNode>? = null
567 3.7.4 Relationship Template
568 A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations.
571 class RelationshipTemplate {
573 var id: String? = null
574 lateinit var type: String
575 var description: String? = null
576 var metadata: MutableMap<String, String>? = null
577 var properties: MutableMap<String, JsonNode>? = null
578 var attributes: MutableMap<String, JsonNode>? = null
579 var interfaces: MutableMap<String, InterfaceDefinition>? = null
580 var copy: String? = null
584 3.7.2 Requirement assignment
585 A Requirement assignment allows template authors to provide either concrete names of TOSCA templates or provide abstract selection criteria for providers to use to find matching TOSCA templates that are used to fulfill a named requirement’s declared TOSCA Node Type.
588 class RequirementAssignment {
590 var id: String? = null
591 var capability: String? = null
592 var node: String? = null
593 // Relationship Type or Relationship Template
594 var relationship: String? = null
599 var id: String? = null
600 var description: String? = null
601 var steps: MutableMap<String, Step>? = null
602 var preconditions: ArrayList<PreConditionDefinition>? = null
603 var inputs: MutableMap<String, PropertyDefinition>? = null
604 var outputs: MutableMap<String, PropertyDefinition>? = null
607 class ConditionClause {
608 var and: ArrayList<MutableMap<String, Any>>? = null
609 var or: ArrayList<MutableMap<String, Any>>? = null
610 @get:JsonProperty("assert")
611 var assertConditions: ArrayList<MutableMap<String, Any>>? = null
615 3.9 Service Template definition
616 A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.
620 value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
623 class ServiceTemplate : Cloneable {
626 var id: String? = null
627 @get:JsonProperty("tosca_definitions_version")
628 var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0"
629 var metadata: MutableMap<String, String>? = null
630 var description: String? = null
631 @get:JsonProperty("dsl_definitions")
632 var dslDefinitions: MutableMap<String, JsonNode>? = null
633 var repositories: MutableMap<String, RepositoryDefinition>? = null
634 var imports: MutableList<ImportDefinition>? = null
635 @get:JsonProperty("artifact_types")
636 var artifactTypes: MutableMap<String, ArtifactType>? = null
637 @get:JsonProperty("data_types")
638 var dataTypes: MutableMap<String, DataType>? = null
639 @get:JsonProperty("relationship_types")
640 var relationshipTypes: MutableMap<String, RelationshipType>? = null
641 @get:JsonProperty("node_types")
642 var nodeTypes: MutableMap<String, NodeType>? = null
643 @get:JsonProperty("policy_types")
644 var policyTypes: MutableMap<String, PolicyType>? = null
645 @get:JsonProperty("topology_template")
646 var topologyTemplate: TopologyTemplate? = null
648 public override fun clone(): ServiceTemplate {
649 return super.clone() as ServiceTemplate
653 class ToscaMetaData {
654 lateinit var toscaMetaFileVersion: String
655 lateinit var csarVersion: String
656 lateinit var createdBy: String
657 lateinit var entityDefinitions: String
658 lateinit var templateName: String
659 lateinit var templateVersion: String
660 lateinit var templateTags: String
661 var templateType: String = BluePrintConstants.BLUEPRINT_TYPE_DEFAULT