Add Service Template TOSCA handling
[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 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
39
40 /**
41  * This interface describes the operations that are provided to users and components for reading objects from and
42  * writing objects to the database.
43  *
44  * @author Liam Fallon (liam.fallon@est.tech)
45  */
46 public interface PolicyModelsProvider extends AutoCloseable {
47     /**
48      * Open the policy model provider initializing whatever internal handling it needs.
49      *
50      * @throws PfModelException on errors opening the models provider
51      */
52     public void init() throws PfModelException;
53
54     @Override
55     public void close() throws PfModelException;
56
57     /**
58      * Get service templates.
59      *
60      * @param name the name of the topology template to get, set to null to get all service templates
61      * @param version the version of the service template to get, set to null to get all service templates
62      * @return the topology templates found
63      * @throws PfModelException on errors getting service templates
64      */
65     public List<ToscaServiceTemplate> getServiceTemplateList(final String name, final String version)
66             throws PfModelException;
67
68     /**
69      * Get filtered service templates.
70      *
71      * @param filter the filter for the service templates to get
72      * @return the service templates found
73      * @throws PfModelException on errors getting service templates
74      */
75     public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull final ToscaServiceTemplateFilter filter)
76             throws PfModelException;
77
78     /**
79      * Create service template.
80      *
81      * @param serviceTemplate the service template to be created
82      * @return the created service template
83      * @throws PfModelException on errors creating the service template
84      */
85     public ToscaServiceTemplate createServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
86             throws PfModelException;
87
88     /**
89      * Update service template.
90      *
91      * @param serviceTemplate the service template to be updated
92      * @return the updated service template
93      * @throws PfModelException on errors updating the service template
94      */
95     public ToscaServiceTemplate updateServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
96             throws PfModelException;
97
98     /**
99      * Delete service template.
100      *
101      * @param name the name of the service template to delete.
102      * @param version the version of the service template to delete.
103      * @return the TOSCA service template that was deleted
104      * @throws PfModelException on errors deleting policy types
105      */
106     public ToscaServiceTemplate deleteServiceTemplate(@NonNull final String name, @NonNull final String version)
107             throws PfModelException;
108
109     /**
110      * Get policy types.
111      *
112      * @param name the name of the policy type to get, set to null to get all policy types
113      * @param version the version of the policy type to get, set to null to get all versions
114      * @return the policy types found
115      * @throws PfModelException on errors getting policy types
116      */
117     public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
118
119     /**
120      * Get policy types.
121      *
122      * @param name the name of the policy type to get, set to null to get all policy types
123      * @param version the version of the policy type to get, set to null to get all versions
124      * @return the policy types found
125      * @throws PfModelException on errors getting policy types
126      */
127     public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
128
129     /**
130      * Get filtered policy types.
131      *
132      * @param filter the filter for the policy types to get
133      * @return the policy types found
134      * @throws PfModelException on errors getting policy types
135      */
136     public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
137             throws PfModelException;
138
139     /**
140      * Get filtered policy types.
141      *
142      * @param filter the filter for the policy types to get
143      * @return the policy types found
144      * @throws PfModelException on errors getting policy types
145      */
146     public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
147             throws PfModelException;
148
149     /**
150      * Create policy types.
151      *
152      * @param serviceTemplate the service template containing the definition of the policy types to be created
153      * @return the TOSCA service template containing the created policy types
154      * @throws PfModelException on errors creating policy types
155      */
156     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
157             throws PfModelException;
158
159     /**
160      * Update policy types.
161      *
162      * @param serviceTemplate the service template containing the definition of the policy types to be modified
163      * @return the TOSCA service template containing the modified policy types
164      * @throws PfModelException on errors updating policy types
165      */
166     public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
167             throws PfModelException;
168
169     /**
170      * Delete policy type.
171      *
172      * @param name the name of the policy type to delete.
173      * @param version the version of the policy type to delete.
174      * @return the TOSCA service template containing the policy type that was deleted
175      * @throws PfModelException on errors deleting the policy type
176      */
177     public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
178             throws PfModelException;
179
180     /**
181      * Get policies.
182      *
183      * @param name the name of the policy to get, null to get all policies
184      * @param version the version of the policy to get, null to get all versions of a policy
185      * @return the policies found
186      * @throws PfModelException on errors getting policies
187      */
188     public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
189
190     /**
191      * Get policies.
192      *
193      * @param name the name of the policy to get, null to get all policies
194      * @param version the version of the policy to get, null to get all versions of a policy
195      * @return the policies found
196      * @throws PfModelException on errors getting policies
197      */
198     public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
199
200     /**
201      * Get filtered policies.
202      *
203      * @param filter the filter for the policies to get
204      * @return the policies found
205      * @throws PfModelException on errors getting policies
206      */
207     public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
208
209     /**
210      * Get filtered policies.
211      *
212      * @param filter the filter for the policies to get
213      * @return the policies found
214      * @throws PfModelException on errors getting policies
215      */
216     public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
217
218     /**
219      * Create policies.
220      *
221      * @param serviceTemplate the service template containing the definitions of the new policies to be created.
222      * @return the TOSCA service template containing the policy types that were created
223      * @throws PfModelException on errors creating policies
224      */
225     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
226             throws PfModelException;
227
228     /**
229      * Update policies.
230      *
231      * @param serviceTemplate the service template containing the definitions of the policies to be updated.
232      * @return the TOSCA service template containing the policies that were updated
233      * @throws PfModelException on errors updating policies
234      */
235     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
236             throws PfModelException;
237
238     /**
239      * Delete policy.
240      *
241      * @param name the name of the policy to delete.
242      * @param version the version of the policy to delete.
243      * @return the TOSCA service template containing the policy that was deleted
244      * @throws PfModelException on errors deleting a policy
245      */
246     public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
247             throws PfModelException;
248
249     /**
250      * Get PDP groups.
251      *
252      * @param name the name of the policy to get, null to get all PDP groups
253      * @return the PDP groups found
254      * @throws PfModelException on errors getting PDP groups
255      */
256     public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
257
258     /**
259      * Get filtered PDP groups.
260      *
261      * @param filter the filter for the PDP groups to get
262      * @return the PDP groups found
263      * @throws PfModelException on errors getting policies
264      */
265     public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
266
267     /**
268      * Creates PDP groups.
269      *
270      * @param pdpGroups a specification of the PDP groups to create
271      * @return the PDP groups created
272      * @throws PfModelException on errors creating PDP groups
273      */
274     public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
275
276     /**
277      * Updates PDP groups.
278      *
279      * @param pdpGroups a specification of the PDP groups to update
280      * @return the PDP groups updated
281      * @throws PfModelException on errors updating PDP groups
282      */
283     public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
284
285     /**
286      * Update a PDP subgroup.
287      *
288      * @param pdpGroupName the name of the PDP group of the PDP subgroup
289      * @param pdpSubGroup the PDP subgroup to be updated
290      * @throws PfModelException on errors updating PDP subgroups
291      */
292     public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
293             throws PfModelException;
294
295     /**
296      * Update a PDP.
297      *
298      * @param pdpGroupName the name of the PDP group of the PDP subgroup
299      * @param pdpSubGroup the PDP subgroup to be updated
300      * @param pdp the PDP to be updated
301      * @throws PfModelException on errors updating PDP subgroups
302      */
303     public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
304             throws PfModelException;
305
306     /**
307      * Delete a PDP group.
308      *
309      * @param name the name of the policy to get, null to get all PDP groups
310      * @return the PDP group deleted
311      * @throws PfModelException on errors deleting PDP groups
312      */
313     public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
314
315     /**
316      * Get PDP statistics.
317      *
318      * @param name the name of the PDP group to get statistics for, null to get all PDP groups
319      * @return the statistics found
320      * @throws PfModelException on errors getting statistics
321      */
322     public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException;
323
324
325     /**
326      * Get filtered PdpStatistics.
327      *
328      * @param name the pdpInstance name for the PDP statistics to get
329      * @param pdpGroupName pdpGroupName to filter statistics
330      * @param pdpSubGroup pdpSubGroupType name to filter statistics
331      * @param startTimeStamp startTimeStamp to filter statistics
332      * @param endTimeStamp endTimeStamp to filter statistics
333      * @param sortOrder sortOrder to query database
334      * @param getRecordNum Total query count from database
335      * @return the PDP statistics found
336      * @throws PfModelException on errors getting policies
337      */
338     public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup,
339             Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) throws PfModelException;
340
341     /**
342      * Creates PDP statistics.
343      *
344      * @param pdpStatisticsList a specification of the PDP statistics to create
345      * @return the PDP statistics created
346      * @throws PfModelException on errors creating PDP statistics
347      */
348     public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
349             throws PfModelException;
350
351     /**
352      * Updates PDP statistics.
353      *
354      * @param pdpStatisticsList a specification of the PDP statistics to update
355      * @return the PDP statistics updated
356      * @throws PfModelException on errors updating PDP statistics
357      */
358     public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
359             throws PfModelException;
360
361     /**
362      * Delete a PDP statistics.
363      *
364      * @param name the name of the policy to get, null to get all PDP statistics
365      * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp
366      * @return the PDP statistics deleted
367      * @throws PfModelException on errors deleting PDP statistics
368      */
369     public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException;
370 }