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.ArrayList;
24 import java.util.Date;
25 import java.util.List;
27 import java.util.UUID;
30 * <code>PolicyParameters</code> defines the Policy Parameters
31 * which are required to Create/Update a Policy.
35 public class PolicyParameters {
36 private PolicyClass policyClass;
37 private PolicyConfigType policyConfigType;
38 private String policyName;
39 private String policyDescription;
40 private String onapName;
41 private String configName;
42 private Map<AttributeType, Map<String,String>> attributes;
43 private Map<String, String> treatments;
44 private String configBody;
45 private PolicyType configBodyType;
46 private String actionPerformer;
47 private String actionAttribute;
48 private UUID requestID;
49 private List<String> dynamicRuleAlgorithmLabels;
50 private List<String> dynamicRuleAlgorithmFunctions;
51 private List<String> dynamicRuleAlgorithmField1;
52 private List<String> dynamicRuleAlgorithmField2;
53 private String priority;
54 private RuleProvider ruleProvider;
55 private String controllerName;
56 private List<String> dependencyNames;
58 private boolean guard = false;
59 private String riskLevel = "5";
60 private String riskType = "default";
61 private String extendedOption;
64 * Sets Config Policy Parameters.
66 * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
67 * @param policyName the <code>String</code> format of the Policy Name
68 * @param policyDescription the <code>String</code> format of the Policy Description
69 * @param onapName the <code>String</code> format of the ONAP Name
70 * @param configName the <code>String</code> format of the Config Name
71 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
72 * @param configBodyType the {@link org.onap.policy.api.PolicyType} Enum format of the config Body Type.
73 * @param configBody the <code>String</code> format of the Policy Body
74 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
75 * A different request ID should be passed for each request.
77 public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String onapName, String configName,
78 Map<AttributeType, Map<String, String>> attributes, PolicyType configBodyType, String configBody, UUID requestID){
79 this.setPolicyConfigType(policyConfigType);
80 this.setPolicyName(policyName);
81 this.setPolicyDescription(policyDescription);
82 this.setOnapName(onapName);
83 this.setConfigName(configName);
84 this.setAttributes(attributes);
85 this.setConfigBody(configBody);
86 this.setConfigBodyType(configBodyType);
87 this.setRequestID(requestID);
91 * Sets config Firewall Policy Parameters.
93 * @param policyName the <code>String</code> format of the Policy Name
94 * @param firewallJson the <code>String</code> representation of the Firewall Rules List
95 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
96 * A different request ID should be passed for each request.
98 public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){
99 this.setPolicyConfigType(PolicyConfigType.Firewall);
100 this.setPolicyName(policyName);
101 this.setConfigBody(firewallJson);
102 this.setConfigBodyType(PolicyType.JSON);
103 this.setRequestID(requestID);
107 * Gets the PolicyName of the Policy Parameters.
109 * @return policyName the <code>String</code> format of the Policy Name
111 public String getPolicyName() {
116 * Sets the policyName of the Policy Parameters.
118 * @param policyName the <code>String</code> format of the Policy Name
120 public void setPolicyName(String policyName) {
121 this.policyName = policyName;
125 * Gets the policy Description.
127 * @return the <code>String</code> format of the Policy Description
129 public String getPolicyDescription() {
130 return policyDescription;
134 * Sets the policy Description of the Policy Description.
136 * @param policyDescription the <code>String</code> format of the Policy Description
138 public void setPolicyDescription(String policyDescription) {
139 this.policyDescription = policyDescription;
143 * Gets the ONAP Name value of the Policy Paramters.
145 * @return <code>String</code> format of the ONAP Name
147 public String getOnapName() {
152 * Gets the ONAP Name value of the Policy Paramters.
154 * @return <code>String</code> format of the ONAP Name
155 * @deprecated Use {@link #getOnapName()} instead.
158 public String getEcompName() {
163 * Sets the ONAP Name field of the Policy Parameters.
165 * @param onapName the <code>String</code> format of the ONAP Name
167 public void setOnapName(String onapName) {
168 this.onapName = onapName;
172 * Sets the ONAP Name field of the Policy Parameters.
174 * @param ecompName the <code>String</code> format of the ONAP Name
175 * @deprecated use {@link #setOnapName(String)} instead.
178 public void setEcompName(String ecompName) {
179 this.onapName = ecompName;
184 * Gets the Config Name value of the Policy Parameters.
186 * @return <code>String</code> format of the Config Name
188 public String getConfigName() {
193 * Sets the Config Name field of the Policy Parameters.
195 * @param configName the <code>String</code> format of the Config Name
197 public void setConfigName(String configName) {
198 this.configName = configName;
202 * Gets the Attributes of the policy Parameters.
204 * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
206 public Map<AttributeType, Map<String, String>> getAttributes() {
211 * Sets the Attributes of the Policy Parameters.
213 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
215 public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
216 this.attributes = attributes;
220 * Gets the Policy Config Type value the Policy parameters.
222 * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type
224 public PolicyConfigType getPolicyConfigType() {
225 return policyConfigType;
229 * Sets the Policy Config Type field of the policy Parameters.
231 * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
233 public void setPolicyConfigType(PolicyConfigType policyConfigType) {
234 if(policyConfigType!=null){
235 setPolicyClass(PolicyClass.Config);
237 this.policyConfigType = policyConfigType;
241 * Gets the configBody value of the Policy Parameters.
243 * @return the <code>String</code> format of the Policy Body
245 public String getConfigBody() {
250 * Sets the configBody field of the Policy Parameters.
252 * @param configBody the <code>String</code> format of the Policy Body
254 public void setConfigBody(String configBody) {
255 this.configBody = configBody;
259 * Gets the config Body Type value of the Policy Parameters.
261 * @return the <code>PolicyType</code> representation of the configBodyType
263 public PolicyType getConfigBodyType() {
264 return configBodyType;
268 * Sets the configBodyType field of the Policy Parameters.
270 * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
272 public void setConfigBodyType(PolicyType configBodyType) {
273 this.configBodyType = configBodyType;
277 * Gets the requestID of the Policy Parameters.
279 * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages.
281 public UUID getRequestID() {
286 * Sets the requestID of the Policy Parameters.
288 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
290 public void setRequestID(UUID requestID) {
291 this.requestID = requestID;
295 * Gets the Policy Class of the Policy Parameters.
297 * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters.
299 public PolicyClass getPolicyClass() {
304 * Sets the Policy Class of the Policy Parameters.
306 * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
308 public void setPolicyClass(PolicyClass policyClass) {
309 this.policyClass = policyClass;
313 * Gets the Action Performer value of the Policy Parameters for Action Policies.
315 * @return the <code>String</code> value of the Action Performer for Action Policies
317 public String getActionPerformer() {
318 return actionPerformer;
322 * Sets the Action Performer value of the Policy Parameters for Action Policies.
324 * @param actionPerformer the <code>String</code> format of the Action Performer
326 public void setActionPerformer(String actionPerformer) {
327 this.actionPerformer = actionPerformer;
331 * Gets the Action Attribute value of the Policy Parameters for Action Policies.
333 * @return the <code>String</code> value of the Action Attribute for Action Policies
335 public String getActionAttribute() {
336 return actionAttribute;
340 * Sets the Action Attribute value of the Policy Parameters for Action Policies.
342 * @param actionAttribute the <code>String</code> format of the Action Attribute
344 public void setActionAttribute(String actionAttribute) {
345 this.actionAttribute = actionAttribute;
349 * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
350 * Function, and Field2 to complete the complex and simple Rule Algorithms
352 * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
354 public List<String> getDynamicRuleAlgorithmLabels() {
355 return dynamicRuleAlgorithmLabels;
359 * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
360 * Function, and Field2 to complete the complex and simple Rule Algorithms
362 * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
364 public void setDynamicRuleAlgorithmLabels(
365 List<String> dynamicRuleAlgorithmLabels) {
366 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
370 * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
371 * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms
373 * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
375 public List<String> getDynamicRuleAlgorithmFunctions() {
376 return dynamicRuleAlgorithmFunctions;
380 * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
381 * Function, and Field2 to complete the complex and simple Rule Algorithms
383 * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
385 public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
386 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
390 * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
391 * Function, and Field2 to complete the complex and simple Rule Algorithms
393 * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
395 public List<String> getDynamicRuleAlgorithmField1() {
396 return dynamicRuleAlgorithmField1;
400 * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
401 * Function, and Field2 to complete the complex and simple Rule Algorithms
403 * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
405 public void setDynamicRuleAlgorithmField1(
406 List<String> dynamicRuleAlgorithmField1) {
407 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
411 * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
412 * Operator, and Field2 to complete the complex and simple Rule Algorithms
414 * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
416 public List<String> getDynamicRuleAlgorithmField2() {
417 return dynamicRuleAlgorithmField2;
421 * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
422 * Function, and Field2 to complete the complex and simple Rule Algorithms
424 * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
426 public void setDynamicRuleAlgorithmField2(
427 List<String> dynamicRuleAlgorithmField2) {
428 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
432 * Gets the Priority of the Policy Parameters.
434 * @return priority the <code>String</code> format of the Micro Services priority
436 public String getPriority() {
441 * Sets the Priority of the Policy Parameters.
443 * @param priority the <code>String</code> format of the Micro Services priority
445 public void setPriority(String priority) {
446 this.priority = priority;
449 public RuleProvider getRuleProvider() {
453 public void setRuleProvider(RuleProvider ruleProvider) {
454 this.ruleProvider = ruleProvider;
457 * Sets the Guard field of the Policy Parameters.
459 * @param guard the <code>Boolean</code> format of the guard value
461 public void setGuard(boolean guard){
466 * Gets the guard value of the Policy Parameters for Action Policies.
468 * @return the <code>boolean</code> value of the Guard for Config Policies
470 public boolean getGuard(){
475 * Sets the riskType field of the Policy Parameters.
477 * @param riskType the <code>String</code> format of the riskType value
479 public void setRiskType(String riskType){
480 this.riskType = riskType;
484 * Gets the riskType value of the Policy Parameters for Config Policies.
486 * @return the <code>String</code> value of the riskType for Config Policies
488 public String getRiskType(){
493 * Sets the riskLevel field of the Policy Parameters.
495 * @param riskLevel the <code>String</code> format of the riskType value
497 public void setRiskLevel(String riskLevel){
498 this.riskLevel = riskLevel;
502 * Gets the riskLevel value of the Policy Parameters for Config Policies.
504 * @return the <code>String</code> value of the riskLevel for Config Policies
506 public String getRiskLevel(){
511 * Sets the TTLDate field of the Policy Parameters.
513 * @param ttlDate the <code>Date</code> format of the TTLDate value
515 public void setTtlDate(Date ttlDate){
516 this.ttlDate = ttlDate;
520 * Gets the TTLDate value of the Policy Parameters for Config Policies.
522 * @return the <code>Date</code> value of the TTLDate for Config Policies
524 public Date getTtlDate(){
529 * Gets the Controller Name for your policy.
531 * @return String format of the controller Name.
533 public String getControllerName() {
534 return controllerName;
538 * Sets Controller Name for your policy.
540 * @param controllerName to identify the controller information for your policy.
542 public void setControllerName(String controllerName) {
543 this.controllerName = controllerName;
547 * Gets Dependency Names for your policy.
549 * @return ArrayList of String(s) format of dependency names.
551 public List<String> getDependencyNames() {
552 return dependencyNames;
556 * Sets Dependency that your policy is dependent on.
558 * @param dependencyNames ArrayList of String(s).
560 public void setDependencyNames(List<String> dependencyNames) {
561 this.dependencyNames = dependencyNames;
564 public String getExtendedOption() {
565 return extendedOption;
568 public void setExtendedOption(String extendedOption) {
569 this.extendedOption = extendedOption;
573 * Gets Allowed Treatments Map for Rainy Day Decision Policy
575 * @return Map of String format for treatments per errorcode
577 public Map<String, String> getTreatments() {
582 * Sets Allowed Treatments Map for Rainy Day Decision Policy
584 * @param treatments Map that contains the treatment per errorcode
586 public void setTreatments(Map<String, String> treatments) {
587 this.treatments = treatments;
591 public String toString() {
592 return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="+ onapName
593 + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody
594 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions
595 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2
596 + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority
597 + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption
598 + ", treatments= " + treatments + "]";