f92548612e5b86c02c0a2182f54a29fcecfc7402
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / blueprints / resource-dict / src / main / kotlin / org / onap / ccsdk / cds / controllerblueprints / resource / dict / ResourceDefinition.kt
1 /*
2  *  Copyright © 2018 IBM.
3  *  Modifications Copyright © 2017-2018 AT&T Intellectual Property.
4  *
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 package org.onap.ccsdk.cds.controllerblueprints.resource.dict
19
20 import com.fasterxml.jackson.annotation.JsonFormat
21 import com.fasterxml.jackson.annotation.JsonProperty
22 import com.fasterxml.jackson.databind.JsonNode
23 import io.swagger.annotations.ApiModel
24 import io.swagger.annotations.ApiModelProperty
25 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
26 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
27 import java.io.Serializable
28 import java.util.Date
29
30 @ApiModel
31 open class ResourceDefinition {
32
33     @JsonProperty(value = "name", required = true)
34     @ApiModelProperty(value = "Name", required = true, example = "\"default-source\"")
35     lateinit var name: String
36
37     @JsonProperty(value = "property", required = true)
38     @ApiModelProperty(value = "Property", required = true)
39     lateinit var property: PropertyDefinition
40
41     var tags: String? = null
42
43     /** The default group for Resource Definition is "default" */
44     @JsonProperty(value = "group", required = true)
45     @ApiModelProperty(value = "Group", required = true, example = "\"default\"")
46     var group: String = "default"
47
48     @JsonProperty(value = "updated-by")
49     @ApiModelProperty(value = "Updated by", required = true, example = "\"example@onap.com\"")
50     lateinit var updatedBy: String
51
52     @JsonProperty(value = "sources", required = true)
53     @ApiModelProperty(value = "Sources", required = true, example = "\"sources\"")
54     lateinit var sources: MutableMap<String, NodeTemplate>
55 }
56
57 open class ResourceAssignment {
58
59     @JsonProperty(value = "name", required = true)
60     lateinit var name: String
61
62     @JsonProperty(value = "property")
63     var property: PropertyDefinition? = null
64
65     @JsonProperty(value = "max-occurrence")
66     var maxOccurrence: Int? = null
67
68     @JsonProperty("input-param")
69     var inputParameter: Boolean = false
70
71     @JsonProperty("dictionary-name")
72     var dictionaryName: String? = null
73
74     @JsonProperty("dictionary-source")
75     var dictionarySource: String? = null
76
77     /** Modified Source definition,  Capability Source will use for script reference changes,
78      * Rest Source will use for extra headers etc **/
79     @JsonProperty("dictionary-source-definition")
80     var dictionarySourceDefinition: NodeTemplate? = null
81
82     /** Duplicate field : Shall be used directly from Dictionary Source definition dependencies. **/
83     @JsonProperty("dependencies")
84     var dependencies: MutableList<String>? = null
85
86     @JsonProperty("version")
87     var version: Int = 0
88
89     @JsonProperty("status")
90     var status: String? = null
91
92     @JsonProperty("message")
93     var message: String? = null
94
95     @JsonProperty("updated-date")
96     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
97     var updatedDate: Date? = null
98
99     @JsonProperty("updated-by")
100     var updatedBy: String? = null
101
102     /** input & output key-mapping with their resolved values **/
103     var keyIdentifiers: MutableList<KeyIdentifier> = mutableListOf()
104
105     override fun toString(): String {
106         return """
107             [
108                 name = $name
109                 status = $status
110                 required = ${property?.required}
111                 dependencies = $dependencies
112                 dictionaryName = $dictionaryName
113                 dictionarySource = $dictionarySource
114             ]
115         """.trimIndent()
116     }
117 }
118
119 data class KeyIdentifier(val name: String, val value: JsonNode)
120 data class DictionaryMetadataEntry(val name: String, val value: String)
121
122 /**
123  * Data class for exposing summary of resource resolution
124  */
125 data class ResolutionSummary(
126     val name: String,
127     val value: JsonNode,
128     val required: Boolean,
129     val type: String,
130     @JsonProperty("key-identifiers")
131     val keyIdentifiers: MutableList<KeyIdentifier>,
132     @JsonProperty("dictionary-description")
133     val dictionaryDescription: String,
134     @JsonProperty("dictionary-metadata")
135     val dictionaryMetadata: MutableList<DictionaryMetadataEntry>,
136     @JsonProperty("dictionary-name")
137     val dictionaryName: String,
138     @JsonProperty("dictionary-source")
139     val dictionarySource: String,
140     @JsonProperty("request-payload")
141     val requestPayload: JsonNode,
142     @JsonProperty("status")
143     val status: String,
144     @JsonProperty("message")
145     val message: String
146 )
147
148 /**
149  * Interface for Source Definitions (ex Input Source,
150  * Default Source, Database Source, Rest Sources, etc)
151  */
152 interface ResourceSource : Serializable
153
154 open class ResourceSourceMapping {
155
156     lateinit var resourceSourceMappings: MutableMap<String, String>
157 }