Merge "Add filter obejcts for concepts"
[policy/models.git] / models-provider / src / main / java / org / onap / policy / models / provider / PolicyModelsProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.models.provider;
22
23 import java.util.List;
24 import java.util.Map;
25
26 import lombok.NonNull;
27
28 import org.onap.policy.models.base.PfModelException;
29 import org.onap.policy.models.pdp.concepts.Pdp;
30 import org.onap.policy.models.pdp.concepts.PdpGroup;
31 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
32 import org.onap.policy.models.pdp.concepts.PdpStatistics;
33 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
35 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
36 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
38 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
39 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
40 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
41 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
42
43 /**
44  * This interface describes the operations that are provided to users and components for reading objects from and
45  * writing objects to the database.
46  *
47  * @author Liam Fallon (liam.fallon@est.tech)
48  */
49 public interface PolicyModelsProvider extends AutoCloseable {
50     /**
51      * Open the policy model provider initializing whatever internal handling it needs.
52      *
53      * @throws PfModelException on errors opening the models provider
54      */
55     public void init() throws PfModelException;
56
57     @Override
58     public void close() throws PfModelException;
59
60     /**
61      * Get policy types.
62      *
63      * @param name the name of the policy type to get, set to null to get all policy types
64      * @param version the version of the policy type to get, set to null to get all versions
65      * @return the policy types found
66      * @throws PfModelException on errors getting policy types
67      */
68     public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
69
70     /**
71      * Get policy types.
72      *
73      * @param name the name of the policy type to get, set to null to get all policy types
74      * @param version the version of the policy type to get, set to null to get all versions
75      * @return the policy types found
76      * @throws PfModelException on errors getting policy types
77      */
78     public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
79
80     /**
81      * Get filtered policy types.
82      *
83      * @param filter the filter for the policy types to get
84      * @return the policy types found
85      * @throws PfModelException on errors getting policy types
86      */
87     public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
88             throws PfModelException;
89
90     /**
91      * Get filtered policy types.
92      *
93      * @param filter the filter for the policy types to get
94      * @return the policy types found
95      * @throws PfModelException on errors getting policy types
96      */
97     public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
98             throws PfModelException;
99
100     /**
101      * Create policy types.
102      *
103      * @param serviceTemplate the service template containing the definition of the policy types to be created
104      * @return the TOSCA service template containing the created policy types
105      * @throws PfModelException on errors creating policy types
106      */
107     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
108             throws PfModelException;
109
110     /**
111      * Create policy types.
112      *
113      * @param serviceTemplate the service template containing the definition of the policy types to be modified
114      * @return the TOSCA service template containing the modified policy types
115      * @throws PfModelException on errors updating policy types
116      */
117     public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
118             throws PfModelException;
119
120     /**
121      * Delete policy type.
122      *
123      * @param name the name of the policy type to delete.
124      * @param version the version of the policy type to delete.
125      * @return the TOSCA service template containing the policy type that was deleted
126      * @throws PfModelException on errors deleting policy types
127      */
128     public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
129             throws PfModelException;
130
131     /**
132      * Get policies.
133      *
134      * @param name the name of the policy to get, null to get all policies
135      * @param version the version of the policy to get, null to get all versions of a policy
136      * @return the policies found
137      * @throws PfModelException on errors getting policies
138      */
139     public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
140
141     /**
142      * Get policies.
143      *
144      * @param name the name of the policy to get, null to get all policies
145      * @param version the version of the policy to get, null to get all versions of a policy
146      * @return the policies found
147      * @throws PfModelException on errors getting policies
148      */
149     public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
150
151     /**
152      * Get filtered policies.
153      *
154      * @param filter the filter for the policies to get
155      * @return the policies found
156      * @throws PfModelException on errors getting policies
157      */
158     public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
159
160     /**
161      * Get filtered policies.
162      *
163      * @param filter the filter for the policies to get
164      * @return the policies found
165      * @throws PfModelException on errors getting policies
166      */
167     public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
168
169     /**
170      * Create policies.
171      *
172      * @param serviceTemplate the service template containing the definitions of the new policies to be created.
173      * @return the TOSCA service template containing the policy types that were created
174      * @throws PfModelException on errors creating policies
175      */
176     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
177             throws PfModelException;
178
179     /**
180      * Update policies.
181      *
182      * @param serviceTemplate the service template containing the definitions of the policies to be updated.
183      * @return the TOSCA service template containing the policies that were updated
184      * @throws PfModelException on errors updating policies
185      */
186     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
187             throws PfModelException;
188
189     /**
190      * Delete policy.
191      *
192      * @param name the name of the policy to delete.
193      * @param version the version of the policy to delete.
194      * @return the TOSCA service template containing the policy that was deleted
195      * @throws PfModelException on errors deleting a policy
196      */
197     public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
198             throws PfModelException;
199
200     /**
201      * Get legacy operational policy.
202      *
203      * @param policyId ID of the policy.
204      * @return the policies found
205      * @throws PfModelException on errors getting policies
206      */
207     public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
208
209     /**
210      * Create legacy operational policy.
211      *
212      * @param legacyOperationalPolicy the definition of the policy to be created.
213      * @return the created policy
214      * @throws PfModelException on errors creating policies
215      */
216     public LegacyOperationalPolicy createOperationalPolicy(
217             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
218
219     /**
220      * Update legacy operational policy.
221      *
222      * @param legacyOperationalPolicy the definition of the policy to be updated
223      * @return the updated policy
224      * @throws PfModelException on errors updating policies
225      */
226     public LegacyOperationalPolicy updateOperationalPolicy(
227             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
228
229     /**
230      * Delete legacy operational policy.
231      *
232      * @param policyId ID of the policy.
233      * @return the deleted policy
234      * @throws PfModelException on errors deleting policies
235      */
236     public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
237
238     /**
239      * Get legacy guard policy.
240      *
241      * @param policyId ID of the policy.
242      * @return the policies found
243      * @throws PfModelException on errors getting policies
244      */
245     public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
246
247     /**
248      * Create legacy guard policy.
249      *
250      * @param legacyGuardPolicy the definition of the policy to be created.
251      * @return the created policy
252      * @throws PfModelException on errors creating policies
253      */
254     public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
255             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
256
257     /**
258      * Update legacy guard policy.
259      *
260      * @param legacyGuardPolicy the definition of the policy to be updated
261      * @return the updated policy
262      * @throws PfModelException on errors updating policies
263      */
264     public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
265             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
266
267     /**
268      * Delete legacy guard policy.
269      *
270      * @param policyId ID of the policy.
271      * @return the deleted policy
272      * @throws PfModelException on errors deleting policies
273      */
274     public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
275             throws PfModelException;
276
277     /**
278      * Get PDP groups.
279      *
280      * @param name the name of the policy to get, null to get all PDP groups
281      * @param version the version of the policy to get, null to get all versions of a PDP group
282      * @return the PDP groups found
283      * @throws PfModelException on errors getting PDP groups
284      */
285     public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException;
286
287     /**
288      * Get filtered PDP groups.
289      *
290      * @param filter the filter for the PDP groups to get
291      * @return the PDP groups found
292      * @throws PfModelException on errors getting policies
293      */
294     public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
295
296     /**
297      * Creates PDP groups.
298      *
299      * @param pdpGroups a specification of the PDP groups to create
300      * @return the PDP groups created
301      * @throws PfModelException on errors creating PDP groups
302      */
303     public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
304
305     /**
306      * Updates PDP groups.
307      *
308      * @param pdpGroups a specification of the PDP groups to update
309      * @return the PDP groups updated
310      * @throws PfModelException on errors updating PDP groups
311      */
312     public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
313
314     /**
315      * Update a PDP subgroup.
316      *
317      * @param pdpGroupName the name of the PDP group of the PDP subgroup
318      * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
319      * @param pdpSubGroup the PDP subgroup to be updated
320      * @throws PfModelException on errors updating PDP subgroups
321      */
322     public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
323             @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException;
324
325     /**
326      * Update a PDP.
327      *
328      * @param pdpGroupName the name of the PDP group of the PDP subgroup
329      * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
330      * @param pdpSubGroup the PDP subgroup to be updated
331      * @param pdp the PDP to be updated
332      * @throws PfModelException on errors updating PDP subgroups
333      */
334     public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
335             @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) throws PfModelException;
336
337     /**
338      * Delete a PDP group.
339      *
340      * @param name the name of the policy to get, null to get all PDP groups
341      * @param version the version of the policy to get, null to get all versions of a PDP group
342      * @return the PDP group deleted
343      * @throws PfModelException on errors deleting PDP groups
344      */
345     public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException;
346
347     /**
348      * Get PDP statistics.
349      *
350      * @param name the name of the PDP group to get statistics for, null to get all PDP groups
351      * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
352      * @return the statistics found
353      * @throws PfModelException on errors getting statistics
354      */
355     public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException;
356
357     /**
358      * Update PDP statistics for a PDP.
359      *
360      * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
361      * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
362      * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
363      * @param pdpInstanceId the instance ID of the PDP to update statistics for
364      * @throws PfModelException on errors updating statistics
365      */
366     public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
367             @NonNull final String pdpType, @NonNull final String pdpInstanceId,
368             @NonNull final PdpStatistics pdppStatistics) throws PfModelException;
369 }