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