Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / processor-core / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / core / api / data / BlueprintProcessorData.kt
1 /*
2  *  Copyright © 2017-2018 AT&T Intellectual Property.
3  *  Modifications Copyright © 2018 IBM.
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.blueprintsprocessor.core.api.data
19
20 import com.fasterxml.jackson.annotation.JsonFormat
21 import com.fasterxml.jackson.annotation.JsonIgnore
22 import com.fasterxml.jackson.databind.JsonNode
23 import com.fasterxml.jackson.databind.node.ObjectNode
24 import io.swagger.annotations.ApiModelProperty
25 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
26 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
27 import java.util.Date
28 import java.util.UUID
29
30 /**
31  * BlueprintProcessorData
32  * @author Brinda Santh
33  * DATE : 8/15/2018
34  */
35
36 abstract class CommonExecutionServiceData {
37     @get:ApiModelProperty(required = true, value = "Headers providing request context.")
38     lateinit var commonHeader: CommonHeader
39
40     @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
41     lateinit var actionIdentifiers: ActionIdentifiers
42 }
43
44 open class ExecutionServiceInput : CommonExecutionServiceData() {
45
46     @get:ApiModelProperty(required = false, hidden = true)
47     var correlationUUID: String = UUID.randomUUID().toString()
48
49     @get:ApiModelProperty(
50         required = true,
51         value = "Contain the information to be passed as input to the action." +
52             "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
53             " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
54     )
55     lateinit var payload: ObjectNode
56
57     @get:ApiModelProperty(hidden = true)
58     @get:JsonIgnore
59     var stepData: StepData? = null
60 }
61
62 open class ExecutionServiceOutput : CommonExecutionServiceData() {
63
64     @get:ApiModelProperty(required = false, hidden = true)
65     var correlationUUID: String? = null
66
67     @get:ApiModelProperty(required = true, value = "Status of the request.")
68     lateinit var status: Status
69
70     @get:ApiModelProperty(
71         required = true,
72         value = "Contain the information to be passed as input to the action." +
73             "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
74             " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
75     )
76     lateinit var payload: ObjectNode
77
78     @get:ApiModelProperty(hidden = true)
79     @get:JsonIgnore
80     var stepData: StepData? = null
81 }
82
83 const val ACTION_MODE_ASYNC = "async"
84 const val ACTION_MODE_SYNC = "sync"
85
86 open class ActionIdentifiers {
87
88     @get:ApiModelProperty(required = false, value = "Name of the CBA.")
89     lateinit var blueprintName: String
90
91     @get:ApiModelProperty(required = false, value = "Version of the CBA.")
92     lateinit var blueprintVersion: String
93
94     @get:ApiModelProperty(required = true, value = "Name of the workflow to execute.")
95     lateinit var actionName: String
96
97     @get:ApiModelProperty(
98         required = true,
99         value = "Async processing is only supported for gRPC client.",
100         allowableValues = "sync, async"
101     )
102     lateinit var mode: String
103 }
104
105 open class CommonHeader {
106
107     @get:ApiModelProperty(required = true, value = "Date of the execution", example = "2012-04-23T18:25:43.511Z")
108     @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
109     var timestamp: Date = Date()
110
111     @get:ApiModelProperty(required = true, value = "Identify the system/person triggering the request.")
112     lateinit var originatorId: String
113
114     @get:ApiModelProperty(required = true, value = "Uniquely identify a request.")
115     lateinit var requestId: String
116
117     @get:ApiModelProperty(required = true, value = "Allow for fine-grain request identifier")
118     lateinit var subRequestId: String
119
120     @get:ApiModelProperty(required = false, hidden = true)
121     var flags: Flags? = null
122 }
123
124 open class Flags {
125
126     @get:ApiModelProperty(value = "Whether or not to force the action.")
127     var isForce: Boolean = false
128
129     @get:ApiModelProperty(value = "3600")
130     var ttl: Int = 3600
131 }
132
133 open class Status {
134
135     @get:ApiModelProperty(required = true, value = "HTTP status code equivalent.")
136     var code: Int = 200
137
138     @get:ApiModelProperty(required = true, value = "Type of the event being emitted by CDS.")
139     var eventType: String = EventType.EVENT_COMPONENT_EXECUTED.name
140
141     @get:ApiModelProperty(
142         required = true,
143         value = "Time when the execution ended.",
144         example = "2012-04-23T18:25:43.511Z"
145     )
146     @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
147     var timestamp: Date = Date()
148
149     @get:ApiModelProperty(required = false, value = "Error message when system failed")
150     var errorMessage: String? = null
151
152     @get:ApiModelProperty(required = true, value = "Message providing request status")
153     var message: String = BluePrintConstants.STATUS_SUCCESS
154 }
155
156 open class StepData {
157
158     lateinit var name: String
159     var properties: MutableMap<String, JsonNode> = mutableMapOf()
160 }