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