CDS add Swagger annotations for Resource, Template, Dictionary and Config API
[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("input-param")
66     var inputParameter: Boolean = false
67
68     @JsonProperty("dictionary-name")
69     var dictionaryName: String? = null
70
71     @JsonProperty("dictionary-source")
72     var dictionarySource: String? = null
73
74     /** Modified Source definition,  Capability Source will use for script reference changes,
75      * Rest Source will use for extra headers etc **/
76     @JsonProperty("dictionary-source-definition")
77     var dictionarySourceDefinition: NodeTemplate? = null
78
79     /** Duplicate field : Shall be used directly from Dictionary Source definition dependencies. **/
80     @JsonProperty("dependencies")
81     var dependencies: MutableList<String>? = null
82
83     @JsonProperty("version")
84     var version: Int = 0
85
86     @JsonProperty("status")
87     var status: String? = null
88
89     @JsonProperty("message")
90     var message: String? = null
91
92     @JsonProperty("updated-date")
93     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
94     var updatedDate: Date? = null
95
96     @JsonProperty("updated-by")
97     var updatedBy: String? = null
98
99     /** input & output key-mapping with their resolved values **/
100     var keyIdentifiers: MutableList<KeyIdentifier> = mutableListOf()
101
102     override fun toString(): String {
103         return """
104             [
105                 name = $name
106                 status = $status
107                 required = ${property?.required}
108                 dependencies = $dependencies
109                 dictionaryName = $dictionaryName
110                 dictionarySource = $dictionarySource
111             ]
112         """.trimIndent()
113     }
114 }
115
116 data class KeyIdentifier(val name: String, val value: JsonNode)
117 data class DictionaryMetadataEntry(val name: String, val value: String)
118
119 /**
120  * Data class for exposing summary of resource resolution
121  */
122 data class ResolutionSummary(
123     val name: String,
124     val value: JsonNode,
125     val required: Boolean,
126     val type: String,
127     @JsonProperty("key-identifiers")
128     val keyIdentifiers: MutableList<KeyIdentifier>,
129     @JsonProperty("dictionary-description")
130     val dictionaryDescription: String,
131     @JsonProperty("dictionary-metadata")
132     val dictionaryMetadata: MutableList<DictionaryMetadataEntry>,
133     @JsonProperty("dictionary-name")
134     val dictionaryName: String,
135     @JsonProperty("dictionary-source")
136     val dictionarySource: String,
137     @JsonProperty("request-payload")
138     val requestPayload: JsonNode,
139     @JsonProperty("status")
140     val status: String,
141     @JsonProperty("message")
142     val message: String
143 )
144
145 /**
146  * Interface for Source Definitions (ex Input Source,
147  * Default Source, Database Source, Rest Sources, etc)
148  */
149 interface ResourceSource : Serializable
150
151 open class ResourceSourceMapping {
152
153     lateinit var resourceSourceMappings: MutableMap<String, String>
154 }