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