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 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;
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 policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
66 * @param policyName the <code>String</code> format of the Policy Name
67 * @param policyDescription the <code>String</code> format of the Policy Description
68 * @param onapName the <code>String</code> format of the ONAP Name
69 * @param configName the <code>String</code> format of the Config Name
70 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
71 * @param configBodyType the {@link org.onap.policy.api.PolicyType} Enum format of the config Body Type.
72 * @param configBody the <code>String</code> format of the Policy Body
73 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
74 * A different request ID should be passed for each request.
76 public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String onapName, String configName,
77 Map<AttributeType, Map<String, String>> attributes, PolicyType configBodyType, String configBody, UUID requestID){
78 this.setPolicyConfigType(policyConfigType);
79 this.setPolicyName(policyName);
80 this.setPolicyDescription(policyDescription);
81 this.setOnapName(onapName);
82 this.setConfigName(configName);
83 this.setAttributes(attributes);
84 this.setConfigBody(configBody);
85 this.setConfigBodyType(configBodyType);
86 this.setRequestID(requestID);
90 * Sets config Firewall Policy Parameters.
92 * @param policyName the <code>String</code> format of the Policy Name
93 * @param firewallJson the <code>String</code> representation of the Firewall Rules List
94 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
95 * A different request ID should be passed for each request.
97 public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){
98 this.setPolicyConfigType(PolicyConfigType.Firewall);
99 this.setPolicyName(policyName);
100 this.setConfigBody(firewallJson);
101 this.setConfigBodyType(PolicyType.JSON);
102 this.setRequestID(requestID);
106 * Gets the PolicyName of the Policy Parameters.
108 * @return policyName the <code>String</code> format of the Policy Name
110 public String getPolicyName() {
115 * Sets the policyName of the Policy Parameters.
117 * @param policyName the <code>String</code> format of the Policy Name
119 public void setPolicyName(String policyName) {
120 this.policyName = policyName;
124 * Gets the policy Description.
126 * @return the <code>String</code> format of the Policy Description
128 public String getPolicyDescription() {
129 return policyDescription;
133 * Sets the policy Description of the Policy Description.
135 * @param policyDescription the <code>String</code> format of the Policy Description
137 public void setPolicyDescription(String policyDescription) {
138 this.policyDescription = policyDescription;
142 * Gets the ONAP Name value of the Policy Paramters.
144 * @return <code>String</code> format of the ONAP Name
146 public String getOnapName() {
151 * Gets the ONAP Name value of the Policy Paramters.
153 * @return <code>String</code> format of the ONAP Name
154 * @deprecated Use {@link #getOnapName()} instead.
157 public String getEcompName() {
162 * Sets the ONAP Name field of the Policy Parameters.
164 * @param onapName the <code>String</code> format of the ONAP Name
166 public void setOnapName(String onapName) {
167 this.onapName = onapName;
171 * Sets the ONAP Name field of the Policy Parameters.
173 * @param ecompName the <code>String</code> format of the ONAP Name
174 * @deprecated use {@link #setOnapName(String)} instead.
177 public void setEcompName(String ecompName) {
178 this.onapName = ecompName;
183 * Gets the Config Name value of the Policy Parameters.
185 * @return <code>String</code> format of the Config Name
187 public String getConfigName() {
192 * Sets the Config Name field of the Policy Parameters.
194 * @param configName the <code>String</code> format of the Config Name
196 public void setConfigName(String configName) {
197 this.configName = configName;
201 * Gets the Attributes of the policy Parameters.
203 * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
205 public Map<AttributeType, Map<String, String>> getAttributes() {
210 * Sets the Attributes of the Policy Parameters.
212 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
214 public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
215 this.attributes = attributes;
219 * Gets the Policy Config Type value the Policy parameters.
221 * @return {@link org.onap.policy.api.PolicyConfigType} Enum of the Config Type
223 public PolicyConfigType getPolicyConfigType() {
224 return policyConfigType;
228 * Sets the Policy Config Type field of the policy Parameters.
230 * @param policyConfigType the {@link org.onap.policy.api.PolicyConfigType} Enum format of the Config Type
232 public void setPolicyConfigType(PolicyConfigType policyConfigType) {
233 if(policyConfigType!=null){
234 setPolicyClass(PolicyClass.Config);
236 this.policyConfigType = policyConfigType;
240 * Gets the configBody value of the Policy Parameters.
242 * @return the <code>String</code> format of the Policy Body
244 public String getConfigBody() {
249 * Sets the configBody field of the Policy Parameters.
251 * @param configBody the <code>String</code> format of the Policy Body
253 public void setConfigBody(String configBody) {
254 this.configBody = configBody;
258 * Gets the config Body Type value of the Policy Parameters.
260 * @return the <code>PolicyType</code> representation of the configBodyType
262 public PolicyType getConfigBodyType() {
263 return configBodyType;
267 * Sets the configBodyType field of the Policy Parameters.
269 * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
271 public void setConfigBodyType(PolicyType configBodyType) {
272 this.configBodyType = configBodyType;
276 * Gets the requestID of the Policy Parameters.
278 * @return unique request ID which will be passed throughout the ONAP components to correlate logging messages.
280 public UUID getRequestID() {
285 * Sets the requestID of the Policy Parameters.
287 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
289 public void setRequestID(UUID requestID) {
290 this.requestID = requestID;
294 * Gets the Policy Class of the Policy Parameters.
296 * @return {@link org.onap.policy.api.PolicyClass} of the Policy Parameters.
298 public PolicyClass getPolicyClass() {
303 * Sets the Policy Class of the Policy Parameters.
305 * @param policyClass the Enum {@link org.onap.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
307 public void setPolicyClass(PolicyClass policyClass) {
308 this.policyClass = policyClass;
312 * Gets the Action Performer value of the Policy Parameters for Action Policies.
314 * @return the <code>String</code> value of the Action Performer for Action Policies
316 public String getActionPerformer() {
317 return actionPerformer;
321 * Sets the Action Performer value of the Policy Parameters for Action Policies.
323 * @param actionPerformer the <code>String</code> format of the Action Performer
325 public void setActionPerformer(String actionPerformer) {
326 this.actionPerformer = actionPerformer;
330 * Gets the Action Attribute value of the Policy Parameters for Action Policies.
332 * @return the <code>String</code> value of the Action Attribute for Action Policies
334 public String getActionAttribute() {
335 return actionAttribute;
339 * Sets the Action Attribute value of the Policy Parameters for Action Policies.
341 * @param actionAttribute the <code>String</code> format of the Action Attribute
343 public void setActionAttribute(String actionAttribute) {
344 this.actionAttribute = actionAttribute;
348 * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
349 * Function, and Field2 to complete the complex and simple Rule Algorithms
351 * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
353 public List<String> getDynamicRuleAlgorithmLabels() {
354 return dynamicRuleAlgorithmLabels;
358 * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
359 * Function, and Field2 to complete the complex and simple Rule Algorithms
361 * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
363 public void setDynamicRuleAlgorithmLabels(
364 List<String> dynamicRuleAlgorithmLabels) {
365 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
369 * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
370 * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms
372 * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
374 public List<String> getDynamicRuleAlgorithmFunctions() {
375 return dynamicRuleAlgorithmFunctions;
379 * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
380 * Function, and Field2 to complete the complex and simple Rule Algorithms
382 * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
384 public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
385 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
389 * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
390 * Function, and Field2 to complete the complex and simple Rule Algorithms
392 * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
394 public List<String> getDynamicRuleAlgorithmField1() {
395 return dynamicRuleAlgorithmField1;
399 * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
400 * Function, and Field2 to complete the complex and simple Rule Algorithms
402 * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
404 public void setDynamicRuleAlgorithmField1(
405 List<String> dynamicRuleAlgorithmField1) {
406 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
410 * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
411 * Operator, and Field2 to complete the complex and simple Rule Algorithms
413 * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
415 public List<String> getDynamicRuleAlgorithmField2() {
416 return dynamicRuleAlgorithmField2;
420 * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
421 * Function, and Field2 to complete the complex and simple Rule Algorithms
423 * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
425 public void setDynamicRuleAlgorithmField2(
426 List<String> dynamicRuleAlgorithmField2) {
427 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
431 * Gets the Priority of the Policy Parameters.
433 * @return priority the <code>String</code> format of the Micro Services priority
435 public String getPriority() {
440 * Sets the Priority of the Policy Parameters.
442 * @param priority the <code>String</code> format of the Micro Services priority
444 public void setPriority(String priority) {
445 this.priority = priority;
448 public RuleProvider getRuleProvider() {
452 public void setRuleProvider(RuleProvider ruleProvider) {
453 this.ruleProvider = ruleProvider;
456 * Sets the Guard field of the Policy Parameters.
458 * @param guard the <code>Boolean</code> format of the guard value
460 public void setGuard(boolean guard){
465 * Gets the guard value of the Policy Parameters for Action Policies.
467 * @return the <code>boolean</code> value of the Guard for Config Policies
469 public boolean getGuard(){
474 * Sets the riskType field of the Policy Parameters.
476 * @param riskType the <code>String</code> format of the riskType value
478 public void setRiskType(String riskType){
479 this.riskType = riskType;
483 * Gets the riskType value of the Policy Parameters for Config Policies.
485 * @return the <code>String</code> value of the riskType for Config Policies
487 public String getRiskType(){
492 * Sets the riskLevel field of the Policy Parameters.
494 * @param riskLevel the <code>String</code> format of the riskType value
496 public void setRiskLevel(String riskLevel){
497 this.riskLevel = riskLevel;
501 * Gets the riskLevel value of the Policy Parameters for Config Policies.
503 * @return the <code>String</code> value of the riskLevel for Config Policies
505 public String getRiskLevel(){
510 * Sets the TTLDate field of the Policy Parameters.
512 * @param ttlDate the <code>Date</code> format of the TTLDate value
514 public void setTtlDate(Date ttlDate){
515 this.ttlDate = ttlDate;
519 * Gets the TTLDate value of the Policy Parameters for Config Policies.
521 * @return the <code>Date</code> value of the TTLDate for Config Policies
523 public Date getTtlDate(){
528 * Gets the Controller Name for your policy.
530 * @return String format of the controller Name.
532 public String getControllerName() {
533 return controllerName;
537 * Sets Controller Name for your policy.
539 * @param controllerName to identify the controller information for your policy.
541 public void setControllerName(String controllerName) {
542 this.controllerName = controllerName;
546 * Gets Dependency Names for your policy.
548 * @return ArrayList of String(s) format of dependency names.
550 public ArrayList<String> getDependencyNames() {
551 return dependencyNames;
555 * Sets Dependency that your policy is dependent on.
557 * @param dependencyNames ArrayList of String(s).
559 public void setDependencyNames(ArrayList<String> dependencyNames) {
560 this.dependencyNames = dependencyNames;
563 public String getExtendedOption() {
564 return extendedOption;
567 public void setExtendedOption(String extendedOption) {
568 this.extendedOption = extendedOption;
571 public String toString() {
572 return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="+ onapName
573 + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody
574 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions
575 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2
576 + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority
577 + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType + ", extendedOption= " + extendedOption