Remove unused imports in models
[policy/models.git] / models-provider / src / main / java / org / onap / policy / models / provider / PolicyModelsProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019-2022 Nordix Foundation.
4  *  Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
5  *  Modifications Copyright (C) 2021 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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.models.provider;
24
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.Map;
28 import lombok.NonNull;
29 import org.onap.policy.models.base.PfModelException;
30 import org.onap.policy.models.base.PfModelRuntimeException;
31 import org.onap.policy.models.pdp.concepts.Pdp;
32 import org.onap.policy.models.pdp.concepts.PdpGroup;
33 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
34 import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
35 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
36 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityFilter;
38 import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey;
39 import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
40 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
41 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
42 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
43 import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
44
45 /**
46  * This interface describes the operations that are provided to users and components for reading objects from and
47  * writing objects to the database.
48  *
49  * @author Liam Fallon (liam.fallon@est.tech)
50  */
51 public interface PolicyModelsProvider extends AutoCloseable {
52     /**
53      * Open the policy model provider initializing whatever internal handling it needs.
54      *
55      * @throws PfModelException on errors opening the models provider
56      */
57     public void init() throws PfModelException;
58
59     @Override
60     public void close() throws PfModelException;
61
62     /**
63      * Get service templates.
64      *
65      * @param name the name of the topology template to get, set to null to get all service templates
66      * @param version the version of the service template to get, set to null to get all service templates
67      * @return the topology templates found
68      * @throws PfModelException on errors getting service templates
69      */
70     public List<ToscaServiceTemplate> getServiceTemplateList(final String name, final String version)
71             throws PfModelException;
72
73     /**
74      * Get filtered service templates.
75      *
76      * @param filter the filter for the service templates to get
77      * @return the service templates found
78      * @throws PfModelException on errors getting service templates
79      */
80     public List<ToscaServiceTemplate> getFilteredServiceTemplateList(
81             @NonNull final ToscaEntityFilter<ToscaServiceTemplate> filter) throws PfModelException;
82
83     /**
84      * Create service template.
85      *
86      * @param serviceTemplate the service template to be created
87      * @return the created service template
88      * @throws PfModelException on errors creating the service template
89      */
90     public ToscaServiceTemplate createServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
91             throws PfModelException;
92
93     /**
94      * Update service template.
95      *
96      * @param serviceTemplate the service template to be updated
97      * @return the updated service template
98      * @throws PfModelException on errors updating the service template
99      */
100     public ToscaServiceTemplate updateServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
101             throws PfModelException;
102
103     /**
104      * Delete service template.
105      *
106      * @param name the name of the service template to delete.
107      * @param version the version of the service template to delete.
108      * @return the TOSCA service template that was deleted
109      * @throws PfModelException on errors deleting policy types
110      */
111     public ToscaServiceTemplate deleteServiceTemplate(@NonNull final String name, @NonNull final String version)
112             throws PfModelException;
113
114     /**
115      * Get policy types.
116      *
117      * @param name the name of the policy type to get, set to null to get all policy types
118      * @param version the version of the policy type to get, set to null to get all versions
119      * @return the policy types found
120      * @throws PfModelException on errors getting policy types
121      */
122     public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
123
124     /**
125      * Get policy types.
126      *
127      * @param name the name of the policy type to get, set to null to get all policy types
128      * @param version the version of the policy type to get, set to null to get all versions
129      * @return the policy types found
130      * @throws PfModelException on errors getting policy types
131      */
132     public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
133
134     /**
135      * Get filtered policy types.
136      *
137      * @param filter the filter for the policy types to get
138      * @return the policy types found
139      * @throws PfModelException on errors getting policy types
140      */
141     public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaEntityFilter<ToscaPolicyType> filter)
142             throws PfModelException;
143
144     /**
145      * Get filtered policy types.
146      *
147      * @param filter the filter for the policy types to get
148      * @return the policy types found
149      * @throws PfModelException on errors getting policy types
150      */
151     public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaEntityFilter<ToscaPolicyType> filter)
152             throws PfModelException;
153
154     /**
155      * Create policy types.
156      *
157      * @param serviceTemplate the service template containing the definition of the policy types to be created
158      * @return the TOSCA service template containing the created policy types
159      * @throws PfModelException on errors creating policy types
160      */
161     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
162             throws PfModelException;
163
164     /**
165      * Update policy types.
166      *
167      * @param serviceTemplate the service template containing the definition of the policy types to be modified
168      * @return the TOSCA service template containing the modified policy types
169      * @throws PfModelException on errors updating policy types
170      */
171     public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
172             throws PfModelException;
173
174     /**
175      * Delete policy type.
176      *
177      * @param name the name of the policy type to delete.
178      * @param version the version of the policy type to delete.
179      * @return the TOSCA service template containing the policy type that was deleted
180      * @throws PfModelException on errors deleting the policy type
181      */
182     public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
183             throws PfModelException;
184
185     /**
186      * Get policies.
187      *
188      * @param name the name of the policy to get, null to get all policies
189      * @param version the version of the policy to get, null to get all versions of a policy
190      * @return the policies found
191      * @throws PfModelException on errors getting policies
192      */
193     public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
194
195     /**
196      * Get policies.
197      *
198      * @param name the name of the policy to get, null to get all policies
199      * @param version the version of the policy to get, null to get all versions of a policy
200      * @return the policies found
201      * @throws PfModelException on errors getting policies
202      */
203     public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
204
205     /**
206      * Get filtered policies.
207      *
208      * @param filter the filter for the policies to get
209      * @return the policies found
210      * @throws PfModelException on errors getting policies
211      */
212     public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaTypedEntityFilter<ToscaPolicy> filter)
213             throws PfModelException;
214
215     /**
216      * Get filtered policies.
217      *
218      * @param filter the filter for the policies to get
219      * @return the policies found
220      * @throws PfModelException on errors getting policies
221      */
222     public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaTypedEntityFilter<ToscaPolicy> filter)
223             throws PfModelException;
224
225     /**
226      * Create policies.
227      *
228      * @param serviceTemplate the service template containing the definitions of the new policies to be created.
229      * @return the TOSCA service template containing the policy types that were created
230      * @throws PfModelException on errors creating policies
231      */
232     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
233             throws PfModelException;
234
235     /**
236      * Update policies.
237      *
238      * @param serviceTemplate the service template containing the definitions of the policies to be updated.
239      * @return the TOSCA service template containing the policies that were updated
240      * @throws PfModelException on errors updating policies
241      */
242     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
243             throws PfModelException;
244
245     /**
246      * Delete policy.
247      *
248      * @param name the name of the policy to delete.
249      * @param version the version of the policy to delete.
250      * @return the TOSCA service template containing the policy that was deleted
251      * @throws PfModelException on errors deleting a policy
252      */
253     public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
254             throws PfModelException;
255
256
257     /**
258      * Create tosca node templates.
259      *
260      * @param serviceTemplate the definitions of the new node templates to be created.
261      * @return the tosca node templates that were created
262      * @throws PfModelException on errors creating tosca node templates
263      */
264     public ToscaServiceTemplate createToscaNodeTemplates(@NonNull final ToscaServiceTemplate serviceTemplate)
265         throws PfModelException;
266
267     /**
268      * Update tosca node templates.
269      *
270      * @param serviceTemplate with node templates to be updated.
271      * @return the service template with node templates that were updated
272      * @throws PfModelException on errors updating tosca node templates
273      */
274     public ToscaServiceTemplate updateToscaNodeTemplates(@NonNull final ToscaServiceTemplate serviceTemplate)
275         throws PfModelRuntimeException, PfModelException;
276
277     /**
278      * Delete a tosca node template.
279      *
280      * @param name the name of the node template to delete.
281      * @param version the version of the node template to delete.
282      * @return the service template with node templates that was deleted
283      * @throws PfModelException on errors deleting a node template
284      */
285     public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull final String name, @NonNull final String version)
286         throws PfModelException;
287
288
289     /**
290      * Get filtered node template metadataSet entities.
291      *
292      * @return the list of metadataSet found
293      * @throws PfModelException on errors getting node template metadataSet
294      */
295     public List<Map<ToscaEntityKey, Map<String, Object>>> getNodeTemplateMetadataSets(final String name,
296                                                                                       final String version)
297         throws PfModelException;
298
299     /**
300      * Get filtered node template entities.
301      *
302      * @return the list of nodeTemplates found
303      * @throws PfModelException on errors getting node template
304      */
305     public List<ToscaNodeTemplate> getToscaNodeTemplate(final String name, final String version)
306         throws PfModelException;
307
308     /**
309      * Get PDP groups.
310      *
311      * @param name the name of the policy to get, null to get all PDP groups
312      * @return the PDP groups found
313      * @throws PfModelException on errors getting PDP groups
314      */
315     public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
316
317     /**
318      * Get filtered PDP groups.
319      *
320      * @param filter the filter for the PDP groups to get
321      * @return the PDP groups found
322      * @throws PfModelException on errors getting policies
323      */
324     public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
325
326     /**
327      * Creates PDP groups.
328      *
329      * @param pdpGroups a specification of the PDP groups to create
330      * @return the PDP groups created
331      * @throws PfModelException on errors creating PDP groups
332      */
333     public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
334
335     /**
336      * Updates PDP groups.
337      *
338      * @param pdpGroups a specification of the PDP groups to update
339      * @return the PDP groups updated
340      * @throws PfModelException on errors updating PDP groups
341      */
342     public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
343
344     /**
345      * Update a PDP subgroup.
346      *
347      * @param pdpGroupName the name of the PDP group of the PDP subgroup
348      * @param pdpSubGroup the PDP subgroup to be updated
349      * @throws PfModelException on errors updating PDP subgroups
350      */
351     public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
352             throws PfModelException;
353
354     /**
355      * Update a PDP.
356      *
357      * @param pdpGroupName the name of the PDP group of the PDP subgroup
358      * @param pdpSubGroup the PDP subgroup to be updated
359      * @param pdp the PDP to be updated
360      * @throws PfModelException on errors updating PDP subgroups
361      */
362     public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
363             throws PfModelException;
364
365     /**
366      * Delete a PDP group.
367      *
368      * @param name the name of the policy to get, null to get all PDP groups
369      * @return the PDP group deleted
370      * @throws PfModelException on errors deleting PDP groups
371      */
372     public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
373
374     /**
375      * Gets all policy deployments.
376      *
377      * @return the deployments found
378      * @throws PfModelException on errors getting PDP groups
379      */
380     public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException;
381
382     /**
383      * Gets all deployments for a policy.
384      *
385      * @return the deployments found
386      * @throws PfModelException on errors getting PDP groups
387      */
388     public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull ToscaConceptIdentifierOptVersion policy)
389             throws PfModelException;
390
391     /**
392      * Gets the policy deployments for a PDP group.
393      *
394      * @param groupName the name of the PDP group of interest, null to get results for all PDP groups
395      * @return the deployments found
396      * @throws PfModelException on errors getting PDP groups
397      */
398     public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull final String groupName) throws PfModelException;
399
400     /**
401      * Creates, updates, and deletes collections of policy status.
402      *
403      * @param createObjs the objects to create
404      * @param updateObjs the objects to update
405      * @param deleteObjs the objects to delete
406      */
407     public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
408             Collection<PdpPolicyStatus> deleteObjs);
409 }