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.
18 package org.onap.ccsdk.apps.controllerblueprints.core.data
20 import com.fasterxml.jackson.annotation.JsonIgnore
21 import com.fasterxml.jackson.annotation.JsonProperty
22 import com.fasterxml.jackson.annotation.JsonPropertyOrder
23 import com.fasterxml.jackson.databind.JsonNode
24 import io.swagger.annotations.ApiModelProperty
29 * @author Brinda Santh
31 open class EntityType {
33 var id: String? = null
34 var description: String? = null
35 var version: String = "1.0.0"
36 var metadata: MutableMap<String, String>? = null
37 @get:JsonProperty("derived_from")
38 lateinit var derivedFrom: String
39 var attributes: MutableMap<String, AttributeDefinition>? = null
40 var properties: MutableMap<String, PropertyDefinition>? = null
44 5.3.2 tosca.datatypes.Credential
45 The Credential type is a complex TOSCA data Type used when describing
46 authorization credentials used to access network accessible resources.
50 var id: String? = null
51 var protocol: String? = null
52 @get:JsonProperty("token_type")
53 lateinit var tokenType: String
54 lateinit var token: String
55 var keys: MutableMap<String, String>? = null
56 lateinit var user: String
60 3.5.2 Constraint clause
61 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.
63 class ConstraintClause {
64 @get:JsonProperty("equal")
65 var equal: JsonNode? = null
66 @get:JsonProperty("greater_than")
67 var greaterThan: Any? = null
68 @get:JsonProperty("greater_or_equal")
69 var greaterOrEqual: Any? = null
70 @get:JsonProperty("less_than")
71 var lessThan: Any? = null
72 @get:JsonProperty("less_or_equal")
73 var lessOrEqual: Any? = null
74 @get:JsonProperty("in_range")
75 var inRange: Any? = null
76 @get:JsonProperty("valid_values")
77 var validValues: MutableList<JsonNode>? = null
78 @get:JsonProperty("length")
79 var length: Any? = null
80 @get:JsonProperty("min_length")
81 var minLength: Any? = null
82 @get:JsonProperty("max_length")
83 var maxLength: Any? = null
84 var pattern: String? = null
85 var schema: String? = null
89 3.5.4 Node Filter definition
90 A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties.
93 class NodeFilterDefinition {
94 var properties: MutableMap<String, PropertyDefinition>? = null
95 var capabilities: MutableList<String>? = null
99 3.5.5 Repository definition
100 A repository definition defines a named external repository which contains deployment
101 and implementation artifacts that are referenced within the TOSCA Service Template.
103 class RepositoryDefinition {
105 var id: String? = null
106 var description: String? = null
107 lateinit var url: String
108 var credential: Credential? = null
113 3.5.6 Artifact definition
114 An artifact definition defines a named, typed file that can be associated with Node Type
115 or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.
117 class ArtifactDefinition {
119 var id: String? = null
120 var type: String? = null
121 var file: String? = null
122 var repository: String? = null
123 var description: String? = null
124 @get:JsonProperty("deploy_Path")
125 var deployPath: String? = null
126 var properties: MutableMap<String, JsonNode>? = null
127 var content: String? = null
128 @Deprecated("Mapping content is define by the Type")
129 var mappingContent: String? = 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 {
141 var id: String? = null
142 lateinit var file: String
143 var repository: String? = null
144 @get:JsonProperty("namespace_uri")
145 var namespaceUri: String? = null
146 @get:JsonProperty("namespace_prefix")
147 var namespacePrefix: String? = null
151 3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an
152 entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.).
153 Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are
154 instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates.
156 class PropertyDefinition {
158 var id: String? = null
159 var description: String? = null
160 var required: Boolean? = null
161 lateinit var type: String
162 @get:JsonProperty("default")
163 var defaultValue: JsonNode? = null
164 var status: String? = null
165 var constraints: MutableList<ConstraintClause>? = null
166 @get:JsonProperty("entry_schema")
167 var entrySchema: EntrySchema? = null
168 @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values")
169 var value: JsonNode? = null
174 3.5.10 Attribute definition
176 An attribute definition defines a named, typed value that can be associated with an entity defined in this
177 specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the
178 “actual state” of some property of a TOSCA entity after it has been deployed and instantiated
179 (as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function
180 from the instance model and used as values to other entities within TOSCA Service Templates.
183 class AttributeDefinition {
185 var id: String? = null
186 var description: String? = null
187 var required: Boolean? = null
188 lateinit var type: String
189 @JsonProperty("default")
190 var defaultValue: JsonNode? = null
191 var status: String? = null
192 var constraints: MutableList<ConstraintClause>? = null
193 @JsonProperty("entry_schema")
194 var entrySchema: EntrySchema? = null
198 3.5.13 Operation definition
199 An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).
201 class OperationDefinition {
203 var id: String? = null
204 var description: String? = null
205 var implementation: Implementation? = null
206 var inputs: MutableMap<String, PropertyDefinition>? = null
207 var outputs: MutableMap<String, PropertyDefinition>? = null
210 class Implementation {
211 lateinit var primary: String
212 var dependencies: MutableList<String>? = null
216 3.5.14 Interface definition
217 An interface definition defines a named interface that can be associated with a Node or Relationship Type
219 class InterfaceDefinition {
221 var id: String? = null
222 var type: String? = null
223 var operations: MutableMap<String, OperationDefinition>? = null
224 var inputs: MutableMap<String, PropertyDefinition>? = null
228 3.5.15 Event Filter definition
229 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.
231 class EventFilterDefinition {
233 var id: String? = null
234 lateinit var node: String
235 var requirement: String? = null
236 var capability: String? = null
240 3.5.16 Trigger definition TODO
241 A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.
243 class TriggerDefinition {
245 var id: String? = null
246 var description: String? = null
247 @get:JsonProperty("event_type")
248 lateinit var eventType: String
249 @get:JsonProperty("target_filter")
250 var targetFilter: EventFilterDefinition? = null
251 var condition: ConditionClause? = null
252 var constraint: ConditionClause? = null
253 var method: String? = null
254 lateinit var action: String
258 3.5.17 Workflow activity definition
259 A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to:
260 · Delegate the workflow for a node expected to be provided by the orchestrator
261 · Set the state of a node
262 · Call an operation defined on a TOSCA interface of a node, relationship or group
263 · Inline another workflow defined in the topology (to allow reusability)
266 var delegate: String? = null
267 @get:JsonProperty("set_state")
268 var setState: String? = null
269 @get:JsonProperty("call_operation")
270 var callOperation: String? = null
271 var inlines: ArrayList<String>? = null
275 3.5.20 Workflow precondition definition
276 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.
278 class PreConditionDefinition {
280 var id: String? = null
281 lateinit var target: String
282 @get:JsonProperty("target_relationship")
283 lateinit var targetRelationship: String
284 lateinit var condition: ArrayList<ConditionClause>
288 3.5.21 Workflow step definition
289 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.
293 var id: String? = null
294 var description: String? = null
295 var target: String? = null
296 @JsonProperty("target_relationship")
297 var targetRelationship: String? = null
298 @JsonProperty("operation_host")
299 var operationHost: String? = null
300 var activities: ArrayList<Activity>? = null
301 @get:JsonProperty("on_success")
302 var onSuccess: ArrayList<String>? = null
303 @get:JsonProperty("on_failure")
304 var onFailure: ArrayList<String>? = null
308 3.6.2 Capability definition
309 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.
312 class CapabilityDefinition {
314 var id: String? = null
315 lateinit var type: String
316 var description: String? = null
317 var properties: MutableMap<String, PropertyDefinition>? = null
318 @get:JsonProperty("valid_source_types")
319 var validSourceTypes: MutableList<String>? = null
320 var occurrences: MutableList<Any>? = null
324 3.6.3 Requirement definition
325 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).
327 class RequirementDefinition {
329 var id: String? = null
330 var description: String? = null
331 var capability: String? = null
332 var node: String? = null
333 var relationship: String? = null
334 var occurrences: MutableList<Any>? = null
339 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.
341 class ArtifactType : EntityType() {
342 @get:JsonProperty("mime_type")
343 var mimeType: String? = null
344 @get:JsonProperty("file_ext")
345 var fileExt: MutableList<String>? = null
351 A Data Type definition defines the schema for new named datatypes in TOSCA.
354 class DataType : EntityType() {
355 var constraints: MutableList<ConstraintClause>? = null
360 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.
364 class NodeType : EntityType() {
365 var capabilities: MutableMap<String, CapabilityDefinition>? = null
366 var requirements: MutableMap<String, RequirementDefinition>? = null
367 var interfaces: MutableMap<String, InterfaceDefinition>? = null
368 var artifacts: MutableMap<String, ArtifactDefinition>? = null
372 3.6.8 Requirement Type
373 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.
376 class RequirementType : EntityType() {
377 var requirements: MutableMap<String, RequirementDefinition>? = null
378 var capabilities: MutableMap<String, CapabilityDefinition>? = null
379 var interfaces: MutableMap<String, InterfaceDefinition>? = null
380 var artifacts: MutableMap<String, ArtifactDefinition>? = null
384 3.6.10 Relationship Type
385 A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates.
388 class RelationshipType : EntityType() {
389 var interfaces: MutableMap<String, InterfaceDefinition>? = null
390 @get:JsonProperty("valid_target_types")
391 var validTargetTypes: ArrayList<String>? = null
396 A Group Type defines logical grouping types for nodes, typically for different management purposes.
397 Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology
398 of an application, yet can have capabilities and the ability to attach policies and interfaces
399 that can be applied (depending on the group type) to its member nodes.
402 class GroupType : EntityType() {
403 var members: MutableList<String>? = null
404 var requirements: ArrayList<RequirementDefinition>? = null
405 var capabilities: MutableMap<String, CapabilityDefinition>? = null
406 var interfaces: MutableMap<String, InterfaceDefinition>? = null
412 A Policy Type defines a type of requirement that affects or governs an application or service’s
413 topology at some stage of its lifecycle, but is not explicitly part of the topology itself
414 (i.e., it does not prevent the application or service from being deployed or run if it did not exist).
416 class PolicyType : EntityType() {
417 lateinit var targets: MutableList<String>
421 3.7.1 Capability assignment
422 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.
424 class CapabilityAssignment {
426 var id: String? = null
427 var attributes: MutableMap<String, JsonNode>? = null
428 var properties: MutableMap<String, JsonNode>? = null
432 3.7.4 Relationship Template
433 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.
435 class GroupDefinition {
437 var id: String? = null
438 lateinit var type: String
439 var description: String? = null
440 var metadata: MutableMap<String, String>? = null
441 var properties: MutableMap<String, JsonNode>? = null
442 var members = ArrayList<String>()
443 var interfaces: MutableMap<String, InterfaceDefinition>? = null
447 3.7.6 Policy definition
448 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.).
450 class PolicyDefinition {
452 var id: String? = null
453 lateinit var type: String
454 var description: String? = null
455 var metadata: MutableMap<String, String>? = null
456 var properties: MutableMap<String, JsonNode>? = null
457 var targets: MutableList<String>? = null
462 3.8 Topology Template definition
463 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.
465 class TopologyTemplate {
467 var id: String? = null
468 var description: String? = null
469 var inputs: MutableMap<String, PropertyDefinition>? = null
470 @get:JsonProperty("node_templates")
471 var nodeTemplates: MutableMap<String, NodeTemplate>? = null
472 @get:JsonProperty("relationship_templates")
473 var relationshipTemplates: MutableMap<String, RelationshipTemplate>? = null
474 var policies: MutableMap<String, PolicyDefinition>? = null
475 var outputs: MutableMap<String, PropertyDefinition>? = null
476 @get:JsonProperty("substitution_mappings")
477 var substitutionMappings: Any? = null
478 var workflows: MutableMap<String, Workflow>? = null
481 class SubstitutionMapping {
482 @get:JsonProperty("node_type")
483 lateinit var nodeType: String
484 lateinit var capabilities: ArrayList<String>
485 lateinit var requirements: ArrayList<String>
489 lateinit var type: String
490 var constraints: MutableList<ConstraintClause>? = null
493 class InterfaceAssignment {
495 var id: String? = null
496 var operations: MutableMap<String, OperationAssignment>? = null
497 var inputs: MutableMap<String, JsonNode>? = null
502 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.
505 open class NodeTemplate {
507 var id: String? = null
508 var description: String? = null
509 lateinit var type: String
510 var metadata: MutableMap<String, String>? = null
511 var directives: MutableList<String>? = null
512 //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
513 var properties: MutableMap<String, JsonNode>? = null
514 var attributes: MutableMap<String, JsonNode>? = null
515 var capabilities: MutableMap<String, CapabilityAssignment>? = null
516 var requirements: MutableMap<String, RequirementAssignment>? = null
517 var interfaces: MutableMap<String, InterfaceAssignment>? = null
518 var artifacts: MutableMap<String, ArtifactDefinition>? = null
519 @get:JsonProperty("node_filter")
520 var nodeFilter: NodeFilterDefinition? = null
521 var copy: String? = null
524 class OperationAssignment {
526 var id: String? = null
527 var description: String? = null
528 var implementation: Implementation? = null
529 var inputs: MutableMap<String, JsonNode>? = null
530 var outputs: MutableMap<String, JsonNode>? = null
534 3.7.4 Relationship Template
535 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.
538 class RelationshipTemplate {
539 var type: String? = null
540 var description: String? = null
541 var metadata: MutableMap<String, String>? = null
542 var properties: MutableMap<String, PropertyDefinition>? = null
543 var attributes: MutableMap<String, JsonNode>? = null
544 var interfaces: MutableMap<String, InterfaceDefinition>? = null
545 var copy: String? = null
549 3.7.2 Requirement assignment
550 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.
553 class RequirementAssignment {
555 var id: String? = null
556 var capability: String? = null
557 var node: String? = null
558 //Relationship Type or Relationship Template
559 var relationship: String? = null
565 var id: String? = null
566 var description: String? = null
567 var steps: MutableMap<String, Step>? = null
568 var preconditions: ArrayList<PreConditionDefinition>? = null
569 var inputs: MutableMap<String, PropertyDefinition>? = null
573 class ConditionClause {
574 var and: ArrayList<MutableMap<String, Any>>? = null
575 var or: ArrayList<MutableMap<String, Any>>? = null
576 @get:JsonProperty("assert")
577 var assertConditions: ArrayList<MutableMap<String, Any>>? = null
581 3.9 Service Template definition
582 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.
585 @JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"])
586 class ServiceTemplate : Cloneable {
588 var id: String? = null
589 @get:JsonProperty("tosca_definitions_version")
590 var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0"
591 var metadata: MutableMap<String, String>? = null
592 var description: String? = null
593 @get:JsonProperty("dsl_definitions")
594 var dslDefinitions: MutableMap<String, Any>? = null
595 var repositories: MutableMap<String, RepositoryDefinition>? = null
596 var imports: MutableList<ImportDefinition>? = null
597 @get:JsonProperty("artifact_types")
598 var artifactTypes: MutableMap<String, ArtifactType>? = null
599 @get:JsonProperty("data_types")
600 var dataTypes: MutableMap<String, DataType>? = null
601 @get:JsonProperty("relationship_types")
602 var relationshipTypes: MutableMap<String, RelationshipType>? = null
603 @get:JsonProperty("node_types")
604 var nodeTypes: MutableMap<String, NodeType>? = null
605 @get:JsonProperty("policy_types")
606 var policyTypes: MutableMap<String, PolicyType>? = null
607 @get:JsonProperty("topology_template")
608 var topologyTemplate: TopologyTemplate? = null
610 override public fun clone(): ServiceTemplate {
611 return super.clone() as ServiceTemplate
615 class ToscaMetaData {
616 lateinit var toscaMetaFileVersion: String
617 lateinit var csarVersion: String
618 lateinit var createdBy: String
619 lateinit var entityDefinitions: String
620 var templateTags: String? = null