Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-plugins / src / main / java / org / openecomp / dcae / apod / analytics / cdap / plugins / domain / config / tca / SimpleTCAPluginConfig.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.cdap.plugins.domain.config.tca;
22
23 import co.cask.cdap.api.annotation.Description;
24 import co.cask.cdap.api.annotation.Macro;
25 import com.google.common.base.Objects;
26 import org.openecomp.dcae.apod.analytics.cdap.common.settings.CDAPBasePluginConfig;
27
28 import javax.annotation.Nullable;
29
30 /**
31  * Simple TCA Plugin Configuration
32  * <p>
33  * @author Rajiv Singla . Creation Date: 2/13/2017.
34  */
35 public class SimpleTCAPluginConfig extends CDAPBasePluginConfig {
36
37     private static final long serialVersionUID = 1L;
38
39     @Description("Field name containing VES Message")
40     @Macro
41     protected String vesMessageFieldName;
42
43     @Description("Policy JSON that need to be applied to VES Message")
44     @Macro
45     protected String policyJson;
46
47     @Description("Name of the output field that will contain the alert")
48     @Macro
49     protected String alertFieldName;
50
51     @Description("Name of the output field that will contain message type: INAPPLICABLE, COMPLIANT, NON_COMPLIANT")
52     @Macro
53     protected String messageTypeFieldName;
54
55     @Description("Specifies the output schema")
56     protected String schema;
57
58     @Description("Enables")
59     @Nullable
60     @Macro
61     protected Boolean enableAlertCEFFormat;
62
63
64     /**
65      * Creates an instance of TCA Plugin Configs
66      *
67      * @param vesMessageFieldName Ves message field name from incoming plugin schema
68      * @param policyJson TCA Policy Json String
69      * @param alertFieldName Alert field name that will be added in TCA plugin output schema
70      * @param messageTypeFieldName Message type field name that will be added in TCA plugin output schema
71      * @param schema TCA Plugin output schema
72      * @param enableAlertCEFFormat enables alert message to be formatted in VES format
73      */
74     public SimpleTCAPluginConfig(final String vesMessageFieldName, final String policyJson,
75                                  final String alertFieldName, final String messageTypeFieldName,
76                                  final String schema, final Boolean enableAlertCEFFormat) {
77         this.vesMessageFieldName = vesMessageFieldName;
78         this.policyJson = policyJson;
79         this.alertFieldName = alertFieldName;
80         this.messageTypeFieldName = messageTypeFieldName;
81         this.schema = schema;
82         this.enableAlertCEFFormat = enableAlertCEFFormat;
83     }
84
85     /**
86      * Name of the field containing VES Message
87      *
88      * @return VES Message field name
89      */
90     public String getVesMessageFieldName() {
91         return vesMessageFieldName;
92     }
93
94     /**
95      * Policy Json String
96      *
97      * @return Policy Json String
98      */
99     public String getPolicyJson() {
100         return policyJson;
101     }
102
103
104     /**
105      * Alert Field name in outgoing schema
106      *
107      * @return alert field name in outgoing schema
108      */
109     public String getAlertFieldName() {
110         return alertFieldName;
111     }
112
113     /**
114      * Returns output schema string
115      *
116      * @return output schema string
117      */
118     public String getSchema() {
119         return schema;
120     }
121
122     /**
123      * Return TCA message type - INAPPLICABLE, COMPLIANT, NON_COMPLIANT
124      *
125      * @return tca message type
126      */
127     public String getMessageTypeFieldName() {
128         return messageTypeFieldName;
129     }
130
131
132     /**
133      * Returns if Alert output in Common Event format
134      *
135      * @return true if alert output is in common event format
136      */
137     @Nullable
138     public Boolean getEnableAlertCEFFormat() {
139         return enableAlertCEFFormat;
140     }
141
142     @Override
143     public String toString() {
144         return Objects.toStringHelper(this)
145                 .add("referenceName", referenceName)
146                 .add("vesMessageFieldName", vesMessageFieldName)
147                 .add("policyJson", policyJson)
148                 .add("alertFieldName", alertFieldName)
149                 .add("messageTypeFieldName", messageTypeFieldName)
150                 .add("schema", schema)
151                 .add("enableAlertCEFFormat", true)
152                 .toString();
153     }
154 }