Add properties to ResolutionSummary
[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 org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
24 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
25 import java.io.Serializable
26 import java.util.Date
27
28 open class ResourceDefinition {
29
30     @JsonProperty(value = "name", required = true)
31     lateinit var name: String
32
33     @JsonProperty(value = "property", required = true)
34     lateinit var property: PropertyDefinition
35
36     var tags: String? = null
37
38     /** The default group for Resource Definition is "default" */
39     @JsonProperty(value = "group", required = true)
40     var group: String = "default"
41
42     @JsonProperty(value = "updated-by")
43     lateinit var updatedBy: String
44
45     @JsonProperty(value = "sources", required = true)
46     lateinit var sources: MutableMap<String, NodeTemplate>
47 }
48
49 open class ResourceAssignment {
50
51     @JsonProperty(value = "name", required = true)
52     lateinit var name: String
53
54     @JsonProperty(value = "property")
55     var property: PropertyDefinition? = null
56
57     @JsonProperty("input-param")
58     var inputParameter: Boolean = false
59
60     @JsonProperty("dictionary-name")
61     var dictionaryName: String? = null
62
63     @JsonProperty("dictionary-source")
64     var dictionarySource: String? = null
65
66     /** Modified Source definition,  Capability Source will use for script reference changes,
67      * Rest Source will use for extra headers etc **/
68     @JsonProperty("dictionary-source-definition")
69     var dictionarySourceDefinition: NodeTemplate? = null
70
71     /** Duplicate field : Shall be used directly from Dictionary Source definition dependencies. **/
72     @JsonProperty("dependencies")
73     var dependencies: MutableList<String>? = null
74
75     @JsonProperty("version")
76     var version: Int = 0
77
78     @JsonProperty("status")
79     var status: String? = null
80
81     @JsonProperty("message")
82     var message: String? = null
83
84     @JsonProperty("updated-date")
85     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
86     var updatedDate: Date? = null
87
88     @JsonProperty("updated-by")
89     var updatedBy: String? = null
90
91     /** input & output key-mapping with their resolved values **/
92     var keyIdentifiers: MutableList<KeyIdentifier> = mutableListOf()
93
94     override fun toString(): String {
95         return """
96             [
97                 name = $name
98                 status = $status
99                 required = ${property?.required}
100                 dependencies = $dependencies
101                 dictionaryName = $dictionaryName
102                 dictionarySource = $dictionarySource
103             ]
104             """.trimIndent()
105     }
106 }
107
108 data class KeyIdentifier(val name: String, val value: JsonNode)
109 data class DictionaryMetadataEntry(val name: String, val value: String)
110 /**
111  * Data class for exposing summary of resource resolution
112  */
113 data class ResolutionSummary(
114     val name: String,
115     val value: JsonNode?,
116     val required: Boolean?,
117     val type: String?,
118     @JsonProperty("key-identifiers")
119     val keyIdentifiers: MutableList<KeyIdentifier>,
120     @JsonProperty("dictionary-description")
121     val dictionaryDescription: String?,
122     @JsonProperty("dictionary-metadata")
123     val dictionaryMetadata: MutableList<DictionaryMetadataEntry>,
124     @JsonProperty("dictionary-name")
125     val dictionaryName: String?,
126     @JsonProperty("dictionary-source")
127     val dictionarySource: String?,
128     @JsonProperty("request-payload")
129     val requestPayload: JsonNode?,
130     @JsonProperty("status")
131     val status: String?,
132     @JsonProperty("message")
133     val message: String?
134 )
135 /**
136  * Interface for Source Definitions (ex Input Source,
137  * Default Source, Database Source, Rest Sources, etc)
138  */
139 interface ResourceSource : Serializable
140
141 open class ResourceSourceMapping {
142     lateinit var resourceSourceMappings: MutableMap<String, String>
143 }