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.openecomp.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 ecompName;
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 = "defualt";
62 * Sets Config Policy Parameters.
64 * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type
65 * @param policyName the <code>String</code> format of the Policy Name
66 * @param policyDescription the <code>String</code> format of the Policy Description
67 * @param ecompName the <code>String</code> format of the ECOMP Name
68 * @param configName the <code>String</code> format of the Config Name
69 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
70 * @param configBodyType the {@link org.openecomp.policy.api.PolicyType} Enum format of the config Body Type.
71 * @param configBody the <code>String</code> format of the Policy Body
72 * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
73 * A different request ID should be passed for each request.
75 public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String ecompName, String configName,
76 Map<AttributeType, Map<String, String>> attributes, PolicyType configBodyType, String configBody, UUID requestID){
77 this.setPolicyConfigType(policyConfigType);
78 this.setPolicyName(policyName);
79 this.setPolicyDescription(policyDescription);
80 this.setEcompName(ecompName);
81 this.setConfigName(configName);
82 this.setAttributes(attributes);
83 this.setConfigBody(configBody);
84 this.setConfigBodyType(configBodyType);
85 this.setRequestID(requestID);
89 * Sets config Firewall Policy Parameters.
91 * @param policyName the <code>String</code> format of the Policy Name
92 * @param firewallJson the <code>String</code> representation of the Firewall Rules List
93 * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
94 * A different request ID should be passed for each request.
96 public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){
97 this.setPolicyConfigType(PolicyConfigType.Firewall);
98 this.setPolicyName(policyName);
99 this.setConfigBody(firewallJson);
100 this.setConfigBodyType(PolicyType.JSON);
101 this.setRequestID(requestID);
105 * Gets the PolicyName of the Policy Parameters.
107 * @return policyName the <code>String</code> format of the Policy Name
109 public String getPolicyName() {
114 * Sets the policyName of the Policy Parameters.
116 * @param policyName the <code>String</code> format of the Policy Name
118 public void setPolicyName(String policyName) {
119 this.policyName = policyName;
123 * Gets the policy Description.
125 * @return the <code>String</code> format of the Policy Description
127 public String getPolicyDescription() {
128 return policyDescription;
132 * Sets the policy Description of the Policy Description.
134 * @param policyDescription the <code>String</code> format of the Policy Description
136 public void setPolicyDescription(String policyDescription) {
137 this.policyDescription = policyDescription;
141 * Gets the ECOMP Name value of the Policy Paramters.
143 * @return <code>String</code> format of the ECOMP Name
145 public String getEcompName() {
150 * Sets the ECOMP Name field of the Policy Parameters.
152 * @param ecompName the <code>String</code> format of the ECOMP Name
154 public void setEcompName(String ecompName) {
155 this.ecompName = ecompName;
159 * Gets the Config Name value of the Policy Parameters.
161 * @return <code>String</code> format of the Config Name
163 public String getConfigName() {
168 * Sets the Config Name field of the Policy Parameters.
170 * @param configName the <code>String</code> format of the Config Name
172 public void setConfigName(String configName) {
173 this.configName = configName;
177 * Gets the Attributes of the policy Parameters.
179 * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
181 public Map<AttributeType, Map<String, String>> getAttributes() {
186 * Sets the Attributes of the Policy Parameters.
188 * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
190 public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
191 this.attributes = attributes;
195 * Gets the Policy Config Type value the Policy parameters.
197 * @return {@link org.openecomp.policy.api.PolicyConfigType} Enum of the Config Type
199 public PolicyConfigType getPolicyConfigType() {
200 return policyConfigType;
204 * Sets the Policy Config Type field of the policy Parameters.
206 * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type
208 public void setPolicyConfigType(PolicyConfigType policyConfigType) {
209 if(policyConfigType!=null){
210 setPolicyClass(PolicyClass.Config);
212 this.policyConfigType = policyConfigType;
216 * Gets the configBody value of the Policy Parameters.
218 * @return the <code>String</code> format of the Policy Body
220 public String getConfigBody() {
225 * Sets the configBody field of the Policy Parameters.
227 * @param configBody the <code>String</code> format of the Policy Body
229 public void setConfigBody(String configBody) {
230 this.configBody = configBody;
234 * Gets the config Body Type value of the Policy Parameters.
236 * @return the <code>PolicyType</code> representation of the configBodyType
238 public PolicyType getConfigBodyType() {
239 return configBodyType;
243 * Sets the configBodyType field of the Policy Parameters.
245 * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
247 public void setConfigBodyType(PolicyType configBodyType) {
248 this.configBodyType = configBodyType;
252 * Gets the requestID of the Policy Parameters.
254 * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
256 public UUID getRequestID() {
261 * Sets the requestID of the Policy Parameters.
263 * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
265 public void setRequestID(UUID requestID) {
266 this.requestID = requestID;
270 * Gets the Policy Class of the Policy Parameters.
272 * @return {@link org.openecomp.policy.api.PolicyClass} of the Policy Parameters.
274 public PolicyClass getPolicyClass() {
279 * Sets the Policy Class of the Policy Parameters.
281 * @param policyClass the Enum {@link org.openecomp.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
283 public void setPolicyClass(PolicyClass policyClass) {
284 this.policyClass = policyClass;
288 * Gets the Action Performer value of the Policy Parameters for Action Policies.
290 * @return the <code>String</code> value of the Action Performer for Action Policies
292 public String getActionPerformer() {
293 return actionPerformer;
297 * Sets the Action Performer value of the Policy Parameters for Action Policies.
299 * @param actionPerformer the <code>String</code> format of the Action Performer
301 public void setActionPerformer(String actionPerformer) {
302 this.actionPerformer = actionPerformer;
306 * Gets the Action Attribute value of the Policy Parameters for Action Policies.
308 * @return the <code>String</code> value of the Action Attribute for Action Policies
310 public String getActionAttribute() {
311 return actionAttribute;
315 * Sets the Action Attribute value of the Policy Parameters for Action Policies.
317 * @param actionAttribute the <code>String</code> format of the Action Attribute
319 public void setActionAttribute(String actionAttribute) {
320 this.actionAttribute = actionAttribute;
324 * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
325 * Function, and Field2 to complete the complex and simple Rule Algorithms
327 * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
329 public List<String> getDynamicRuleAlgorithmLabels() {
330 return dynamicRuleAlgorithmLabels;
334 * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
335 * Function, and Field2 to complete the complex and simple Rule Algorithms
337 * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
339 public void setDynamicRuleAlgorithmLabels(
340 List<String> dynamicRuleAlgorithmLabels) {
341 this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
345 * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
346 * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms
348 * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
350 public List<String> getDynamicRuleAlgorithmFunctions() {
351 return dynamicRuleAlgorithmFunctions;
355 * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
356 * Function, and Field2 to complete the complex and simple Rule Algorithms
358 * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
360 public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
361 this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
365 * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
366 * Function, and Field2 to complete the complex and simple Rule Algorithms
368 * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
370 public List<String> getDynamicRuleAlgorithmField1() {
371 return dynamicRuleAlgorithmField1;
375 * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
376 * Function, and Field2 to complete the complex and simple Rule Algorithms
378 * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
380 public void setDynamicRuleAlgorithmField1(
381 List<String> dynamicRuleAlgorithmField1) {
382 this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
386 * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
387 * Operator, and Field2 to complete the complex and simple Rule Algorithms
389 * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
391 public List<String> getDynamicRuleAlgorithmField2() {
392 return dynamicRuleAlgorithmField2;
396 * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
397 * Function, and Field2 to complete the complex and simple Rule Algorithms
399 * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
401 public void setDynamicRuleAlgorithmField2(
402 List<String> dynamicRuleAlgorithmField2) {
403 this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
407 * Gets the Priority of the Policy Parameters.
409 * @return priority the <code>String</code> format of the Micro Services priority
411 public String getPriority() {
416 * Sets the Priority of the Policy Parameters.
418 * @param priority the <code>String</code> format of the Micro Services priority
420 public void setPriority(String priority) {
421 this.priority = priority;
424 public RuleProvider getRuleProvider() {
428 public void setRuleProvider(RuleProvider ruleProvider) {
429 this.ruleProvider = ruleProvider;
432 * Sets the Guard field of the Policy Parameters.
434 * @param guard the <code>Boolean</code> format of the guard value
436 public void setGuard(boolean guard){
441 * Gets the guard value of the Policy Parameters for Action Policies.
443 * @return the <code>boolean</code> value of the Guard for Config Policies
445 public boolean getGuard(){
450 * Sets the riskType field of the Policy Parameters.
452 * @param riskType the <code>String</code> format of the riskType value
454 public void setRiskType(String riskType){
455 this.riskType = riskType;
459 * Gets the riskType value of the Policy Parameters for Config Policies.
461 * @return the <code>String</code> value of the riskType for Config Policies
463 public String getRiskType(){
468 * Sets the riskLevel field of the Policy Parameters.
470 * @param riskLevel the <code>String</code> format of the riskType value
472 public void setRiskLevel(String riskLevel){
473 this.riskLevel = riskLevel;
477 * Gets the riskLevel value of the Policy Parameters for Config Policies.
479 * @return the <code>String</code> value of the riskLevel for Config Policies
481 public String getRiskLevel(){
486 * Sets the TTLDate field of the Policy Parameters.
488 * @param TTLDate the <code>Date</code> format of the TTLDate value
490 public void setTtlDate(Date TTLDate){
491 this.TTLDate = TTLDate;
495 * Gets the TTLDate value of the Policy Parameters for Config Policies.
497 * @return the <code>Date</code> value of the TTLDate for Config Policies
499 public Date getTtlDate(){
504 * Gets the Controller Name for your policy.
506 * @return String format of the controller Name.
508 public String getControllerName() {
509 return controllerName;
513 * Sets Controller Name for your policy.
515 * @param controllerName to identify the controller information for your policy.
517 public void setControllerName(String controllerName) {
518 this.controllerName = controllerName;
522 * Gets Dependency Names for your policy.
524 * @return ArrayList of String(s) format of dependency names.
526 public ArrayList<String> getDependencyNames() {
527 return dependencyNames;
531 * Sets Dependency that your policy is dependent on.
533 * @param dependencyNames ArrayList of String(s).
535 public void setDependencyNames(ArrayList<String> dependencyNames) {
536 this.dependencyNames = dependencyNames;
539 public String toString() {
540 return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", ecompName="+ ecompName
541 + ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody
542 + ",dynamicRuleAlgorithmLabels=" + dynamicRuleAlgorithmLabels + ",dynamicRuleAlgorithmFunctions=" + dynamicRuleAlgorithmFunctions
543 + ",dynamicRuleAlgorithmField1=" + dynamicRuleAlgorithmField1 + ",dynamicRuleAlgorithmField2=" + dynamicRuleAlgorithmField2
544 + ", actionPerformer=" + actionPerformer + ", actionAttribute=" + actionAttribute + ", priority=" + priority
545 + ", ruleProvider= " + ruleProvider + ", riskLevel= " + riskLevel + ", riskType= " + riskType