2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.api;
23 import java.util.Date;
24 import java.util.List;
26 import java.util.UUID;
29 * <code>PolicyParameters</code> defines the Policy Parameters
30 * which are required to Create/Update a Policy.
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;
57 private boolean guard = false;
58 private String riskLevel = "5";
59 private String riskType = "default";
60 private String extendedOption;
61 private String rawXacmlPolicy;
64 * Sets Config Policy Parameters.
66 * @param policyConfigParams
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());
81 * Sets config Firewall Policy Parameters.
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.
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);
97 * Gets the PolicyName of the Policy Parameters.
99 * @return policyName the <code>String</code> format of the Policy Name
101 public String getPolicyName() {
106 * Sets the policyName of the Policy Parameters.
108 * @param policyName the <code>String</code> format of the Policy Name
110 public void setPolicyName(String policyName) {
111 this.policyName = policyName;
115 * Gets the policy Description.
117 * @return the <code>String</code> format of the Policy Description
119 public String getPolicyDescription() {
120 return policyDescription;
124 * Sets the policy Description of the Policy Description.
126 * @param policyDescription the <code>String</code> format of the Policy Description
128 public void setPolicyDescription(String policyDescription) {
129 this.policyDescription = policyDescription;
133 * Gets the ONAP Name value of the Policy Paramters.
135 * @return <code>String</code> format of the ONAP Name
137 public String getOnapName() {
142 * Gets the ONAP Name value of the Policy Paramters.
144 * @return <code>String</code> format of the ONAP Name
145 * @deprecated Use {@link #getOnapName()} instead.
148 public String getEcompName() {
153 * Sets the ONAP Name field of the Policy Parameters.
155 * @param onapName the <code>String</code> format of the ONAP Name
157 public void setOnapName(String onapName) {
158 this.onapName = onapName;
162 * Sets the ONAP Name field of the Policy Parameters.
164 * @param ecompName the <code>String</code> format of the ONAP Name
165 * @deprecated use {@link #setOnapName(String)} instead.
168 public void setEcompName(String ecompName) {
169 this.onapName = ecompName;
174 * Gets the Config Name value of the Policy Parameters.
176 * @return <code>String</code> format of the Config Name
178 public String getConfigName() {
183 * Sets the Config Name field of the Policy Parameters.
185 * @param configName the <code>String</code> format of the Config Name
187 public void setConfigName(String configName) {
188 this.configName = configName;
192 * Gets the Attributes of the policy Parameters.
194 * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
196 public Map<AttributeType, Map<String, String>> getAttributes() {
201 * Sets the Attributes of the Policy Parameters.
203 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
205 public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
206 this.attributes = attributes;
210 * Gets the Policy Config Type value the Policy parameters.
212 * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type
214 public PolicyConfigType getPolicyConfigType() {
215 return policyConfigType;
219 * Sets the Policy Config Type field of the policy Parameters.
221 * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
223 public void setPolicyConfigType(PolicyConfigType policyConfigType) {
224 if(policyConfigType!=null){
225 setPolicyClass(PolicyClass.Config);
227 this.policyConfigType = policyConfigType;
231 * Gets the configBody value of the Policy Parameters.
233 * @return the <code>String</code> format of the Policy Body
235 public String getConfigBody() {
240 * Sets the configBody field of the Policy Parameters.
242 * @param configBody the <code>String</code> format of the Policy Body
244 public void setConfigBody(String configBody) {
245 this.configBody = configBody;
249 * Gets the config Body Type value of the Policy Parameters.
251 * @return the <code>PolicyType</code> representation of the configBodyType
253 public PolicyType getConfigBodyType() {
254 return configBodyType;
258 * Sets the configBodyType field of the Policy Parameters.
260 * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
262 public void setConfigBodyType(PolicyType configBodyType) {
263 this.configBodyType = configBodyType;
267 * Gets the requestID of the Policy Parameters.
269 * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages.
271 public UUID getRequestID() {
276 * Sets the requestID of the Policy Parameters.
278 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
280 public void setRequestID(UUID requestID) {
281 this.requestID = requestID;
285 * Gets the Policy Class of the Policy Parameters.
287 * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters.
289 public PolicyClass getPolicyClass() {
294 * Sets the Policy Class of the Policy Parameters.
296 * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
298 public void setPolicyClass(PolicyClass policyClass) {
299 this.policyClass = policyClass;
303 * Gets the Action Performer value of the Policy Parameters for Action Policies.
305 * @return the <code>String</code> value of the Action Performer for Action Policies
307 public String getActionPerformer() {
308 return actionPerformer;
312 * Sets the Action Performer value of the Policy Parameters for Action Policies.
314 * @param actionPerformer the <code>String</code> format of the Action Performer
316 public void setActionPerformer(String actionPerformer) {
317 this.actionPerformer = actionPerformer;
321 * Gets the Action Attribute value of the Policy Parameters for Action Policies.
323 * @return the <code>String</code> value of the Action Attribute for Action Policies
325 public String getActionAttribute() {
326 return actionAttribute;
330 * Sets the Action Attribute value of the Policy Parameters for Action Policies.
332 * @param actionAttribute the <code>String</code> format of the Action Attribute
334 public void setActionAttribute(String actionAttribute) {
335 this.actionAttribute = actionAttribute;
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
342 * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
344 public List<String> getDynamicRuleAlgorithmLabels() {
345 return dynamicRuleAlgorithmLabels;
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
352 * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
354 public void setDynamicRuleAlgorithmLabels(
355 List<String> dynamicRuleAlgorithmLabels) {
356 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
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
363 * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
365 public List<String> getDynamicRuleAlgorithmFunctions() {
366 return dynamicRuleAlgorithmFunctions;
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
373 * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
375 public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
376 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
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
383 * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
385 public List<String> getDynamicRuleAlgorithmField1() {
386 return dynamicRuleAlgorithmField1;
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
393 * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
395 public void setDynamicRuleAlgorithmField1(
396 List<String> dynamicRuleAlgorithmField1) {
397 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
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
404 * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
406 public List<String> getDynamicRuleAlgorithmField2() {
407 return dynamicRuleAlgorithmField2;
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
414 * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
416 public void setDynamicRuleAlgorithmField2(
417 List<String> dynamicRuleAlgorithmField2) {
418 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
422 * Gets the Priority of the Policy Parameters.
424 * @return priority the <code>String</code> format of the Micro Services priority
426 public String getPriority() {
431 * Sets the Priority of the Policy Parameters.
433 * @param priority the <code>String</code> format of the Micro Services priority
435 public void setPriority(String priority) {
436 this.priority = priority;
439 public RuleProvider getRuleProvider() {
443 public void setRuleProvider(RuleProvider ruleProvider) {
444 this.ruleProvider = ruleProvider;
447 * Sets the Guard field of the Policy Parameters.
449 * @param guard the <code>Boolean</code> format of the guard value
451 public void setGuard(boolean guard){
456 * Gets the guard value of the Policy Parameters for Action Policies.
458 * @return the <code>boolean</code> value of the Guard for Config Policies
460 public boolean getGuard(){
465 * Sets the riskType field of the Policy Parameters.
467 * @param riskType the <code>String</code> format of the riskType value
469 public void setRiskType(String riskType){
470 this.riskType = riskType;
474 * Gets the riskType value of the Policy Parameters for Config Policies.
476 * @return the <code>String</code> value of the riskType for Config Policies
478 public String getRiskType(){
483 * Sets the riskLevel field of the Policy Parameters.
485 * @param riskLevel the <code>String</code> format of the riskType value
487 public void setRiskLevel(String riskLevel){
488 this.riskLevel = riskLevel;
492 * Gets the riskLevel value of the Policy Parameters for Config Policies.
494 * @return the <code>String</code> value of the riskLevel for Config Policies
496 public String getRiskLevel(){
501 * Sets the TTLDate field of the Policy Parameters.
503 * @param ttlDate the <code>Date</code> format of the TTLDate value
505 public void setTtlDate(Date ttlDate){
506 this.ttlDate = ttlDate;
510 * Gets the TTLDate value of the Policy Parameters for Config Policies.
512 * @return the <code>Date</code> value of the TTLDate for Config Policies
514 public Date getTtlDate(){
519 * Gets the Controller Name for your policy.
521 * @return String format of the controller Name.
523 public String getControllerName() {
524 return controllerName;
528 * Sets Controller Name for your policy.
530 * @param controllerName to identify the controller information for your policy.
532 public void setControllerName(String controllerName) {
533 this.controllerName = controllerName;
537 * Gets Dependency Names for your policy.
539 * @return ArrayList of String(s) format of dependency names.
541 public List<String> getDependencyNames() {
542 return dependencyNames;
546 * Sets Dependency that your policy is dependent on.
548 * @param dependencyNames ArrayList of String(s).
550 public void setDependencyNames(List<String> dependencyNames) {
551 this.dependencyNames = dependencyNames;
554 public String getExtendedOption() {
555 return extendedOption;
558 public void setExtendedOption(String extendedOption) {
559 this.extendedOption = extendedOption;
563 * Gets Allowed Treatments Map for Rainy Day Decision Policy
565 * @return Map of String format for treatments per errorcode
567 public Map<String, String> getTreatments() {
572 * Sets Allowed Treatments Map for Rainy Day Decision Policy
574 * @param treatments Map that contains the treatment per errorcode
576 public void setTreatments(Map<String, String> treatments) {
577 this.treatments = treatments;
580 public String getRawXacmlPolicy() {
581 return rawXacmlPolicy;
584 public void setRawXacmlPolicy(String rawXacmlPolicy) {
585 this.rawXacmlPolicy = rawXacmlPolicy;
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 + "]";