/* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.onap.ccsdk.apps.controllerblueprints.core.data import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.JsonNode import io.swagger.annotations.ApiModelProperty /** * * * @author Brinda Santh */ open class EntityType { @get:JsonIgnore var id: String? = null var description: String? = null var version: String = "1.0.0" var metadata: MutableMap? = null @get:JsonProperty("derived_from") lateinit var derivedFrom: String var attributes: MutableMap? = null var properties: MutableMap? = null } /* 5.3.2 tosca.datatypes.Credential The Credential type is a complex TOSCA data Type used when describing authorization credentials used to access network accessible resources. */ class Credential { @get:JsonIgnore var id: String? = null var protocol: String? = null @get:JsonProperty("token_type") lateinit var tokenType: String lateinit var token: String var keys: MutableMap? = null lateinit var user: String } /* 3.5.2 Constraint clause 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. */ class ConstraintClause { @get:JsonProperty("equal") var equal: JsonNode? = null @get:JsonProperty("greater_than") var greaterThan: Any? = null @get:JsonProperty("greater_or_equal") var greaterOrEqual: Any? = null @get:JsonProperty("less_than") var lessThan: Any? = null @get:JsonProperty("less_or_equal") var lessOrEqual: Any? = null @get:JsonProperty("in_range") var inRange: Any? = null @get:JsonProperty("valid_values") var validValues: MutableList? = null @get:JsonProperty("length") var length: Any? = null @get:JsonProperty("min_length") var minLength: Any? = null @get:JsonProperty("max_length") var maxLength: Any? = null var pattern: String? = null var schema: String? = null } /* 3.5.4 Node Filter definition A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties. */ class NodeFilterDefinition { var properties: MutableMap? = null var capabilities : MutableList? = null } /* 3.5.5 Repository definition A repository definition defines a named external repository which contains deployment and implementation artifacts that are referenced within the TOSCA Service Template. */ class RepositoryDefinition { @get:JsonIgnore var id: String? = null var description: String? = null lateinit var url: String var credential: Credential? = null } /* 3.5.6 Artifact definition An artifact definition defines a named, typed file that can be associated with Node Type or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations. */ class ArtifactDefinition { @get:JsonIgnore var id: String? = null var type: String? = null var file: String? = null var repository: String? = null var description: String? = null @get:JsonProperty("deploy_Path") var deployPath: String? = null var properties: MutableMap? = null var content: String? = null @Deprecated("Mapping content is define by the Type") var mappingContent: String? = null } /* 3.5.7 Import definition An import definition is used within a TOSCA Service Template to locate and uniquely name another TOSCA Service Template file which has type and template definitions to be imported (included) and referenced within another Service Template. */ class ImportDefinition { @get:JsonIgnore var id: String? = null lateinit var file: String var repository: String? = null @get:JsonProperty("namespace_uri") var namespaceUri: String? = null @get:JsonProperty("namespace_prefix") var namespacePrefix: String? = null } /* 3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.). Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates. */ class PropertyDefinition { @get:JsonIgnore var id: String? = null var description: String? = null var required: Boolean? = null lateinit var type: String @get:JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null var constraints: MutableList? = null @get:JsonProperty("entry_schema") var entrySchema: EntrySchema? = null @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values") var value: JsonNode? = null } /* 3.5.10 Attribute definition An attribute definition defines a named, typed value that can be associated with an entity defined in this specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the “actual state” of some property of a TOSCA entity after it has been deployed and instantiated (as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function from the instance model and used as values to other entities within TOSCA Service Templates. */ class AttributeDefinition { @get:JsonIgnore var id: String? = null var description: String? = null lateinit var type: String @JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null @JsonProperty("entry_schema") var entrySchema: String? = null } /* 3.5.13 Operation definition An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script). */ class OperationDefinition { @get:JsonIgnore var id: String? = null var description: String? = null var implementation: Implementation? = null var inputs: MutableMap? = null var outputs: MutableMap? = null } class Implementation { lateinit var primary: String var dependencies: MutableList? = null } /* 3.5.14 Interface definition An interface definition defines a named interface that can be associated with a Node or Relationship Type */ class InterfaceDefinition { @get:JsonIgnore var id: String? = null var type: String? = null var operations: MutableMap? = null var inputs: MutableMap? = null } /* 3.5.15 Event Filter definition 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. */ class EventFilterDefinition { @get:JsonIgnore var id: String? = null lateinit var node: String var requirement: String? = null var capability: String? = null } /* 3.5.16 Trigger definition TODO A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with. */ class TriggerDefinition { @get:JsonIgnore var id: String? = null var description: String? = null @get:JsonProperty("event_type") lateinit var eventType: String @get:JsonProperty("target_filter") var targetFilter: EventFilterDefinition? = null var condition: ConditionClause? = null var constraint: ConditionClause? = null var method: String? = null lateinit var action: String } /* 3.5.17 Workflow activity definition A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to: · Delegate the workflow for a node expected to be provided by the orchestrator · Set the state of a node · Call an operation defined on a TOSCA interface of a node, relationship or group · Inline another workflow defined in the topology (to allow reusability) */ class Activity { var delegate: String? = null @get:JsonProperty("set_state") var setState: String? = null @get:JsonProperty("call_operation") var callOperation: String? = null var inlines: ArrayList? = null } /* 3.5.20 Workflow precondition definition 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. */ class PreConditionDefinition { @get:JsonIgnore var id: String? = null lateinit var target: String @get:JsonProperty("target_relationship") lateinit var targetRelationship: String lateinit var condition: ArrayList } /* 3.5.21 Workflow step definition 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. */ class Step { @get:JsonIgnore var id: String? = null var description: String? = null var target: String? = null @JsonProperty("target_relationship") var targetRelationship: String? = null @JsonProperty("operation_host") var operationHost: String? = null var activities: ArrayList? = null @get:JsonProperty("on_success") var onSuccess: ArrayList? = null @get:JsonProperty("on_failure") var onFailure: ArrayList? = null } /* 3.6.2 Capability definition 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. */ class CapabilityDefinition { @get:JsonIgnore var id: String? = null lateinit var type: String var description: String? = null var properties: MutableMap? = null @get:JsonProperty("valid_source_types") var validSourceTypes: MutableList? = null var occurrences: MutableList? = null } /* 3.6.3 Requirement definition 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). */ class RequirementDefinition { @get:JsonIgnore var id: String? = null var description: String? = null var capability: String? = null var node: String? = null var relationship: String? = null var occurrences: MutableList? = null } /* 3.6.4 Artifact Type 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. */ class ArtifactType : EntityType() { @get:JsonProperty("mime_type") var mimeType: String? = null @get:JsonProperty("file_ext") var fileExt: MutableList? = null } /* 3.6.6 Data Type A Data Type definition defines the schema for new named datatypes in TOSCA. */ class DataType : EntityType(){ var constraints: MutableList? = null } /* 3.6.9 Node Type 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. */ class NodeType : EntityType() { var capabilities: MutableMap? = null var requirements: MutableMap? = null var interfaces: MutableMap? = null var artifacts: MutableMap? = null } /* 3.6.8 Requirement Type 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. */ class RequirementType : EntityType() { var requirements: MutableMap? = null var capabilities: MutableMap? = null var interfaces: MutableMap? = null var artifacts: MutableMap? = null } /* 3.6.10 Relationship Type A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates. */ class RelationshipType : EntityType() { var interfaces: MutableMap? = null @get:JsonProperty("valid_target_types") var validTargetTypes: ArrayList? = null } /* 3.6.11 Group Type A Group Type defines logical grouping types for nodes, typically for different management purposes. Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology of an application, yet can have capabilities and the ability to attach policies and interfaces that can be applied (depending on the group type) to its member nodes. */ class GroupType : EntityType() { var members: MutableList? = null var requirements: ArrayList? = null var capabilities: MutableMap? = null var interfaces: MutableMap? = null } /* 3.6.12 Policy Type A Policy Type defines a type of requirement that affects or governs an application or service’s topology at some stage of its lifecycle, but is not explicitly part of the topology itself (i.e., it does not prevent the application or service from being deployed or run if it did not exist). */ class PolicyType : EntityType(){ lateinit var targets: MutableList } /* 3.7.1 Capability assignment 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. */ class CapabilityAssignment { @get:JsonIgnore var id: String? = null var attributes: MutableMap? = null var properties: MutableMap? = null } /* 3.7.4 Relationship Template 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. */ class GroupDefinition { @get:JsonIgnore var id: String? = null lateinit var type: String var description: String? = null var metadata : MutableMap? = null var properties : MutableMap? = null var members = ArrayList() var interfaces : MutableMap?= null } /* 3.7.6 Policy definition 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.). */ class PolicyDefinition { @get:JsonIgnore var id: String? = null lateinit var type: String var description: String? = null var metadata: MutableMap? = null var properties: MutableMap? = null var targets: MutableList? = null } /* 3.8 Topology Template definition 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. */ class TopologyTemplate { @get:JsonIgnore var id: String? = null var description: String? = null var inputs: MutableMap? = null @get:JsonProperty("node_templates") var nodeTemplates: MutableMap? = null @get:JsonProperty("relationship_templates") var relationshipTemplates: MutableMap? = null var policies: MutableMap? = null var outputs: MutableMap? = null @get:JsonProperty("substitution_mappings") var substitutionMappings: Any? = null var workflows: MutableMap? = null } class SubstitutionMapping { @get:JsonProperty("node_type") lateinit var nodeType: String lateinit var capabilities: ArrayList lateinit var requirements: ArrayList } class EntrySchema { lateinit var type: String var constraints: MutableList? = null } class InterfaceAssignment { @get:JsonIgnore var id: String? = null var operations: MutableMap? = null var inputs: MutableMap? = null } /* 3.7.3 Node Template 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. */ class NodeTemplate { @get:JsonIgnore var id: String? = null var description: String? = null lateinit var type: String var metadata: MutableMap? = null var directives: MutableList? = null //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class) var properties: MutableMap? = null var attributes: MutableMap? = null var capabilities: MutableMap? = null var requirements: MutableMap? = null var interfaces: MutableMap? = null var artifacts: MutableMap? = null @get:JsonProperty("node_filter") var nodeFilter: NodeFilterDefinition? = null var copy: String? = null } class OperationAssignment { @get:JsonIgnore var id: String? = null var description: String? = null var implementation: Implementation? = null var inputs: MutableMap? = null var outputs: MutableMap? = null } /* 3.7.4 Relationship Template 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. */ class RelationshipTemplate { var type: String? = null var description: String? = null var metadata: MutableMap? = null var properties: MutableMap? = null var attributes: MutableMap? = null var interfaces: MutableMap? = null var copy: String? = null } /* 3.7.2 Requirement assignment 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. */ class RequirementAssignment { @get:JsonIgnore var id: String? = null var capability: String? = null var node: String? = null //Relationship Type or Relationship Template var relationship: String? = null } class Workflow { @get:JsonIgnore var id: String? = null var description: String? = null var steps: MutableMap? = null var preconditions: ArrayList? = null var inputs: MutableMap? = null } class ConditionClause { var and: ArrayList>? = null var or: ArrayList>? = null @get:JsonProperty("assert") var assertConditions: ArrayList>? = null } /* 3.9 Service Template definition 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. */ class ServiceTemplate { @get:JsonIgnore var id: String? = null @get:JsonProperty("tosca_definitions_version") var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0" var metadata: MutableMap? = null var description: String? = null @get:JsonProperty("dsl_definitions") var dslDefinitions: MutableMap? = null var repositories: MutableMap? = null var imports: MutableList? = null @get:JsonProperty("artifact_types") var artifactTypes: MutableMap? = null @get:JsonProperty("data_types") var dataTypes: MutableMap? = null @get:JsonProperty("node_types") var nodeTypes: MutableMap? = null @get:JsonProperty("policy_types") var policyTypes: PolicyType? = null @get:JsonProperty("topology_template") var topologyTemplate: TopologyTemplate? = null } class ToscaMetaData { lateinit var toscaMetaFileVersion: String lateinit var csarVersion: String lateinit var createdBy: String lateinit var entityDefinitions: String var templateTags: String? = null }