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
31 * @author Brinda Santh
33 open class EntityType {
36 var id: String? = null
37 var description: String? = null
38 var version: String = "1.0.0"
39 var metadata: MutableMap<String, String>? = null
40 @get:JsonProperty("derived_from")
41 lateinit var derivedFrom: String
42 var attributes: MutableMap<String, AttributeDefinition>? = null
43 var properties: MutableMap<String, PropertyDefinition>? = null
47 5.3.2 tosca.datatypes.Credential
48 The Credential type is a complex TOSCA data Type used when describing
49 authorization credentials used to access network accessible resources.
54 var id: String? = null
55 var protocol: String? = null
56 @get:JsonProperty("token_type")
57 lateinit var tokenType: String
58 lateinit var token: String
59 var keys: MutableMap<String, String>? = null
60 lateinit var user: String
64 3.5.2 Constraint clause
65 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.
67 class ConstraintClause {
69 var equal: JsonNode? = null
70 @get:JsonProperty("greater_than")
71 var greaterThan: JsonNode? = null
72 @get:JsonProperty("greater_or_equal")
73 var greaterOrEqual: JsonNode? = null
74 @get:JsonProperty("less_than")
75 var lessThan: JsonNode? = null
76 @get:JsonProperty("less_or_equal")
77 var lessOrEqual: JsonNode? = null
78 @get:JsonProperty("in_range")
79 var inRange: MutableList<JsonNode>? = null
80 @get:JsonProperty("valid_values")
81 var validValues: MutableList<JsonNode>? = null
82 var length: JsonNode? = null
83 @get:JsonProperty("min_length")
84 var minLength: JsonNode? = null
85 @get:JsonProperty("max_length")
86 var maxLength: JsonNode? = null
87 var pattern: String? = null
88 var schema: String? = null
92 3.5.4 Node Filter definition
93 A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties.
96 class NodeFilterDefinition {
97 var properties: MutableMap<String, PropertyDefinition>? = null
98 var capabilities: MutableList<String>? = null
102 3.5.5 Repository definition
103 A repository definition defines a named external repository which contains deployment
104 and implementation artifacts that are referenced within the TOSCA Service Template.
106 class RepositoryDefinition {
109 var id: String? = null
110 var description: String? = null
111 lateinit var url: String
112 var credential: Credential? = null
116 3.5.6 Artifact definition
117 An artifact definition defines a named, typed file that can be associated with Node Type
118 or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.
120 class ArtifactDefinition {
123 var id: String? = null
124 lateinit var type: String
125 lateinit var file: String
126 var repository: String? = null
127 var description: String? = null
128 @get:JsonProperty("deploy_Path")
129 var deployPath: String? = null
130 var properties: MutableMap<String, JsonNode>? = null
134 3.5.7 Import definition
135 An import definition is used within a TOSCA Service Template to locate and uniquely name
136 another TOSCA Service Template file which has type and template definitions to be imported (included)
137 and referenced within another Service Template.
139 class ImportDefinition {
142 var id: String? = null
143 lateinit var file: String
144 var repository: String? = null
145 @get:JsonProperty("namespace_uri")
146 var namespaceUri: String? = null
147 @get:JsonProperty("namespace_prefix")
148 var namespacePrefix: String? = null
152 3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an
153 entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.).
154 Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are
155 instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates.
157 class PropertyDefinition {
160 var id: String? = null
161 var description: String? = null
162 var required: Boolean? = null
163 lateinit var type: String
164 @get:JsonProperty("default")
165 var defaultValue: JsonNode? = null
166 var status: String? = null
167 var constraints: MutableList<ConstraintClause>? = null
168 @get:JsonProperty("entry_schema")
169 var entrySchema: EntrySchema? = null
170 @get:JsonProperty("external-schema")
171 var externalSchema: String? = null
172 var metadata: MutableMap<String, String>? = null
173 // Mainly used in Workflow Outputs
174 @get:ApiModelProperty(notes = "Property Value, It may be Expression or Json type values")
175 var value: JsonNode? = null
179 3.5.10 Attribute definition
181 An attribute definition defines a named, typed value that can be associated with an entity defined in this
182 specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the
183 “actual state” of some property of a TOSCA entity after it has been deployed and instantiated
184 (as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function
185 from the instance model and used as values to other entities within TOSCA Service Templates.
188 class AttributeDefinition {
190 var id: String? = null
191 var description: String? = null
192 var required: Boolean? = null
193 lateinit var type: String
194 @JsonProperty("default")
195 var defaultValue: JsonNode? = null
196 var status: String? = null
197 var constraints: MutableList<ConstraintClause>? = null
198 @JsonProperty("entry_schema")
199 var entrySchema: EntrySchema? = null
200 // Mainly used in DSL definitions
201 @get:ApiModelProperty(notes = "Attribute Value, It may be Expression or Json type values")
202 var value: JsonNode? = null
206 3.5.13 Operation definition
207 An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).
209 class OperationDefinition {
212 var id: String? = null
213 var description: String? = null
214 var implementation: Implementation? = null
215 var inputs: MutableMap<String, PropertyDefinition>? = null
216 var outputs: MutableMap<String, PropertyDefinition>? = null
219 class Implementation {
220 var primary: String? = null
221 var dependencies: MutableList<String>? = null
222 @get:JsonProperty("operation_host")
223 var operationHost: String = BluePrintConstants.PROPERTY_SELF
224 // Timeout value in seconds
225 var timeout: Int = 180
229 3.5.14 Interface definition
230 An interface definition defines a named interface that can be associated with a Node or Relationship Type
232 class InterfaceDefinition {
235 var id: String? = null
236 var type: String? = null
237 var operations: MutableMap<String, OperationDefinition>? = null
238 var inputs: MutableMap<String, PropertyDefinition>? = null
242 3.5.15 Event Filter definition
243 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.
245 class EventFilterDefinition {
248 var id: String? = null
249 lateinit var node: String
250 var requirement: String? = null
251 var capability: String? = null
255 3.5.16 Trigger definition TODO
256 A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.
258 class TriggerDefinition {
261 var id: String? = null
262 var description: String? = null
263 @get:JsonProperty("event_type")
264 lateinit var eventType: String
265 @get:JsonProperty("target_filter")
266 var targetFilter: EventFilterDefinition? = null
267 var condition: ConditionClause? = null
268 var constraint: ConditionClause? = null
269 var method: String? = null
270 lateinit var action: String
274 3.5.17 Workflow activity definition
275 A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to:
276 · Delegate the workflow for a node expected to be provided by the orchestrator
277 · Set the state of a node
278 · Call an operation defined on a TOSCA interface of a node, relationship or group
279 · Inline another workflow defined in the topology (to allow reusability)
283 var delegate: String? = null
284 @get:JsonProperty("set_state")
285 var setState: String? = null
286 @get:JsonProperty("call_operation")
287 var callOperation: String? = null
288 var inlines: ArrayList<String>? = null
292 3.5.20 Workflow precondition definition
293 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.
295 class PreConditionDefinition {
298 var id: String? = null
299 lateinit var target: String
300 @get:JsonProperty("target_relationship")
301 lateinit var targetRelationship: String
302 lateinit var condition: ArrayList<ConditionClause>
306 3.5.21 Workflow step definition
307 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.
312 var id: String? = null
313 var description: String? = null
314 var target: String? = null
315 @JsonProperty("target_relationship")
316 var targetRelationship: String? = null
317 @JsonProperty("operation_host")
318 var operationHost: String? = null
319 var activities: ArrayList<Activity>? = null
320 @get:JsonProperty("on_success")
321 var onSuccess: ArrayList<String>? = null
322 @get:JsonProperty("on_failure")
323 var onFailure: ArrayList<String>? = null
327 3.6.2 Capability definition
328 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.
331 class CapabilityDefinition {
333 var id: String? = null
334 lateinit var type: String
335 var description: String? = null
336 var properties: MutableMap<String, PropertyDefinition>? = null
337 @get:JsonProperty("valid_source_types")
338 var validSourceTypes: MutableList<String>? = null
339 var occurrences: MutableList<Any>? = null
343 3.6.3 Requirement definition
344 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).
346 class RequirementDefinition {
349 var id: String? = null
350 var description: String? = null
351 var capability: String? = null
352 var node: String? = null
353 var relationship: String? = null
354 var occurrences: MutableList<Any>? = null
359 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.
361 class ArtifactType : EntityType() {
363 @get:JsonProperty("mime_type")
364 var mimeType: String? = null
365 @get:JsonProperty("file_ext")
366 var fileExt: MutableList<String>? = null
371 A Data Type definition defines the schema for new named datatypes in TOSCA.
374 class DataType : EntityType() {
375 var constraints: MutableList<ConstraintClause>? = null
380 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.
384 class NodeType : EntityType() {
385 var capabilities: MutableMap<String, CapabilityDefinition>? = null
386 var requirements: MutableMap<String, RequirementDefinition>? = null
387 var interfaces: MutableMap<String, InterfaceDefinition>? = null
388 var artifacts: MutableMap<String, ArtifactDefinition>? = null
392 3.6.8 Requirement Type
393 A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose.
394 The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types
395 from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types
396 along with a named Feature notation.
399 class RequirementType : EntityType() {
400 var requirements: MutableMap<String, RequirementDefinition>? = null
401 var capabilities: MutableMap<String, CapabilityDefinition>? = null
402 var interfaces: MutableMap<String, InterfaceDefinition>? = null
403 var artifacts: MutableMap<String, ArtifactDefinition>? = null
407 3.6.10 Relationship Type
408 A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.
411 class RelationshipType : EntityType() {
412 var interfaces: MutableMap<String, InterfaceDefinition>? = null
413 @get:JsonProperty("valid_target_types")
414 var validTargetTypes: MutableList<String>? = null
419 A Group Type defines logical grouping types for nodes, typically for different management purposes.
420 Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology
421 of an application, yet can have capabilities and the ability to attach policies and interfaces
422 that can be applied (depending on the group type) to its member nodes.
425 class GroupType : EntityType() {
426 var members: MutableList<String>? = null
427 var requirements: ArrayList<RequirementDefinition>? = null
428 var capabilities: MutableMap<String, CapabilityDefinition>? = null
429 var interfaces: MutableMap<String, InterfaceDefinition>? = null
434 A Policy Type defines a type of requirement that affects or governs an application or service’s
435 topology at some stage of its lifecycle, but is not explicitly part of the topology itself
436 (i.e., it does not prevent the application or service from being deployed or run if it did not exist).
438 class PolicyType : EntityType() {
440 lateinit var targets: MutableList<String>
444 3.7.1 Capability assignment
445 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.
447 class CapabilityAssignment {
450 var id: String? = null
451 var attributes: MutableMap<String, JsonNode>? = null
452 var properties: MutableMap<String, JsonNode>? = null
456 3.7.4 Relationship Template
457 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.
459 class GroupDefinition {
462 var id: String? = null
463 lateinit var type: String
464 var description: String? = null
465 var metadata: MutableMap<String, String>? = null
466 var properties: MutableMap<String, JsonNode>? = null
467 var members = ArrayList<String>()
468 var interfaces: MutableMap<String, InterfaceDefinition>? = null
472 3.7.6 Policy definition
473 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.).
475 class PolicyDefinition {
478 var id: String? = null
479 lateinit var type: String
480 var description: String? = null
481 var metadata: MutableMap<String, String>? = null
482 var properties: MutableMap<String, JsonNode>? = null
483 var targets: MutableList<String>? = null
487 3.8 Topology Template definition
488 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.
490 class TopologyTemplate {
493 var id: String? = null
494 var description: String? = null
495 var inputs: MutableMap<String, PropertyDefinition>? = null
496 @get:JsonProperty("node_templates")
497 var nodeTemplates: MutableMap<String, NodeTemplate>? = null
498 @get:JsonProperty("relationship_templates")
499 var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
500 var policies: MutableMap<String, PolicyDefinition>? = null
501 var outputs: MutableMap<String, PropertyDefinition>? = null
502 @get:JsonProperty("substitution_mappings")
503 var substitutionMappings: Any? = null
504 var workflows: MutableMap<String, Workflow>? = null
507 class SubstitutionMapping {
508 @get:JsonProperty("node_type")
509 lateinit var nodeType: String
510 lateinit var capabilities: ArrayList<String>
511 lateinit var requirements: ArrayList<String>
515 lateinit var type: String
516 var constraints: MutableList<ConstraintClause>? = null
519 class InterfaceAssignment {
521 var id: String? = null
522 var operations: MutableMap<String, OperationAssignment>? = null
523 var inputs: MutableMap<String, JsonNode>? = null
528 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.
531 open class NodeTemplate {
533 var id: String? = null
534 var description: String? = null
535 lateinit var type: String
536 var metadata: MutableMap<String, String>? = null
537 var directives: MutableList<String>? = null
538 // @get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
539 var properties: MutableMap<String, JsonNode>? = null
540 var attributes: MutableMap<String, JsonNode>? = null
541 var capabilities: MutableMap<String, CapabilityAssignment>? = null
542 var requirements: MutableMap<String, RequirementAssignment>? = null
543 var interfaces: MutableMap<String, InterfaceAssignment>? = null
544 var artifacts: MutableMap<String, ArtifactDefinition>? = null
545 @get:JsonProperty("node_filter")
546 var nodeFilter: NodeFilterDefinition? = null
547 var copy: String? = null
550 class OperationAssignment {
552 var id: String? = null
553 var description: String? = null
554 var implementation: Implementation? = null
555 var inputs: MutableMap<String, JsonNode>? = null
556 var outputs: MutableMap<String, JsonNode>? = null
560 3.7.4 Relationship Template
561 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.
564 class RelationshipTemplate {
565 var type: String? = null
566 var description: String? = null
567 var metadata: MutableMap<String, String>? = null
568 var properties: MutableMap<String, PropertyDefinition>? = null
569 var attributes: MutableMap<String, JsonNode>? = null
570 var interfaces: MutableMap<String, InterfaceDefinition>? = null
571 var copy: String? = null
575 3.7.2 Requirement assignment
576 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.
579 class RequirementAssignment {
581 var id: String? = null
582 var capability: String? = null
583 var node: String? = null
584 // Relationship Type or Relationship Template
585 var relationship: String? = null
590 var id: String? = null
591 var description: String? = null
592 var steps: MutableMap<String, Step>? = null
593 var preconditions: ArrayList<PreConditionDefinition>? = null
594 var inputs: MutableMap<String, PropertyDefinition>? = null
595 var outputs: MutableMap<String, PropertyDefinition>? = null
598 class ConditionClause {
599 var and: ArrayList<MutableMap<String, Any>>? = null
600 var or: ArrayList<MutableMap<String, Any>>? = null
601 @get:JsonProperty("assert")
602 var assertConditions: ArrayList<MutableMap<String, Any>>? = null
606 3.9 Service Template definition
607 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.
611 value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
614 class ServiceTemplate : Cloneable {
617 var id: String? = null
618 @get:JsonProperty("tosca_definitions_version")
619 var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0"
620 var metadata: MutableMap<String, String>? = null
621 var description: String? = null
622 @get:JsonProperty("dsl_definitions")
623 var dslDefinitions: MutableMap<String, JsonNode>? = null
624 var repositories: MutableMap<String, RepositoryDefinition>? = null
625 var imports: MutableList<ImportDefinition>? = null
626 @get:JsonProperty("artifact_types")
627 var artifactTypes: MutableMap<String, ArtifactType>? = null
628 @get:JsonProperty("data_types")
629 var dataTypes: MutableMap<String, DataType>? = null
630 @get:JsonProperty("relationship_types")
631 var relationshipTypes: MutableMap<String, RelationshipType>? = null
632 @get:JsonProperty("node_types")
633 var nodeTypes: MutableMap<String, NodeType>? = null
634 @get:JsonProperty("policy_types")
635 var policyTypes: MutableMap<String, PolicyType>? = null
636 @get:JsonProperty("topology_template")
637 var topologyTemplate: TopologyTemplate? = null
639 public override fun clone(): ServiceTemplate {
640 return super.clone() as ServiceTemplate
644 class ToscaMetaData {
645 lateinit var toscaMetaFileVersion: String
646 lateinit var csarVersion: String
647 lateinit var createdBy: String
648 lateinit var entityDefinitions: String
649 var templateName: String? = null
650 var templateVersion: String? = null
651 var templateTags: String? = null