2 * ============LICENSE_START=======================================================
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
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;
63 * Sets Config Policy Parameters.
65 * @param policyConfigParams
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());
80 * Sets config Firewall Policy Parameters.
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.
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);
96 * Gets the PolicyName of the Policy Parameters.
98 * @return policyName the <code>String</code> format of the Policy Name
100 public String getPolicyName() {
105 * Sets the policyName of the Policy Parameters.
107 * @param policyName the <code>String</code> format of the Policy Name
109 public void setPolicyName(String policyName) {
110 this.policyName = policyName;
114 * Gets the policy Description.
116 * @return the <code>String</code> format of the Policy Description
118 public String getPolicyDescription() {
119 return policyDescription;
123 * Sets the policy Description of the Policy Description.
125 * @param policyDescription the <code>String</code> format of the Policy Description
127 public void setPolicyDescription(String policyDescription) {
128 this.policyDescription = policyDescription;
132 * Gets the ONAP Name value of the Policy Paramters.
134 * @return <code>String</code> format of the ONAP Name
136 public String getOnapName() {
141 * Gets the ONAP Name value of the Policy Paramters.
143 * @return <code>String</code> format of the ONAP Name
144 * @deprecated Use {@link #getOnapName()} instead.
147 public String getEcompName() {
152 * Sets the ONAP Name field of the Policy Parameters.
154 * @param onapName the <code>String</code> format of the ONAP Name
156 public void setOnapName(String onapName) {
157 this.onapName = onapName;
161 * Sets the ONAP Name field of the Policy Parameters.
163 * @param ecompName the <code>String</code> format of the ONAP Name
164 * @deprecated use {@link #setOnapName(String)} instead.
167 public void setEcompName(String ecompName) {
168 this.onapName = ecompName;
173 * Gets the Config Name value of the Policy Parameters.
175 * @return <code>String</code> format of the Config Name
177 public String getConfigName() {
182 * Sets the Config Name field of the Policy Parameters.
184 * @param configName the <code>String</code> format of the Config Name
186 public void setConfigName(String configName) {
187 this.configName = configName;
191 * Gets the Attributes of the policy Parameters.
193 * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
195 public Map<AttributeType, Map<String, String>> getAttributes() {
200 * Sets the Attributes of the Policy Parameters.
202 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
204 public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
205 this.attributes = attributes;
209 * Gets the Policy Config Type value the Policy parameters.
211 * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type
213 public PolicyConfigType getPolicyConfigType() {
214 return policyConfigType;
218 * Sets the Policy Config Type field of the policy Parameters.
220 * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
222 public void setPolicyConfigType(PolicyConfigType policyConfigType) {
223 if(policyConfigType!=null){
224 setPolicyClass(PolicyClass.Config);
226 this.policyConfigType = policyConfigType;
230 * Gets the configBody value of the Policy Parameters.
232 * @return the <code>String</code> format of the Policy Body
234 public String getConfigBody() {
239 * Sets the configBody field of the Policy Parameters.
241 * @param configBody the <code>String</code> format of the Policy Body
243 public void setConfigBody(String configBody) {
244 this.configBody = configBody;
248 * Gets the config Body Type value of the Policy Parameters.
250 * @return the <code>PolicyType</code> representation of the configBodyType
252 public PolicyType getConfigBodyType() {
253 return configBodyType;
257 * Sets the configBodyType field of the Policy Parameters.
259 * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
261 public void setConfigBodyType(PolicyType configBodyType) {
262 this.configBodyType = configBodyType;
266 * Gets the requestID of the Policy Parameters.
268 * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages.
270 public UUID getRequestID() {
275 * Sets the requestID of the Policy Parameters.
277 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
279 public void setRequestID(UUID requestID) {
280 this.requestID = requestID;
284 * Gets the Policy Class of the Policy Parameters.
286 * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters.
288 public PolicyClass getPolicyClass() {
293 * Sets the Policy Class of the Policy Parameters.
295 * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
297 public void setPolicyClass(PolicyClass policyClass) {
298 this.policyClass = policyClass;
302 * Gets the Action Performer value of the Policy Parameters for Action Policies.
304 * @return the <code>String</code> value of the Action Performer for Action Policies
306 public String getActionPerformer() {
307 return actionPerformer;
311 * Sets the Action Performer value of the Policy Parameters for Action Policies.
313 * @param actionPerformer the <code>String</code> format of the Action Performer
315 public void setActionPerformer(String actionPerformer) {
316 this.actionPerformer = actionPerformer;
320 * Gets the Action Attribute value of the Policy Parameters for Action Policies.
322 * @return the <code>String</code> value of the Action Attribute for Action Policies
324 public String getActionAttribute() {
325 return actionAttribute;
329 * Sets the Action Attribute value of the Policy Parameters for Action Policies.
331 * @param actionAttribute the <code>String</code> format of the Action Attribute
333 public void setActionAttribute(String actionAttribute) {
334 this.actionAttribute = actionAttribute;
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
341 * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
343 public List<String> getDynamicRuleAlgorithmLabels() {
344 return dynamicRuleAlgorithmLabels;
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
351 * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
353 public void setDynamicRuleAlgorithmLabels(
354 List<String> dynamicRuleAlgorithmLabels) {
355 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
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
362 * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
364 public List<String> getDynamicRuleAlgorithmFunctions() {
365 return dynamicRuleAlgorithmFunctions;
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
372 * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
374 public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
375 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
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
382 * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
384 public List<String> getDynamicRuleAlgorithmField1() {
385 return dynamicRuleAlgorithmField1;
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
392 * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
394 public void setDynamicRuleAlgorithmField1(
395 List<String> dynamicRuleAlgorithmField1) {
396 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
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
403 * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
405 public List<String> getDynamicRuleAlgorithmField2() {
406 return dynamicRuleAlgorithmField2;
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
413 * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
415 public void setDynamicRuleAlgorithmField2(
416 List<String> dynamicRuleAlgorithmField2) {
417 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
421 * Gets the Priority of the Policy Parameters.
423 * @return priority the <code>String</code> format of the Micro Services priority
425 public String getPriority() {
430 * Sets the Priority of the Policy Parameters.
432 * @param priority the <code>String</code> format of the Micro Services priority
434 public void setPriority(String priority) {
435 this.priority = priority;
438 public RuleProvider getRuleProvider() {
442 public void setRuleProvider(RuleProvider ruleProvider) {
443 this.ruleProvider = ruleProvider;
446 * Sets the Guard field of the Policy Parameters.
448 * @param guard the <code>Boolean</code> format of the guard value
450 public void setGuard(boolean guard){
455 * Gets the guard value of the Policy Parameters for Action Policies.
457 * @return the <code>boolean</code> value of the Guard for Config Policies
459 public boolean getGuard(){
464 * Sets the riskType field of the Policy Parameters.
466 * @param riskType the <code>String</code> format of the riskType value
468 public void setRiskType(String riskType){
469 this.riskType = riskType;
473 * Gets the riskType value of the Policy Parameters for Config Policies.
475 * @return the <code>String</code> value of the riskType for Config Policies
477 public String getRiskType(){
482 * Sets the riskLevel field of the Policy Parameters.
484 * @param riskLevel the <code>String</code> format of the riskType value
486 public void setRiskLevel(String riskLevel){
487 this.riskLevel = riskLevel;
491 * Gets the riskLevel value of the Policy Parameters for Config Policies.
493 * @return the <code>String</code> value of the riskLevel for Config Policies
495 public String getRiskLevel(){
500 * Sets the TTLDate field of the Policy Parameters.
502 * @param ttlDate the <code>Date</code> format of the TTLDate value
504 public void setTtlDate(Date ttlDate){
505 this.ttlDate = ttlDate;
509 * Gets the TTLDate value of the Policy Parameters for Config Policies.
511 * @return the <code>Date</code> value of the TTLDate for Config Policies
513 public Date getTtlDate(){
518 * Gets the Controller Name for your policy.
520 * @return String format of the controller Name.
522 public String getControllerName() {
523 return controllerName;
527 * Sets Controller Name for your policy.
529 * @param controllerName to identify the controller information for your policy.
531 public void setControllerName(String controllerName) {
532 this.controllerName = controllerName;
536 * Gets Dependency Names for your policy.
538 * @return ArrayList of String(s) format of dependency names.
540 public List<String> getDependencyNames() {
541 return dependencyNames;
545 * Sets Dependency that your policy is dependent on.
547 * @param dependencyNames ArrayList of String(s).
549 public void setDependencyNames(List<String> dependencyNames) {
550 this.dependencyNames = dependencyNames;
553 public String getExtendedOption() {
554 return extendedOption;
557 public void setExtendedOption(String extendedOption) {
558 this.extendedOption = extendedOption;
562 * Gets Allowed Treatments Map for Rainy Day Decision Policy
564 * @return Map of String format for treatments per errorcode
566 public Map<String, String> getTreatments() {
571 * Sets Allowed Treatments Map for Rainy Day Decision Policy
573 * @param treatments Map that contains the treatment per errorcode
575 public void setTreatments(Map<String, String> treatments) {
576 this.treatments = treatments;
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 + "]";