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 open class ExecutionServiceInput {
37
38     @get:ApiModelProperty(required = false, hidden = true)
39     var correlationUUID: String = UUID.randomUUID().toString()
40
41     @get:ApiModelProperty(required = true, value = "Headers providing request context.")
42     lateinit var commonHeader: CommonHeader
43
44     @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
45     lateinit var actionIdentifiers: ActionIdentifiers
46
47     @get:ApiModelProperty(
48         required = true,
49         value = "Contain the information to be passed as input to the action." +
50             "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
51             " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
52     )
53     lateinit var payload: ObjectNode
54
55     @get:ApiModelProperty(hidden = true)
56     @get:JsonIgnore
57     var stepData: StepData? = null
58 }
59
60 open class ExecutionServiceOutput {
61
62     @get:ApiModelProperty(required = false, hidden = true)
63     var correlationUUID: String? = null
64
65     @get:ApiModelProperty(required = true, value = "Headers providing request context.")
66     lateinit var commonHeader: CommonHeader
67
68     @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
69     lateinit var actionIdentifiers: ActionIdentifiers
70
71     @get:ApiModelProperty(required = true, value = "Status of the request.")
72     lateinit var status: Status
73
74     @get:ApiModelProperty(
75         required = true,
76         value = "Contain the information to be passed as input to the action." +
77             "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
78             " and the input for resource resolution located within the xxx-request block, contained within xxx-properties"
79     )
80     lateinit var payload: ObjectNode
81
82     @get:ApiModelProperty(hidden = true)
83     @get:JsonIgnore
84     var stepData: StepData? = null
85 }
86
87 const val ACTION_MODE_ASYNC = "async"
88 const val ACTION_MODE_SYNC = "sync"
89
90 open class ActionIdentifiers {
91
92     @get:ApiModelProperty(required = false, value = "Name of the CBA.")
93     lateinit var blueprintName: String
94
95     @get:ApiModelProperty(required = false, value = "Version of the CBA.")
96     lateinit var blueprintVersion: String
97
98     @get:ApiModelProperty(required = true, value = "Name of the workflow to execute.")
99     lateinit var actionName: String
100
101     @get:ApiModelProperty(
102         required = true,
103         value = "Async processing is only supported for gRPC client.",
104         allowableValues = "sync, async"
105     )
106     lateinit var mode: String
107 }
108
109 open class CommonHeader {
110
111     @get:ApiModelProperty(required = true, value = "Date of the execution", example = "2012-04-23T18:25:43.511Z")
112     @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
113     var timestamp: Date = Date()
114
115     @get:ApiModelProperty(required = true, value = "Identify the system/person triggering the request.")
116     lateinit var originatorId: String
117
118     @get:ApiModelProperty(required = true, value = "Uniquely identify a request.")
119     lateinit var requestId: String
120
121     @get:ApiModelProperty(required = true, value = "Allow for fine-grain request identifier")
122     lateinit var subRequestId: String
123
124     @get:ApiModelProperty(required = false, hidden = true)
125     var flags: Flags? = null
126 }
127
128 open class Flags {
129
130     @get:ApiModelProperty(value = "Whether or not to force the action.")
131     var isForce: Boolean = false
132
133     @get:ApiModelProperty(value = "3600")
134     var ttl: Int = 3600
135 }
136
137 open class Status {
138
139     @get:ApiModelProperty(required = true, value = "HTTP status code equivalent.")
140     var code: Int = 200
141
142     @get:ApiModelProperty(required = true, value = "Type of the event being emitted by CDS.")
143     var eventType: String = EventType.EVENT_COMPONENT_EXECUTED.name
144
145     @get:ApiModelProperty(
146         required = true,
147         value = "Time when the execution ended.",
148         example = "2012-04-23T18:25:43.511Z"
149     )
150     @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
151     var timestamp: Date = Date()
152
153     @get:ApiModelProperty(required = false, value = "Error message when system failed")
154     var errorMessage: String? = null
155
156     @get:ApiModelProperty(required = true, value = "Message providing request status")
157     var message: String = BlueprintConstants.STATUS_SUCCESS
158 }
159
160 open class StepData {
161
162     lateinit var name: String
163     var properties: MutableMap<String, JsonNode> = mutableMapOf()
164 }