New listPolicy API to check pushed policies in PDP
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / onap / policy / api / PolicyEngine.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2017-2019 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.api;
22
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.Properties;
26 import java.util.UUID;
27 import javax.json.JsonObject;
28 import org.onap.policy.std.StdPolicyEngine;
29
30 /**
31  * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine
32  *
33  * @version 2.0
34  */
35 public class PolicyEngine {
36     private final StdPolicyEngine stdPolicyEngine;
37     private NotificationScheme scheme = null;
38     private NotificationHandler handler = null;
39
40     /**
41      * PolicyEngine Constructor with <code>Properties</code> structure
42      *
43      * @param properties the <code>Properties</code> structure containing the Policy engine parameters
44      * @throws PolicyEngineException PolicyEngine Exception
45      */
46     public PolicyEngine(final Properties properties) throws PolicyEngineException {
47         this.stdPolicyEngine = new StdPolicyEngine(properties, (String) null);
48     }
49
50     /**
51      * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
52      *
53      * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
54      * @throws PolicyEngineException PolicyEngine Exception
55      */
56     public PolicyEngine(final String propertiesFilePathname) throws PolicyEngineException {
57         this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, (String) null);
58     }
59
60     /**
61      * PolicyEngine Constructor with <code>Properties</code> structure
62      *
63      * @param properties the <code>Properties</code> structure containing the Policy engine parameters
64      * @param clientKey depicts String format of Password/ Client_Key.
65      * @throws PolicyEngineException PolicyEngine Exception
66      */
67     public PolicyEngine(final Properties properties, final String clientKey) throws PolicyEngineException {
68         this.stdPolicyEngine = new StdPolicyEngine(properties, clientKey);
69     }
70
71     /**
72      * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
73      *
74      * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
75      * @param clientKey depicts String format of Password/ Client_Key.
76      * @throws PolicyEngineException PolicyEngine Exception
77      */
78     public PolicyEngine(final String propertiesFilePathname, final String clientKey) throws PolicyEngineException {
79         this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, clientKey);
80     }
81
82     /**
83      * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname and
84      * <code>NotificationScheme</code>
85      *
86      * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
87      * @param scheme the <code>NotificationScheme</code> of
88      *        {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
89      * @throws PolicyEngineException PolicyEngine Exception
90      */
91     public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme)
92             throws PolicyEngineException {
93         this.scheme = scheme;
94         this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme);
95     }
96
97     /**
98      * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname,
99      * <code>NotificationScheme</code> and <code>NotificationHandler</code>
100      *
101      * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
102      * @param scheme the <code>NotificationScheme</code> of
103      *        {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
104      * @param handler the <code>NotificationHandler</code> of
105      *        {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a
106      *        notification is received.
107      * @throws PolicyEngineException PolicyEngine Exception
108      */
109     public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme,
110             final NotificationHandler handler) throws PolicyEngineException {
111         this.scheme = scheme;
112         this.handler = handler;
113         this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme, this.handler);
114     }
115
116     /**
117      * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which
118      * represents the Policy File Name
119      *
120      * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is
121      *        required.
122      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
123      *         configuration.
124      * @throws PolicyConfigException PolicyConfig Exception
125      * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
126      */
127     @Deprecated
128     public Collection<PolicyConfig> getConfigByPolicyName(final String policyName) throws PolicyConfigException {
129         return getConfig(setConfigRequestParameters(policyName, null, null, null, null));
130     }
131
132     /**
133      * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which
134      * represents the Policy File Name
135      *
136      * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is
137      *        required.
138      * @param requestID unique request ID which will be passed throughout the ONAP components to
139      *        correlate logging messages. A different request ID should be passed for each request.
140      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
141      *         configuration.
142      * @throws PolicyConfigException PolicyConfig Exception
143      * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
144      */
145     @Deprecated
146     public Collection<PolicyConfig> getConfigByPolicyName(final String policyName, final UUID requestID)
147             throws PolicyConfigException {
148         return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID));
149     }
150
151     /**
152      * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which
153      * represents the onapName
154      *
155      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
156      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
157      *         configuration.
158      * @throws PolicyConfigException PolicyConfig Exception
159      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
160      */
161     @Deprecated
162     public Collection<PolicyConfig> getConfig(final String onapName) throws PolicyConfigException {
163         return getConfig(setConfigRequestParameters(null, onapName, null, null, null));
164     }
165
166     /**
167      * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which
168      * represents the onapName
169      *
170      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
171      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
172      *         configuration.
173      * @param requestID unique request ID which will be passed throughout the ONAP components to
174      *        correlate logging messages. A different request ID should be passed for each request.
175      * @throws PolicyConfigException PolicyConfig Exception
176      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
177      */
178     @Deprecated
179     public Collection<PolicyConfig> getConfig(final String onapName, final UUID requestID)
180             throws PolicyConfigException {
181         return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID));
182     }
183
184     /**
185      * Requests the configuration of the <code>String</code> which represents the onapName and
186      * <code>String</code> which represents the configName and returns the configuration if different
187      * Configurations exist for the particular onapName.
188      *
189      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
190      * @param configName the <code>String</code> format of the configurationName whose configuration is
191      *        required.
192      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
193      *         configuration.
194      * @throws PolicyConfigException PolicyConfig Exception
195      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
196      */
197     @Deprecated
198     public Collection<PolicyConfig> getConfig(final String onapName, final String configName)
199             throws PolicyConfigException {
200         return getConfig(setConfigRequestParameters(null, onapName, configName, null, null));
201     }
202
203     /**
204      * Requests the configuration of the <code>String</code> which represents the onapName and
205      * <code>String</code> which represents the configName and returns the configuration if different
206      * Configurations exist for the particular onapName.
207      *
208      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
209      * @param configName the <code>String</code> format of the configurationName whose configuration is
210      *        required.
211      * @param requestID unique request ID which will be passed throughout the ONAP components to
212      *        correlate logging messages. A different request ID should be passed for each request.
213      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
214      *         configuration.
215      * @throws PolicyConfigException PolicyConfig Exception
216      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
217      */
218     @Deprecated
219     public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final UUID requestID)
220             throws PolicyConfigException {
221         return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID));
222     }
223
224     /**
225      * Requests the configuration of the <code>String</code> which represents the onapName,
226      * <code>String</code> which represents the configName and <code>Map</code> of
227      * <code>String,String</code> which has the configAttribute and returns the specific configuration
228      * related to the configAttributes mentioned.
229      *
230      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
231      * @param configName the <code>String</code> format of the configurationName whose configuration is
232      *        required.
233      * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the
234      *        configuration attributes which are required.
235      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
236      *         configuration.
237      * @throws PolicyConfigException PolicyConfig Exception
238      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
239      */
240     @Deprecated
241     public Collection<PolicyConfig> getConfig(final String onapName, final String configName,
242             final Map<String, String> configAttributes) throws PolicyConfigException {
243         return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null));
244     }
245
246     /**
247      * Requests the configuration of the <code>String</code> which represents the onapName,
248      * <code>String</code> which represents the configName and <code>Map</code> of
249      * <code>String,String</code> which has the configAttribute and returns the specific configuration
250      * related to the configAttributes mentioned.
251      *
252      * @param onapName the <code>String</code> format of the onapName whose configuration is required.
253      * @param configName the <code>String</code> format of the configurationName whose configuration is
254      *        required.
255      * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the
256      *        configuration attributes which are required.
257      * @param requestID unique request ID which will be passed throughout the ONAP components to
258      *        correlate logging messages. A different request ID should be passed for each request.
259      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
260      *         configuration.
261      * @throws PolicyConfigException PolicyConfig Exception
262      * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
263      */
264     @Deprecated
265     public Collection<PolicyConfig> getConfig(final String onapName, final String configName,
266             final Map<String, String> configAttributes, final UUID requestID) throws PolicyConfigException {
267         return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID));
268     }
269
270     /**
271      * Requests the configuration of the <code>ConfigRequestParameters</code> which represents the
272      * Config policy request parameters and returns the specific configuration related to the matching
273      * parameters.
274      *
275      * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which
276      *        represents the Config policy request parameters.
277      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the
278      *         configuration.
279      * @throws PolicyConfigException PolicyConfig Exception
280      */
281     public Collection<PolicyConfig> getConfig(final ConfigRequestParameters configRequestParameters)
282             throws PolicyConfigException {
283         return stdPolicyEngine.getConfig(configRequestParameters);
284     }
285
286     /**
287      * Requests the list of policies based on the <code>ConfigRequestParameters</code> which represents
288      * the policy request parameters and returns the list of policies filtered by the parameters.
289      *
290      * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which
291      *        represents the List Policy request parameters.
292      * @return <code>Collection</code> of <code>String</code> which returns the list of policies.
293      * @throws PolicyConfigException PolicyConfig Exception
294      */
295     public Collection<String> listConfig(final ConfigRequestParameters listPolicyRequestParameters)
296             throws PolicyConfigException {
297         return stdPolicyEngine.listConfig(listPolicyRequestParameters);
298     }
299
300     /**
301      * Requests the list of policies from PDP based on the <code>ConfigNameRequest</code> which
302      * represents the policy request parameters and returns the list of policies filtered by the
303      * parameters.
304      *
305      * @param ConfigNameRequest {@link org.onap.policy.api.ConfigNameRequest} which represents the List
306      *        Policy request parameters.
307      * @return <code>Collection</code> of <code>String</code> which returns the list of policies.
308      * @throws PolicyConfigException PolicyConfig Exception
309      */
310     public Collection<String> listPolicy(final ConfigNameRequest listPolicyParams) throws PolicyConfigException {
311         return stdPolicyEngine.listPolicy(listPolicyParams);
312     }
313
314     /**
315      * Sends the Events specified to the PEP and returns back the PolicyResponse.
316      *
317      * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the
318      *        eventAttributes that must contain the event ID and values.
319      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the
320      *         Response.
321      * @throws PolicyEventException PolicyEvent Exception
322      * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
323      */
324     @Deprecated
325     public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes) throws PolicyEventException {
326         return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null);
327     }
328
329     /**
330      * Sends the Events specified to the PEP and returns back the PolicyResponse.
331      *
332      * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the
333      *        eventAttributes that must contain the event ID and values.
334      * @param requestID unique request ID which will be passed throughout the ONAP components to
335      *        correlate logging messages. A different request ID should be passed for each request.
336      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the
337      *         Response.
338      * @throws PolicyEventException PolicyEvent Exception
339      * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
340      */
341     @Deprecated
342     public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes, final UUID requestID)
343             throws PolicyEventException {
344         return stdPolicyEngine.sendEvent(eventAttributes, requestID);
345     }
346
347     /**
348      * Sends the Events specified to the PEP and returns back the PolicyResponse.
349      *
350      * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents
351      *        the Event Request Parameters.
352      * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the
353      *         Response.
354      * @throws PolicyEventException PolicyEvent Exception
355      */
356     public Collection<PolicyResponse> sendEvent(final EventRequestParameters eventRequestParameters)
357             throws PolicyEventException {
358         return stdPolicyEngine.sendEvent(eventRequestParameters);
359     }
360
361     /**
362      * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
363      *
364      * @param onapName the <code>String</code> format of the onapName whose Decision is required.
365      * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the
366      *        decisionAttributes that must contain the ID and values.
367      * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
368      * @throws PolicyDecisionException PolicyDecision Exception
369      * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
370      */
371     @Deprecated
372     public DecisionResponse getDecision(final String onapName, final Map<String, String> decisionAttributes)
373             throws PolicyDecisionException {
374         return stdPolicyEngine.getDecision(onapName, decisionAttributes, null);
375     }
376
377     /**
378      * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
379      *
380      * @param onapName the <code>String</code> format of the onapName whose Decision is required.
381      * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the
382      *        decisionAttributes that must contain the ID and values.
383      * @param requestID unique request ID which will be passed throughout the ONAP components to
384      *        correlate logging messages. A different request ID should be passed for each request.
385      * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
386      * @throws PolicyDecisionException PolicyDecision Exception
387      * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
388      */
389     @Deprecated
390     public DecisionResponse getDecision(final String onapName, final Map<String, String> decisionAttributes,
391             final UUID requestID) throws PolicyDecisionException {
392         return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID);
393     }
394
395     /**
396      * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
397      *
398      * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which
399      *        represents the Decision Request Parameters.
400      * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
401      * @throws PolicyDecisionException PolicyDecision Exception
402      */
403     public DecisionResponse getDecision(final DecisionRequestParameters decisionRequestParameters)
404             throws PolicyDecisionException {
405         return stdPolicyEngine.getDecision(decisionRequestParameters);
406     }
407
408     /**
409      * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole
410      *
411      * @param parameters {@link org.onap.policy.api.MetricsRequestParameters} which represents the
412      *        Parameters required to get the Policy Metrics
413      * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to
414      *         getMetrics Request.
415      * @throws PolicyException PolicyException related to the operation
416      *
417      */
418     public MetricsResponse getMetrics(final MetricsRequestParameters parameters) throws PolicyException {
419         return stdPolicyEngine.getMetrics(parameters);
420     }
421
422     /**
423      * Creates a Config Policy based on given arguments
424      *
425      * @param policyName the <code>String</code> format of the Policy Name
426      * @param policyDescription the <code>String</code> format of the Policy Description
427      * @param onapName the <code>String</code> format of the ONAP Name
428      * @param configName the <code>String</code> format of the Config Name
429      * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain
430      *        the key and value.
431      * @param configType the <code>String</code> format of the Config Type
432      * @param body the <code>String</code> format of the Policy Body
433      * @param policyScope the <code>String</code> value of the sub scope directory where the policy will
434      *        be created and stored
435      * @param requestID unique request ID which will be passed throughout the ONAP components to
436      *        correlate logging messages. A different request ID should be passed for each request.
437      * @param riskLevel the <code>String</code> value of risk Level.
438      * @param riskType the <code>String</code> value of risk Type.
439      * @param guard the <code>String</code> value of guard.
440      * @param ttlDate the <code>String</code> value of time to live Date.
441      * @throws PolicyException PolicyException related to the operation.
442      * @return <code>String</code> format of response
443      * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
444      */
445     @Deprecated
446     public String createConfigPolicy(final String policyName, final String policyDescription, final String onapName,
447             final String configName, final Map<String, String> configAttributes, final String configType,
448             final String body, final String policyScope, final UUID requestID, final String riskLevel,
449             final String riskType, final String guard, final String ttlDate) throws PolicyException {
450         return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName,
451                 configAttributes, configType, body, policyScope, requestID, riskLevel, riskType, guard, ttlDate, false);
452     }
453
454     /**
455      * Creates a Config Policy based on given arguments
456      *
457      * @param policyName the <code>String</code> format of the Policy Name
458      * @param policyDescription the <code>String</code> format of the Policy Description
459      * @param onapName the <code>String</code> format of the ONAP Name
460      * @param configName the <code>String</code> format of the Config Name
461      * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain
462      *        the key and value.
463      * @param configType the <code>String</code> format of the Config Type
464      * @param body the <code>String</code> format of the Policy Body
465      * @param policyScope the <code>String</code> value of the sub scope directory where the policy will
466      *        be created and stored
467      * @param requestID unique request ID which will be passed throughout the ONAP components to
468      *        correlate logging messages. A different request ID should be passed for each request.
469      * @param riskLevel the <code>String</code> value of risk Level.
470      * @param riskType the <code>String</code> value of risk Type.
471      * @param guard the <code>String</code> value of guard.
472      * @param ttlDate the <code>String</code> value of time to live Date.
473      * @throws PolicyException PolicyException related to the operation.
474      * @return <code>String</code> format of response
475      * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
476      */
477     @Deprecated
478     public String updateConfigPolicy(final String policyName, final String policyDescription, final String onapName,
479             final String configName, final Map<String, String> configAttributes, final String configType,
480             final String body, final String policyScope, final UUID requestID, final String riskLevel,
481             final String riskType, final String guard, final String ttlDate) throws PolicyException {
482         return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName,
483                 configAttributes, configType, body, policyScope, requestID, riskLevel, riskType, guard, ttlDate, true);
484     }
485
486     /**
487      * Creates a Config Firewall Policy based on given arguments
488      *
489      * @param policyName the <code>String</code> format of the Policy Name
490      * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
491      * @param policyScope the <code>String</code> value of the sub scope directory where the policy will
492      *        be created and stored
493      * @param requestID unique request ID which will be passed throughout the ONAP components to
494      *        correlate logging messages. A different request ID should be passed for each request.
495      * @param riskLevel the <code>String</code> value of risk Level.
496      * @param riskType the <code>String</code> value of risk Type.
497      * @param guard the <code>String</code> value of guard.
498      * @param ttlDate the <code>String</code> value of time to live Date.
499      * @throws PolicyException PolicyException related to the operation.
500      * @return <code>String</code> format of response.
501      * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
502      */
503     @Deprecated
504     public String createConfigFirewallPolicy(final String policyName, final JsonObject firewallJson,
505             final String policyScope, final UUID requestID, final String riskLevel, final String riskType,
506             final String guard, final String ttlDate) throws PolicyException {
507         return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,
508                 riskLevel, riskType, guard, ttlDate, false);
509     }
510
511     /**
512      * Updates a Config Firewall Policy based on given arguments
513      *
514      * @param policyName the <code>String</code> format of the Policy Name
515      * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
516      * @param policyScope the <code>String</code> value of the sub scope directory where the policy will
517      *        be created and stored
518      * @param requestID unique request ID which will be passed throughout the ONAP components to
519      *        correlate logging messages. A different request ID should be passed for each request.
520      * @param riskLevel the <code>String</code> value of risk Level.
521      * @param riskType the <code>String</code> value of risk Type.
522      * @param guard the <code>String</code> value of guard.
523      * @param ttlDate the <code>String</code> value of time to live Date.
524      * @throws PolicyException PolicyException related to the operation.
525      * @return <code>String</code> format of response.
526      * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
527      */
528     @Deprecated
529     public String updateConfigFirewallPolicy(final String policyName, final JsonObject firewallJson,
530             final String policyScope, final UUID requestID, final String riskLevel, final String riskType,
531             final String guard, final String ttlDate) throws PolicyException {
532         return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,
533                 riskLevel, riskType, guard, ttlDate, true);
534     }
535
536     /**
537      * Retrieves Dictionary Items for a specified dictionary
538      *
539      * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the
540      *        Dictionary Parameters required to create a Dictionary Item.
541      * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to
542      *         create dictionary item Request.
543      * @throws PolicyException PolicyException related to the operation
544      *
545      */
546     public DictionaryResponse getDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
547         return stdPolicyEngine.getDictionaryItem(parameters);
548     }
549
550     /**
551      * Creates a Dictionary Item based on given Dictionary Parameters
552      *
553      * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the
554      *        Dictionary Parameters required to create a Dictionary Item.
555      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
556      *         to create dictionary item Request.
557      * @throws PolicyException PolicyException related to the operation.
558      */
559     public PolicyChangeResponse createDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
560         return stdPolicyEngine.createDictionaryItem(parameters);
561     }
562
563     /**
564      * Updates a Dictionary Item based on given Dictionary Parameters
565      *
566      * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the
567      *        Dictionary Parameters required to update a Dictionary Item.
568      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
569      *         to update dictionary item Request.
570      * @throws PolicyException PolicyException related to the operation.
571      */
572     public PolicyChangeResponse updateDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
573         return stdPolicyEngine.updateDictionaryItem(parameters);
574     }
575
576     /**
577      * Creates a Policy based on given Policy Parameters.
578      *
579      * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy
580      *        Parameters required to create a Policy.
581      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
582      *         to create policy Request.
583      * @throws PolicyException PolicyException related to the operation.
584      */
585     public PolicyChangeResponse createPolicy(final PolicyParameters policyParameters) throws PolicyException {
586         return stdPolicyEngine.createPolicy(policyParameters);
587     }
588
589     /**
590      * Update Policy based on given Policy Parameters.
591      *
592      * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy
593      *        Parameters required to update a Policy.
594      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
595      *         to create policy Request.
596      * @throws PolicyException PolicyException related to the operation.
597      */
598     public PolicyChangeResponse updatePolicy(final PolicyParameters policyParameters) throws PolicyException {
599         return stdPolicyEngine.updatePolicy(policyParameters);
600     }
601
602     /**
603      * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
604      *
605      * @param policyScope the <code>String</code> value of the sub scope directory where the policy is
606      *        located
607      * @param policyName the <code>String</code> format of the Policy Name being pushed.
608      * @param policyType the <code>String</code> format of the Policy Type which is being pushed.
609      * @param pdpGroup the <code>String</code> format of the PDP Group name to which the policy needs to
610      *        be pushed to.
611      * @param requestID unique request ID which will be passed throughout the ONAP components to
612      *        correlate logging messages.
613      * @return <code>String</code> format of the response related to the push Policy Request.
614      * @throws PolicyException PolicyException related to the operation.
615      * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead.
616      */
617     @Deprecated
618     public String pushPolicy(final String policyScope, final String policyName, final String policyType,
619             final String pdpGroup, final UUID requestID) throws PolicyException {
620         return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID);
621     }
622
623     /**
624      * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
625      *
626      * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the
627      *        Push Policy parameters required to push a policy.
628      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
629      *         to the push Policy Request.
630      * @throws PolicyException PolicyException related to the operation.
631      */
632     public PolicyChangeResponse pushPolicy(final PushPolicyParameters pushPolicyParameters) throws PolicyException {
633         return stdPolicyEngine.pushPolicy(pushPolicyParameters);
634     }
635
636     /**
637      * Deletes the specified policy from the PAP or PDP.
638      *
639      * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents
640      *        the Delete Policy parameters to delete a policy.
641      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
642      *         to the Delete Policy Request.
643      * @throws PolicyException PolicyException related to the operation.
644      */
645     public PolicyChangeResponse deletePolicy(final DeletePolicyParameters deletePolicyParameters)
646             throws PolicyException {
647         return stdPolicyEngine.deletePolicy(deletePolicyParameters);
648     }
649
650     /**
651      * Creates a new Policy Service based on given Service Parameters.
652      *
653      * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service
654      *        Parameters required to create a Policy Service.
655      * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related
656      *         to create import Service.
657      * @throws PolicyException PolicyException related to the operation.
658      */
659     public PolicyChangeResponse policyEngineImport(final ImportParameters importParameters) throws PolicyException {
660         return stdPolicyEngine.policyEngineImport(importParameters);
661     }
662
663     /**
664      * <code>setNotification</code> allows changes to the Notification Scheme and Notification Handler
665      *
666      * @param scheme the <code>NotificationScheme</code> of
667      *        {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
668      * @param handler the <code>NotificationHandler</code> of
669      *        {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a
670      *        notification is received.
671      */
672     public void setNotification(final NotificationScheme scheme, final NotificationHandler handler) {
673         this.scheme = scheme;
674         this.handler = handler;
675         stdPolicyEngine.notification(this.scheme, this.handler);
676     }
677
678     /**
679      * <code>clearNotification</code> shutsDown the Notification Service if the Auto Scehme Notification
680      * service is running.
681      */
682     public void clearNotification() {
683         stdPolicyEngine.stopNotification();
684     }
685
686     /**
687      * <code>setNotification</code> allows changes to the Notification Scheme
688      *
689      * @param scheme the <code>NotificationScheme</code> of
690      *        {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
691      */
692     public void setScheme(final NotificationScheme scheme) {
693         this.scheme = scheme;
694         stdPolicyEngine.setScheme(this.scheme);
695     }
696
697     /**
698      * Gets the <code>PDPNotification</code> if there is one exists. This is used for Polling Patterns.
699      *
700      * @return <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} which has the
701      *         Notification.
702      */
703     public PDPNotification getNotification() {
704         return stdPolicyEngine.getNotification();
705     }
706
707     /**
708      * setClientKey allows the client to use their own implementation logic for Password Protection and
709      * will be used to set the clear text password, this will be used while making Requests.
710      *
711      * @param clientKey depicts String format of Password/ Client_Key.
712      */
713     public void setClientKey(final String clientKey) {
714         StdPolicyEngine.setClientKey(clientKey);
715     }
716
717     // Internal Setter Method to help build configRequestParameters.
718     private ConfigRequestParameters setConfigRequestParameters(final String policyName, final String onapName,
719             final String configName, final Map<String, String> configAttributes, final UUID requestID) {
720         final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
721         configRequestParameters.setPolicyName(policyName);
722         configRequestParameters.setOnapName(onapName);
723         configRequestParameters.setConfigName(configName);
724         configRequestParameters.setConfigAttributes(configAttributes);
725         configRequestParameters.setRequestID(requestID);
726         return configRequestParameters;
727     }
728 }