2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2018 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.apps.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
30 * @author Brinda Santh
32 open class EntityType {
34 var id: String? = null
35 var description: String? = null
36 var version: String = "1.0.0"
37 var metadata: MutableMap<String, String>? = null
38 @get:JsonProperty("derived_from")
39 lateinit var derivedFrom: String
40 var attributes: MutableMap<String, AttributeDefinition>? = null
41 var properties: MutableMap<String, PropertyDefinition>? = null
45 5.3.2 tosca.datatypes.Credential
46 The Credential type is a complex TOSCA data Type used when describing
47 authorization credentials used to access network accessible resources.
51 var id: String? = null
52 var protocol: String? = null
53 @get:JsonProperty("token_type")
54 lateinit var tokenType: String
55 lateinit var token: String
56 var keys: MutableMap<String, String>? = null
57 lateinit var user: String
61 3.5.2 Constraint clause
62 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.
64 class ConstraintClause {
65 @get:JsonProperty("equal")
66 var equal: JsonNode? = null
67 @get:JsonProperty("greater_than")
68 var greaterThan: Any? = null
69 @get:JsonProperty("greater_or_equal")
70 var greaterOrEqual: Any? = null
71 @get:JsonProperty("less_than")
72 var lessThan: Any? = null
73 @get:JsonProperty("less_or_equal")
74 var lessOrEqual: Any? = null
75 @get:JsonProperty("in_range")
76 var inRange: Any? = null
77 @get:JsonProperty("valid_values")
78 var validValues: MutableList<JsonNode>? = null
79 @get:JsonProperty("length")
80 var length: Any? = null
81 @get:JsonProperty("min_length")
82 var minLength: Any? = null
83 @get:JsonProperty("max_length")
84 var maxLength: Any? = null
85 var pattern: String? = null
86 var schema: String? = null
90 3.5.4 Node Filter definition
91 A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties.
94 class NodeFilterDefinition {
95 var properties: MutableMap<String, PropertyDefinition>? = null
96 var capabilities: MutableList<String>? = null
100 3.5.5 Repository definition
101 A repository definition defines a named external repository which contains deployment
102 and implementation artifacts that are referenced within the TOSCA Service Template.
104 class RepositoryDefinition {
106 var id: String? = null
107 var description: String? = null
108 lateinit var url: String
109 var credential: Credential? = null
114 3.5.6 Artifact definition
115 An artifact definition defines a named, typed file that can be associated with Node Type
116 or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.
118 class ArtifactDefinition {
120 var id: String? = null
121 var type: String? = null
122 var file: String? = null
123 var repository: String? = null
124 var description: String? = null
125 @get:JsonProperty("deploy_Path")
126 var deployPath: String? = null
127 var properties: MutableMap<String, JsonNode>? = null
128 var content: String? = null
129 @Deprecated("Mapping content is define by the Type")
130 var mappingContent: String? = 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 {
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 {
159 var id: String? = null
160 var description: String? = null
161 var required: Boolean? = null
162 lateinit var type: String
163 @get:JsonProperty("default")
164 var defaultValue: JsonNode? = null
165 var status: String? = null
166 var constraints: MutableList<ConstraintClause>? = null
167 @get:JsonProperty("entry_schema")
168 var entrySchema: EntrySchema? = null
169 @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values")
170 var value: JsonNode? = null
175 3.5.10 Attribute definition
177 An attribute definition defines a named, typed value that can be associated with an entity defined in this
178 specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the
179 “actual state” of some property of a TOSCA entity after it has been deployed and instantiated
180 (as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function
181 from the instance model and used as values to other entities within TOSCA Service Templates.
184 class AttributeDefinition {
186 var id: String? = null
187 var description: String? = null
188 var required: Boolean? = null
189 lateinit var type: String
190 @JsonProperty("default")
191 var defaultValue: JsonNode? = null
192 var status: String? = null
193 var constraints: MutableList<ConstraintClause>? = null
194 @JsonProperty("entry_schema")
195 var entrySchema: EntrySchema? = null
199 3.5.13 Operation definition
200 An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).
202 class OperationDefinition {
204 var id: String? = null
205 var description: String? = null
206 var implementation: Implementation? = null
207 var inputs: MutableMap<String, PropertyDefinition>? = null
208 var outputs: MutableMap<String, PropertyDefinition>? = null
211 class Implementation {
212 lateinit var primary: String
213 var dependencies: MutableList<String>? = null
217 3.5.14 Interface definition
218 An interface definition defines a named interface that can be associated with a Node or Relationship Type
220 class InterfaceDefinition {
222 var id: String? = null
223 var type: String? = null
224 var operations: MutableMap<String, OperationDefinition>? = null
225 var inputs: MutableMap<String, PropertyDefinition>? = null
229 3.5.15 Event Filter definition
230 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.
232 class EventFilterDefinition {
234 var id: String? = null
235 lateinit var node: String
236 var requirement: String? = null
237 var capability: String? = null
241 3.5.16 Trigger definition TODO
242 A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.
244 class TriggerDefinition {
246 var id: String? = null
247 var description: String? = null
248 @get:JsonProperty("event_type")
249 lateinit var eventType: String
250 @get:JsonProperty("target_filter")
251 var targetFilter: EventFilterDefinition? = null
252 var condition: ConditionClause? = null
253 var constraint: ConditionClause? = null
254 var method: String? = null
255 lateinit var action: String
259 3.5.17 Workflow activity definition
260 A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to:
261 · Delegate the workflow for a node expected to be provided by the orchestrator
262 · Set the state of a node
263 · Call an operation defined on a TOSCA interface of a node, relationship or group
264 · Inline another workflow defined in the topology (to allow reusability)
267 var delegate: String? = null
268 @get:JsonProperty("set_state")
269 var setState: String? = null
270 @get:JsonProperty("call_operation")
271 var callOperation: String? = null
272 var inlines: ArrayList<String>? = null
276 3.5.20 Workflow precondition definition
277 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.
279 class PreConditionDefinition {
281 var id: String? = null
282 lateinit var target: String
283 @get:JsonProperty("target_relationship")
284 lateinit var targetRelationship: String
285 lateinit var condition: ArrayList<ConditionClause>
289 3.5.21 Workflow step definition
290 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.
294 var id: String? = null
295 var description: String? = null
296 var target: String? = null
297 @JsonProperty("target_relationship")
298 var targetRelationship: String? = null
299 @JsonProperty("operation_host")
300 var operationHost: String? = null
301 var activities: ArrayList<Activity>? = null
302 @get:JsonProperty("on_success")
303 var onSuccess: ArrayList<String>? = null
304 @get:JsonProperty("on_failure")
305 var onFailure: ArrayList<String>? = null
309 3.6.2 Capability definition
310 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.
313 class CapabilityDefinition {
315 var id: String? = null
316 lateinit var type: String
317 var description: String? = null
318 var properties: MutableMap<String, PropertyDefinition>? = null
319 @get:JsonProperty("valid_source_types")
320 var validSourceTypes: MutableList<String>? = null
321 var occurrences: MutableList<Any>? = null
325 3.6.3 Requirement definition
326 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).
328 class RequirementDefinition {
330 var id: String? = null
331 var description: String? = null
332 var capability: String? = null
333 var node: String? = null
334 var relationship: String? = null
335 var occurrences: MutableList<Any>? = null
340 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.
342 class ArtifactType : EntityType() {
343 @get:JsonProperty("mime_type")
344 var mimeType: String? = null
345 @get:JsonProperty("file_ext")
346 var fileExt: MutableList<String>? = null
352 A Data Type definition defines the schema for new named datatypes in TOSCA.
355 class DataType : EntityType() {
356 var constraints: MutableList<ConstraintClause>? = null
361 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.
365 class NodeType : EntityType() {
366 var capabilities: MutableMap<String, CapabilityDefinition>? = null
367 var requirements: MutableMap<String, RequirementDefinition>? = null
368 var interfaces: MutableMap<String, InterfaceDefinition>? = null
369 var artifacts: MutableMap<String, ArtifactDefinition>? = null
373 3.6.8 Requirement Type
374 A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose. The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types along with a named Feature notation.
377 class RequirementType : EntityType() {
378 var requirements: MutableMap<String, RequirementDefinition>? = null
379 var capabilities: MutableMap<String, CapabilityDefinition>? = null
380 var interfaces: MutableMap<String, InterfaceDefinition>? = null
381 var artifacts: MutableMap<String, ArtifactDefinition>? = null
385 3.6.10 Relationship Type
386 A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.
389 class RelationshipType : EntityType() {
390 var interfaces: MutableMap<String, InterfaceDefinition>? = null
391 @get:JsonProperty("valid_target_types")
392 var validTargetTypes: ArrayList<String>? = null
397 A Group Type defines logical grouping types for nodes, typically for different management purposes.
398 Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology
399 of an application, yet can have capabilities and the ability to attach policies and interfaces
400 that can be applied (depending on the group type) to its member nodes.
403 class GroupType : EntityType() {
404 var members: MutableList<String>? = null
405 var requirements: ArrayList<RequirementDefinition>? = null
406 var capabilities: MutableMap<String, CapabilityDefinition>? = null
407 var interfaces: MutableMap<String, InterfaceDefinition>? = null
413 A Policy Type defines a type of requirement that affects or governs an application or service’s
414 topology at some stage of its lifecycle, but is not explicitly part of the topology itself
415 (i.e., it does not prevent the application or service from being deployed or run if it did not exist).
417 class PolicyType : EntityType() {
418 lateinit var targets: MutableList<String>
422 3.7.1 Capability assignment
423 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.
425 class CapabilityAssignment {
427 var id: String? = null
428 var attributes: MutableMap<String, JsonNode>? = null
429 var properties: MutableMap<String, JsonNode>? = null
433 3.7.4 Relationship Template
434 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.
436 class GroupDefinition {
438 var id: String? = null
439 lateinit var type: String
440 var description: String? = null
441 var metadata: MutableMap<String, String>? = null
442 var properties: MutableMap<String, JsonNode>? = null
443 var members = ArrayList<String>()
444 var interfaces: MutableMap<String, InterfaceDefinition>? = null
448 3.7.6 Policy definition
449 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.).
451 class PolicyDefinition {
453 var id: String? = null
454 lateinit var type: String
455 var description: String? = null
456 var metadata: MutableMap<String, String>? = null
457 var properties: MutableMap<String, JsonNode>? = null
458 var targets: MutableList<String>? = null
463 3.8 Topology Template definition
464 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.
466 class TopologyTemplate {
468 var id: String? = null
469 var description: String? = null
470 var inputs: MutableMap<String, PropertyDefinition>? = null
471 @get:JsonProperty("node_templates")
472 var nodeTemplates: MutableMap<String, NodeTemplate>? = null
473 @get:JsonProperty("relationship_templates")
474 var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
475 var policies: MutableMap<String, PolicyDefinition>? = null
476 var outputs: MutableMap<String, PropertyDefinition>? = null
477 @get:JsonProperty("substitution_mappings")
478 var substitutionMappings: Any? = null
479 var workflows: MutableMap<String, Workflow>? = null
482 class SubstitutionMapping {
483 @get:JsonProperty("node_type")
484 lateinit var nodeType: String
485 lateinit var capabilities: ArrayList<String>
486 lateinit var requirements: ArrayList<String>
490 lateinit var type: String
491 var constraints: MutableList<ConstraintClause>? = null
494 class InterfaceAssignment {
496 var id: String? = null
497 var operations: MutableMap<String, OperationAssignment>? = null
498 var inputs: MutableMap<String, JsonNode>? = null
503 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.
506 open class NodeTemplate {
508 var id: String? = null
509 var description: String? = null
510 lateinit var type: String
511 var metadata: MutableMap<String, String>? = null
512 var directives: MutableList<String>? = null
513 //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
514 var properties: MutableMap<String, JsonNode>? = null
515 var attributes: MutableMap<String, JsonNode>? = null
516 var capabilities: MutableMap<String, CapabilityAssignment>? = null
517 var requirements: MutableMap<String, RequirementAssignment>? = null
518 var interfaces: MutableMap<String, InterfaceAssignment>? = null
519 var artifacts: MutableMap<String, ArtifactDefinition>? = null
520 @get:JsonProperty("node_filter")
521 var nodeFilter: NodeFilterDefinition? = null
522 var copy: String? = null
525 class OperationAssignment {
527 var id: String? = null
528 var description: String? = null
529 var implementation: Implementation? = null
530 var inputs: MutableMap<String, JsonNode>? = null
531 var outputs: MutableMap<String, JsonNode>? = null
535 3.7.4 Relationship Template
536 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.
539 class RelationshipTemplate {
540 var type: String? = null
541 var description: String? = null
542 var metadata: MutableMap<String, String>? = null
543 var properties: MutableMap<String, PropertyDefinition>? = null
544 var attributes: MutableMap<String, JsonNode>? = null
545 var interfaces: MutableMap<String, InterfaceDefinition>? = null
546 var copy: String? = null
550 3.7.2 Requirement assignment
551 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.
554 class RequirementAssignment {
556 var id: String? = null
557 var capability: String? = null
558 var node: String? = null
559 //Relationship Type or Relationship Template
560 var relationship: String? = null
566 var id: String? = null
567 var description: String? = null
568 var steps: MutableMap<String, Step>? = null
569 var preconditions: ArrayList<PreConditionDefinition>? = null
570 var inputs: MutableMap<String, PropertyDefinition>? = null
574 class ConditionClause {
575 var and: ArrayList<MutableMap<String, Any>>? = null
576 var or: ArrayList<MutableMap<String, Any>>? = null
577 @get:JsonProperty("assert")
578 var assertConditions: ArrayList<MutableMap<String, Any>>? = null
582 3.9 Service Template definition
583 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.
586 @JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
588 class ServiceTemplate : Cloneable {
590 var id: String? = null
591 @get:JsonProperty("tosca_definitions_version")
592 var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0"
593 var metadata: MutableMap<String, String>? = null
594 var description: String? = null
595 @get:JsonProperty("dsl_definitions")
596 var dslDefinitions: MutableMap<String, JsonNode>? = null
597 var repositories: MutableMap<String, RepositoryDefinition>? = null
598 var imports: MutableList<ImportDefinition>? = null
599 @get:JsonProperty("artifact_types")
600 var artifactTypes: MutableMap<String, ArtifactType>? = null
601 @get:JsonProperty("data_types")
602 var dataTypes: MutableMap<String, DataType>? = null
603 @get:JsonProperty("relationship_types")
604 var relationshipTypes: MutableMap<String, RelationshipType>? = null
605 @get:JsonProperty("node_types")
606 var nodeTypes: MutableMap<String, NodeType>? = null
607 @get:JsonProperty("policy_types")
608 var policyTypes: MutableMap<String, PolicyType>? = null
609 @get:JsonProperty("topology_template")
610 var topologyTemplate: TopologyTemplate? = null
612 override public fun clone(): ServiceTemplate {
613 return super.clone() as ServiceTemplate
617 class ToscaMetaData {
618 lateinit var toscaMetaFileVersion: String
619 lateinit var csarVersion: String
620 lateinit var createdBy: String
621 lateinit var entityDefinitions: String
622 var templateTags: String? = null