Policy TestSuite Enabled
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / openecomp / 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.openecomp.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 ecompName;
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.openecomp.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 ecompName the <code>String</code> format of the ECOMP 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.openecomp.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 ECOMP 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 ecompName, 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.setEcompName(ecompName);
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 ECOMP 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 ECOMP Name value of the Policy Paramters. 
143          * 
144          * @return <code>String</code> format of the ECOMP Name
145          */
146         public String getEcompName() {
147                 return ecompName;
148         }
149
150         /**
151          * Sets the ECOMP Name field of the Policy Parameters. 
152          * 
153          * @param ecompName the <code>String</code> format of the ECOMP Name
154          */
155         public void setEcompName(String ecompName) {
156                 this.ecompName = ecompName;
157         }
158
159         /**
160          * Gets the Config Name value of the Policy Parameters. 
161          * 
162          * @return <code>String</code> format of the Config Name
163          */
164         public String getConfigName() {
165                 return configName;
166         }
167
168         /**
169          * Sets the Config Name field of the Policy Parameters. 
170          * 
171          * @param configName the <code>String</code> format of the Config Name
172          */
173         public void setConfigName(String configName) {
174                 this.configName = configName;
175         }
176
177         /**
178          * Gets the Attributes of the policy Parameters. 
179          * 
180          * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
181          */
182         public Map<AttributeType, Map<String, String>> getAttributes() {
183                 return attributes;
184         }
185
186         /**
187          * Sets the Attributes of the Policy Parameters. 
188          * 
189          * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
190          */
191         public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
192                 this.attributes = attributes;
193         }
194
195         /**
196          * Gets the Policy Config Type value the Policy parameters. 
197          * 
198          * @return {@link org.openecomp.policy.api.PolicyConfigType} Enum of the Config Type
199          */
200         public PolicyConfigType getPolicyConfigType() {
201                 return policyConfigType;
202         }
203
204         /**
205          * Sets the Policy Config Type field of the policy Parameters. 
206          * 
207          * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type
208          */
209         public void setPolicyConfigType(PolicyConfigType policyConfigType) {
210                 if(policyConfigType!=null){
211                 setPolicyClass(PolicyClass.Config);
212             }
213                 this.policyConfigType = policyConfigType;
214         }
215
216         /**
217          * Gets the configBody value of the Policy Parameters. 
218          * 
219          * @return the <code>String</code> format of the Policy Body
220          */
221         public String getConfigBody() {
222                 return configBody;
223         }
224
225         /**
226          * Sets the configBody field of the Policy Parameters. 
227          * 
228          * @param configBody the <code>String</code> format of the Policy Body
229          */
230         public void setConfigBody(String configBody) {
231                 this.configBody = configBody;
232         }
233
234         /**
235          * Gets the config Body Type value of the Policy Parameters.  
236          * 
237          * @return the <code>PolicyType</code> representation of the configBodyType
238          */
239         public PolicyType getConfigBodyType() {
240                 return configBodyType;
241         }
242
243         /**
244          * Sets the configBodyType field of the Policy Parameters. 
245          * 
246          * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
247          */
248         public void setConfigBodyType(PolicyType configBodyType) {
249                 this.configBodyType = configBodyType;
250         }
251         
252         /**
253          * Gets the requestID of the Policy Parameters. 
254          * 
255          * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
256          */
257         public UUID getRequestID() {
258                 return requestID;
259         }
260         
261         /**
262          * Sets the requestID of the Policy Parameters. 
263          * 
264          * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
265          */
266         public void setRequestID(UUID requestID) {
267                 this.requestID = requestID;
268         }
269
270         /**
271          * Gets the Policy Class of the Policy Parameters. 
272          * 
273          * @return {@link org.openecomp.policy.api.PolicyClass} of the Policy Parameters. 
274          */
275         public PolicyClass getPolicyClass() {
276                 return policyClass;
277         }
278
279         /**
280          * Sets the Policy Class of the Policy Parameters. 
281          * 
282          * @param policyClass the Enum {@link org.openecomp.policy.api.PolicyClass} to set Policy Class Type of Policy parameters. 
283          */
284         public void setPolicyClass(PolicyClass policyClass) {
285                 this.policyClass = policyClass;
286         }
287         
288         /**
289          * Gets the Action Performer value of the Policy Parameters for Action Policies. 
290          *
291          * @return the <code>String</code> value of the Action Performer for Action Policies
292          */
293         public String getActionPerformer() {
294                 return actionPerformer;
295         }
296         
297         /**
298          * Sets the Action Performer value of the Policy Parameters for Action Policies.
299          * 
300          * @param actionPerformer the <code>String</code> format of the Action Performer
301          */
302         public void setActionPerformer(String actionPerformer) {
303                 this.actionPerformer = actionPerformer;
304         }
305
306         /**
307          * Gets the Action Attribute value of the Policy Parameters for Action Policies. 
308          *
309          * @return the <code>String</code> value of the Action Attribute for Action Policies
310          */
311         public String getActionAttribute() {
312                 return actionAttribute;
313         }
314
315         /**
316          * Sets the Action Attribute value of the Policy Parameters for Action Policies.
317          * 
318          * @param actionAttribute the <code>String</code> format of the Action Attribute
319          */
320         public void setActionAttribute(String actionAttribute) {
321                 this.actionAttribute = actionAttribute;
322         }
323         
324         /**
325          * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
326          * Function, and Field2 to complete the complex and simple Rule Algorithms
327          * 
328          * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
329          */
330         public List<String> getDynamicRuleAlgorithmLabels() {
331                 return dynamicRuleAlgorithmLabels;
332         }
333
334         /**
335          * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
336          * Function, and Field2 to complete the complex and simple Rule Algorithms
337          * 
338          * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
339          */
340         public void setDynamicRuleAlgorithmLabels(
341                         List<String> dynamicRuleAlgorithmLabels) {
342                 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
343         }
344
345         /**
346          * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
347          * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms 
348          * 
349          * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
350          */
351         public List<String> getDynamicRuleAlgorithmFunctions() {
352                 return dynamicRuleAlgorithmFunctions;
353         }
354
355         /**
356          * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
357          * Function, and Field2 to complete the complex and simple Rule Algorithms
358          * 
359          * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
360          */
361         public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
362                 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
363         }
364
365         /**
366          * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
367          * Function, and Field2 to complete the complex and simple Rule Algorithms
368          * 
369          * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
370          */
371         public List<String> getDynamicRuleAlgorithmField1() {
372                 return dynamicRuleAlgorithmField1;
373         }
374
375         /**
376          * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
377          * Function, and Field2 to complete the complex and simple Rule Algorithms
378          * 
379          * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
380          */
381         public void setDynamicRuleAlgorithmField1(
382                         List<String> dynamicRuleAlgorithmField1) {
383                 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
384         }
385
386         /**
387          * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
388          * Operator, and Field2 to complete the complex and simple Rule Algorithms
389          * 
390          * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
391          */
392         public List<String> getDynamicRuleAlgorithmField2() {
393                 return dynamicRuleAlgorithmField2;
394         }
395
396         /**
397          * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
398          * Function, and Field2 to complete the complex and simple Rule Algorithms
399          * 
400          * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
401          */
402         public void setDynamicRuleAlgorithmField2(
403                         List<String> dynamicRuleAlgorithmField2) {
404                 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
405         }
406         
407         /**
408          * Gets the Priority of the Policy Parameters. 
409          * 
410          * @return priority the <code>String</code> format of the Micro Services priority
411          */
412         public String getPriority() {
413                 return priority;
414         }
415         
416         /**
417          * Sets the Priority of the Policy Parameters.
418          * 
419          * @param priority the <code>String</code> format of the Micro Services priority
420          */
421         public void setPriority(String priority) {
422                 this.priority = priority;
423         }
424
425         public RuleProvider getRuleProvider() {
426                 return ruleProvider;
427         }
428
429         public void setRuleProvider(RuleProvider ruleProvider) {
430                 this.ruleProvider = ruleProvider;
431         }       
432         /**
433          * Sets the Guard field of the Policy Parameters. 
434          * 
435          * @param guard the <code>Boolean</code> format of the guard value
436          */
437         public void setGuard(boolean guard){
438                 this.guard = guard;
439         }
440         
441         /**
442          * Gets the  guard value of the Policy Parameters for Action Policies. 
443          *
444          * @return the <code>boolean</code> value of the Guard for Config Policies
445          */
446         public boolean getGuard(){
447                 return guard;
448         }
449         
450         /**
451          * Sets the riskType field of the Policy Parameters. 
452          * 
453          * @param riskType the <code>String</code> format of the riskType value
454          */
455         public void setRiskType(String riskType){
456                 this.riskType = riskType;
457         }
458         
459         /**
460          * Gets the riskType value of the Policy Parameters for Config Policies. 
461          *
462          * @return the <code>String</code> value of the riskType for Config Policies
463          */
464         public String getRiskType(){
465                 return riskType;
466         }
467         
468         /**
469          * Sets the riskLevel field of the Policy Parameters. 
470          * 
471          * @param riskLevel the <code>String</code> format of the riskType value
472          */
473         public void setRiskLevel(String riskLevel){
474                 this.riskLevel = riskLevel;
475         }
476         
477         /**
478          * Gets the riskLevel value of the Policy Parameters for Config Policies. 
479          *
480          * @return the <code>String</code> value of the riskLevel for Config Policies
481          */
482         public String getRiskLevel(){
483                 return riskLevel;
484         }
485         
486         /**
487          * Sets the TTLDate field of the Policy Parameters. 
488          * 
489          * @param TTLDate the <code>Date</code> format of the TTLDate value
490          */
491         public void setTtlDate(Date TTLDate){
492                 this.TTLDate = TTLDate;
493         }
494         
495         /**
496          * Gets the TTLDate value of the Policy Parameters for Config Policies. 
497          *
498          * @return the <code>Date</code> value of the TTLDate for Config Policies
499          */
500         public Date getTtlDate(){
501                 return TTLDate;
502         }
503         
504         /**
505          * Gets the Controller Name for your policy. 
506          *  
507          * @return String format of the controller Name. 
508          */
509         public String getControllerName() {
510         return controllerName;
511     }
512         
513         /**
514          * Sets Controller Name for your policy. 
515          * 
516          * @param controllerName to identify the controller information for your policy. 
517          */
518     public void setControllerName(String controllerName) {
519         this.controllerName = controllerName;
520     }
521     
522     /**
523      * Gets Dependency Names for your policy. 
524      * 
525      * @return ArrayList of String(s) format of dependency names.
526      */
527     public ArrayList<String> getDependencyNames() {
528         return dependencyNames;
529     }
530
531     /**
532      * Sets Dependency that your policy is dependent on. 
533      * 
534      * @param dependencyNames ArrayList of String(s). 
535      */
536     public void setDependencyNames(ArrayList<String> dependencyNames) {
537         this.dependencyNames = dependencyNames;
538     }
539         
540     public String getExtendedOption() {
541                 return extendedOption;
542         }
543
544         public void setExtendedOption(String extendedOption) {
545                 this.extendedOption = extendedOption;
546         }
547         
548         public String toString() {
549                 return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", ecompName="+ ecompName 
550                                 + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody 
551                                 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions 
552                                 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2 
553                                 + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority  
554                                 + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption
555                                 + "]";
556         }
557 }