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