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