ae9ba8a885cfb65456bf1bff3995788fdc303ee8
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / onap / policy / api / PolicyParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 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.onap.policy.api;
22
23 import java.util.ArrayList;
24 import java.util.Date;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.UUID;
28
29 /**
30  * <code>PolicyParameters</code> defines the Policy Parameters
31  *  which are required to Create/Update a Policy. 
32  * 
33  * @version 0.1
34  */
35 public class PolicyParameters {
36         private PolicyClass policyClass;
37         private PolicyConfigType policyConfigType;
38         private String policyName;
39         private String policyDescription;
40         private String onapName;
41         private String configName;
42         private Map<AttributeType, Map<String,String>> attributes;
43         private Map<String, String> treatments;
44         private String configBody;
45         private PolicyType configBodyType;
46         private String actionPerformer;
47         private String actionAttribute;
48         private UUID requestID;
49         private List<String> dynamicRuleAlgorithmLabels;
50         private List<String> dynamicRuleAlgorithmFunctions;
51         private List<String> dynamicRuleAlgorithmField1;
52         private List<String> dynamicRuleAlgorithmField2;
53         private String priority;
54         private RuleProvider ruleProvider;
55         private String controllerName;
56         private ArrayList<String> dependencyNames;
57         private Date ttlDate;
58         private boolean guard = false;
59         private String riskLevel = "5";
60         private String riskType = "default";
61         private String extendedOption;
62         
63         /**
64          * Sets Config Policy Parameters.
65          * 
66          * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
67          * @param policyName the <code>String</code> format of the Policy Name
68          * @param policyDescription the <code>String</code> format of the Policy Description
69          * @param onapName the <code>String</code> format of the ONAP Name
70          * @param configName the <code>String</code> format of the Config Name
71          * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
72          * @param configBodyType the {@link org.onap.policy.api.PolicyType} Enum format of the config Body Type. 
73          * @param configBody the <code>String</code> format of the Policy Body
74          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
75          * A different request ID should be passed for each request.
76          */
77         public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String onapName, String configName, 
78                         Map<AttributeType, Map<String, String>> attributes, PolicyType configBodyType, String configBody, UUID requestID){
79                 this.setPolicyConfigType(policyConfigType);
80                 this.setPolicyName(policyName);
81                 this.setPolicyDescription(policyDescription);
82                 this.setOnapName(onapName);
83                 this.setConfigName(configName);
84                 this.setAttributes(attributes);
85                 this.setConfigBody(configBody);
86                 this.setConfigBodyType(configBodyType);
87                 this.setRequestID(requestID);
88         }
89         
90         /**
91          * Sets config Firewall Policy Parameters.
92          * 
93          * @param policyName the <code>String</code> format of the Policy Name
94          * @param firewallJson the <code>String</code> representation of the Firewall Rules List
95          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
96          * A different request ID should be passed for each request.
97          */
98         public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){
99                 this.setPolicyConfigType(PolicyConfigType.Firewall);
100                 this.setPolicyName(policyName);
101                 this.setConfigBody(firewallJson);
102                 this.setConfigBodyType(PolicyType.JSON);
103                 this.setRequestID(requestID);
104         }
105
106         /**
107          * Gets the PolicyName of the Policy Parameters. 
108          * 
109          * @return policyName the <code>String</code> format of the Policy Name
110          */
111         public String getPolicyName() {
112                 return policyName;
113         }
114
115         /**
116          * Sets the policyName of the Policy Parameters.
117          * 
118          * @param policyName the <code>String</code> format of the Policy Name
119          */
120         public void setPolicyName(String policyName) {
121                 this.policyName = policyName;
122         }
123
124         /**
125          * Gets the policy Description. 
126          * 
127          * @return the <code>String</code> format of the Policy Description
128          */
129         public String getPolicyDescription() {
130                 return policyDescription;
131         }
132
133         /**
134          * Sets the policy Description of the Policy Description. 
135          * 
136          * @param policyDescription the <code>String</code> format of the Policy Description
137          */
138         public void setPolicyDescription(String policyDescription) {
139                 this.policyDescription = policyDescription;
140         }
141
142         /**
143          * Gets the ONAP Name value of the Policy Paramters. 
144          * 
145          * @return <code>String</code> format of the ONAP Name
146          */
147         public String getOnapName() {
148                 return onapName;
149         }
150         
151         /**
152      * Gets the ONAP Name value of the Policy Paramters. 
153      * 
154      * @return <code>String</code> format of the ONAP Name
155      * @deprecated Use {@link #getOnapName()} instead. 
156      */
157         @Deprecated
158     public String getEcompName() {
159         return onapName;
160     }
161
162         /**
163          * Sets the ONAP Name field of the Policy Parameters. 
164          * 
165          * @param onapName the <code>String</code> format of the ONAP Name
166          */
167         public void setOnapName(String onapName) {
168                 this.onapName = onapName;
169         }
170         
171         /**
172      * Sets the ONAP Name field of the Policy Parameters. 
173      * 
174      * @param ecompName the <code>String</code> format of the ONAP Name
175      * @deprecated use {@link #setOnapName(String)} instead. 
176      */
177         @Deprecated
178     public void setEcompName(String ecompName) {
179         this.onapName = ecompName;
180     }
181     
182
183         /**
184          * Gets the Config Name value of the Policy Parameters. 
185          * 
186          * @return <code>String</code> format of the Config Name
187          */
188         public String getConfigName() {
189                 return configName;
190         }
191
192         /**
193          * Sets the Config Name field of the Policy Parameters. 
194          * 
195          * @param configName the <code>String</code> format of the Config Name
196          */
197         public void setConfigName(String configName) {
198                 this.configName = configName;
199         }
200
201         /**
202          * Gets the Attributes of the policy Parameters. 
203          * 
204          * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
205          */
206         public Map<AttributeType, Map<String, String>> getAttributes() {
207                 return attributes;
208         }
209
210         /**
211          * Sets the Attributes of the Policy Parameters. 
212          * 
213          * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
214          */
215         public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
216                 this.attributes = attributes;
217         }
218
219         /**
220          * Gets the Policy Config Type value the Policy parameters. 
221          * 
222          * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type
223          */
224         public PolicyConfigType getPolicyConfigType() {
225                 return policyConfigType;
226         }
227
228         /**
229          * Sets the Policy Config Type field of the policy Parameters. 
230          * 
231          * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
232          */
233         public void setPolicyConfigType(PolicyConfigType policyConfigType) {
234                 if(policyConfigType!=null){
235                 setPolicyClass(PolicyClass.Config);
236             }
237                 this.policyConfigType = policyConfigType;
238         }
239
240         /**
241          * Gets the configBody value of the Policy Parameters. 
242          * 
243          * @return the <code>String</code> format of the Policy Body
244          */
245         public String getConfigBody() {
246                 return configBody;
247         }
248
249         /**
250          * Sets the configBody field of the Policy Parameters. 
251          * 
252          * @param configBody the <code>String</code> format of the Policy Body
253          */
254         public void setConfigBody(String configBody) {
255                 this.configBody = configBody;
256         }
257
258         /**
259          * Gets the config Body Type value of the Policy Parameters.  
260          * 
261          * @return the <code>PolicyType</code> representation of the configBodyType
262          */
263         public PolicyType getConfigBodyType() {
264                 return configBodyType;
265         }
266
267         /**
268          * Sets the configBodyType field of the Policy Parameters. 
269          * 
270          * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
271          */
272         public void setConfigBodyType(PolicyType configBodyType) {
273                 this.configBodyType = configBodyType;
274         }
275         
276         /**
277          * Gets the requestID of the Policy Parameters. 
278          * 
279          * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages.
280          */
281         public UUID getRequestID() {
282                 return requestID;
283         }
284         
285         /**
286          * Sets the requestID of the Policy Parameters. 
287          * 
288          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
289          */
290         public void setRequestID(UUID requestID) {
291                 this.requestID = requestID;
292         }
293
294         /**
295          * Gets the Policy Class of the Policy Parameters. 
296          * 
297          * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters. 
298          */
299         public PolicyClass getPolicyClass() {
300                 return policyClass;
301         }
302
303         /**
304          * Sets the Policy Class of the Policy Parameters. 
305          * 
306          * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters. 
307          */
308         public void setPolicyClass(PolicyClass policyClass) {
309                 this.policyClass = policyClass;
310         }
311         
312         /**
313          * Gets the Action Performer value of the Policy Parameters for Action Policies. 
314          *
315          * @return the <code>String</code> value of the Action Performer for Action Policies
316          */
317         public String getActionPerformer() {
318                 return actionPerformer;
319         }
320         
321         /**
322          * Sets the Action Performer value of the Policy Parameters for Action Policies.
323          * 
324          * @param actionPerformer the <code>String</code> format of the Action Performer
325          */
326         public void setActionPerformer(String actionPerformer) {
327                 this.actionPerformer = actionPerformer;
328         }
329
330         /**
331          * Gets the Action Attribute value of the Policy Parameters for Action Policies. 
332          *
333          * @return the <code>String</code> value of the Action Attribute for Action Policies
334          */
335         public String getActionAttribute() {
336                 return actionAttribute;
337         }
338
339         /**
340          * Sets the Action Attribute value of the Policy Parameters for Action Policies.
341          * 
342          * @param actionAttribute the <code>String</code> format of the Action Attribute
343          */
344         public void setActionAttribute(String actionAttribute) {
345                 this.actionAttribute = actionAttribute;
346         }
347         
348         /**
349          * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
350          * Function, and Field2 to complete the complex and simple Rule Algorithms
351          * 
352          * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
353          */
354         public List<String> getDynamicRuleAlgorithmLabels() {
355                 return dynamicRuleAlgorithmLabels;
356         }
357
358         /**
359          * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
360          * Function, and Field2 to complete the complex and simple Rule Algorithms
361          * 
362          * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
363          */
364         public void setDynamicRuleAlgorithmLabels(
365                         List<String> dynamicRuleAlgorithmLabels) {
366                 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
367         }
368
369         /**
370          * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
371          * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms 
372          * 
373          * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
374          */
375         public List<String> getDynamicRuleAlgorithmFunctions() {
376                 return dynamicRuleAlgorithmFunctions;
377         }
378
379         /**
380          * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
381          * Function, and Field2 to complete the complex and simple Rule Algorithms
382          * 
383          * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
384          */
385         public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
386                 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
387         }
388
389         /**
390          * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
391          * Function, and Field2 to complete the complex and simple Rule Algorithms
392          * 
393          * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
394          */
395         public List<String> getDynamicRuleAlgorithmField1() {
396                 return dynamicRuleAlgorithmField1;
397         }
398
399         /**
400          * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
401          * Function, and Field2 to complete the complex and simple Rule Algorithms
402          * 
403          * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
404          */
405         public void setDynamicRuleAlgorithmField1(
406                         List<String> dynamicRuleAlgorithmField1) {
407                 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
408         }
409
410         /**
411          * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
412          * Operator, and Field2 to complete the complex and simple Rule Algorithms
413          * 
414          * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
415          */
416         public List<String> getDynamicRuleAlgorithmField2() {
417                 return dynamicRuleAlgorithmField2;
418         }
419
420         /**
421          * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
422          * Function, and Field2 to complete the complex and simple Rule Algorithms
423          * 
424          * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
425          */
426         public void setDynamicRuleAlgorithmField2(
427                         List<String> dynamicRuleAlgorithmField2) {
428                 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
429         }
430         
431         /**
432          * Gets the Priority of the Policy Parameters. 
433          * 
434          * @return priority the <code>String</code> format of the Micro Services priority
435          */
436         public String getPriority() {
437                 return priority;
438         }
439         
440         /**
441          * Sets the Priority of the Policy Parameters.
442          * 
443          * @param priority the <code>String</code> format of the Micro Services priority
444          */
445         public void setPriority(String priority) {
446                 this.priority = priority;
447         }
448
449         public RuleProvider getRuleProvider() {
450                 return ruleProvider;
451         }
452
453         public void setRuleProvider(RuleProvider ruleProvider) {
454                 this.ruleProvider = ruleProvider;
455         }       
456         /**
457          * Sets the Guard field of the Policy Parameters. 
458          * 
459          * @param guard the <code>Boolean</code> format of the guard value
460          */
461         public void setGuard(boolean guard){
462                 this.guard = guard;
463         }
464         
465         /**
466          * Gets the  guard value of the Policy Parameters for Action Policies. 
467          *
468          * @return the <code>boolean</code> value of the Guard for Config Policies
469          */
470         public boolean getGuard(){
471                 return guard;
472         }
473         
474         /**
475          * Sets the riskType field of the Policy Parameters. 
476          * 
477          * @param riskType the <code>String</code> format of the riskType value
478          */
479         public void setRiskType(String riskType){
480                 this.riskType = riskType;
481         }
482         
483         /**
484          * Gets the riskType value of the Policy Parameters for Config Policies. 
485          *
486          * @return the <code>String</code> value of the riskType for Config Policies
487          */
488         public String getRiskType(){
489                 return riskType;
490         }
491         
492         /**
493          * Sets the riskLevel field of the Policy Parameters. 
494          * 
495          * @param riskLevel the <code>String</code> format of the riskType value
496          */
497         public void setRiskLevel(String riskLevel){
498                 this.riskLevel = riskLevel;
499         }
500         
501         /**
502          * Gets the riskLevel value of the Policy Parameters for Config Policies. 
503          *
504          * @return the <code>String</code> value of the riskLevel for Config Policies
505          */
506         public String getRiskLevel(){
507                 return riskLevel;
508         }
509         
510         /**
511          * Sets the TTLDate field of the Policy Parameters. 
512          * 
513          * @param ttlDate the <code>Date</code> format of the TTLDate value
514          */
515         public void setTtlDate(Date ttlDate){
516                 this.ttlDate = ttlDate;
517         }
518         
519         /**
520          * Gets the TTLDate value of the Policy Parameters for Config Policies. 
521          *
522          * @return the <code>Date</code> value of the TTLDate for Config Policies
523          */
524         public Date getTtlDate(){
525                 return ttlDate;
526         }
527         
528         /**
529          * Gets the Controller Name for your policy. 
530          *  
531          * @return String format of the controller Name. 
532          */
533         public String getControllerName() {
534         return controllerName;
535     }
536         
537         /**
538          * Sets Controller Name for your policy. 
539          * 
540          * @param controllerName to identify the controller information for your policy. 
541          */
542     public void setControllerName(String controllerName) {
543         this.controllerName = controllerName;
544     }
545     
546     /**
547      * Gets Dependency Names for your policy. 
548      * 
549      * @return ArrayList of String(s) format of dependency names.
550      */
551     public ArrayList<String> getDependencyNames() {
552         return dependencyNames;
553     }
554
555     /**
556      * Sets Dependency that your policy is dependent on. 
557      * 
558      * @param dependencyNames ArrayList of String(s). 
559      */
560     public void setDependencyNames(ArrayList<String> dependencyNames) {
561         this.dependencyNames = dependencyNames;
562     }
563         
564     public String getExtendedOption() {
565                 return extendedOption;
566         }
567
568         public void setExtendedOption(String extendedOption) {
569                 this.extendedOption = extendedOption;
570         }
571         
572         /**
573      * Gets Allowed Treatments Map for Rainy Day Decision Policy
574      * 
575      * @return Map of String format for treatments per errorcode
576      */
577         public Map<String, String> getTreatments() {
578                 return treatments;
579         }
580
581         /**
582          * Sets Allowed Treatments Map for Rainy Day Decision Policy 
583          * 
584          * @param treatments Map that contains the treatment per errorcode 
585          */
586         public void setTreatments(Map<String, String> treatments) {
587                 this.treatments = treatments;
588         }
589         
590         @Override
591         public String toString() {
592                 return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="+ onapName 
593                                 + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody 
594                                 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions 
595                                 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2 
596                                 + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority  
597                                 + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption
598                                 + ", treatments= " + treatments + "]";
599         }
600 }