Fix missing status event type workflow response.
[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.*
28
29 /**
30  * BlueprintProcessorData
31  * @author Brinda Santh
32  * DATE : 8/15/2018
33  */
34
35 open class ExecutionServiceInput {
36     @get:ApiModelProperty(required = true, value = "Headers providing request context.")
37     lateinit var commonHeader: CommonHeader
38     @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
39     lateinit var actionIdentifiers: ActionIdentifiers
40     @get:ApiModelProperty(required = true,
41             value = "Contain the information to be passed as input to the action." +
42                     "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
43                     " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
44     lateinit var payload: ObjectNode
45     @get:ApiModelProperty(hidden = true)
46     @get:JsonIgnore
47     var stepData: StepData? = null
48 }
49
50 open class ExecutionServiceOutput {
51     @get:ApiModelProperty(required = true, value = "Headers providing request context.")
52     lateinit var commonHeader: CommonHeader
53     @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
54     lateinit var actionIdentifiers: ActionIdentifiers
55     @get:ApiModelProperty(required = true, value = "Status of the request.")
56     lateinit var status: Status
57     @get:ApiModelProperty(required = true,
58             value = "Contain the information to be passed as input to the action." +
59                     "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
60                     " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
61     lateinit var payload: ObjectNode
62     @get:ApiModelProperty(hidden = true)
63     @get:JsonIgnore
64     var stepData: StepData? = null
65 }
66
67 const val ACTION_MODE_ASYNC = "async"
68 const val ACTION_MODE_SYNC = "sync"
69
70 open class ActionIdentifiers {
71     @get:ApiModelProperty(required = false, value = "Name of the CBA.")
72     lateinit var blueprintName: String
73     @get:ApiModelProperty(required = false, value = "Version of the CBA.")
74     lateinit var blueprintVersion: String
75     @get:ApiModelProperty(required = true, value = "Name of the workflow to execute.")
76     lateinit var actionName: String
77     @get:ApiModelProperty(required = true,
78             value = "Async processing is only supported for gRPC client.",
79             allowableValues = "sync, async")
80     lateinit var mode: String
81 }
82
83 open class CommonHeader {
84     @get:ApiModelProperty(required = true, value = "Date of the execution", example = "2012-04-23T18:25:43.511Z")
85     @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
86     var timestamp: Date = Date()
87     @get:ApiModelProperty(required = true, value = "Identify the system/person triggering the request.")
88     lateinit var originatorId: String
89     @get:ApiModelProperty(required = true, value = "Uniquely identify a request.")
90     lateinit var requestId: String
91     @get:ApiModelProperty(required = true, value = "Allow for fine-grain request identifier")
92     lateinit var subRequestId: String
93     @get:ApiModelProperty(required = false, hidden = true)
94     var flags: Flags? = null
95 }
96
97 open class Flags {
98     @get:ApiModelProperty(value = "Whether or not to force the action.")
99     var isForce: Boolean = false
100     @get:ApiModelProperty(value = "3600")
101     var ttl: Int = 3600
102 }
103
104 open class Status {
105     @get:ApiModelProperty(required = true, value = "HTTP status code equivalent.")
106     var code: Int = 200
107     @get:ApiModelProperty(required = true, value = "Type of the event being emitted by CDS.")
108     var eventType: String = EventType.EVENT_COMPONENT_EXECUTED.name
109     @get:ApiModelProperty(required = true,
110             value = "Time when the execution ended.",
111             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     @get:ApiModelProperty(required = false, value = "Error message when system failed")
115     var errorMessage: String? = null
116     @get:ApiModelProperty(required = true, value = "Message providing request status")
117     var message: String = BluePrintConstants.STATUS_SUCCESS
118 }
119
120 open class StepData {
121     lateinit var name: String
122     var properties: MutableMap<String, JsonNode> = mutableMapOf()
123 }