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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.provider;
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;
41 * This interface describes the operations that are provided to users and components for reading objects from and
42 * writing objects to the database.
44 * @author Liam Fallon (liam.fallon@est.tech)
46 public interface PolicyModelsProvider extends AutoCloseable {
48 * Open the policy model provider initializing whatever internal handling it needs.
50 * @throws PfModelException on errors opening the models provider
52 public void init() throws PfModelException;
55 public void close() throws PfModelException;
58 * Get service templates.
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
65 public List<ToscaServiceTemplate> getServiceTemplateList(final String name, final String version)
66 throws PfModelException;
69 * Get filtered service templates.
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
75 public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull final ToscaServiceTemplateFilter filter)
76 throws PfModelException;
79 * Create service template.
81 * @param serviceTemplate the service template to be created
82 * @return the created service template
83 * @throws PfModelException on errors creating the service template
85 public ToscaServiceTemplate createServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
86 throws PfModelException;
89 * Update service template.
91 * @param serviceTemplate the service template to be updated
92 * @return the updated service template
93 * @throws PfModelException on errors updating the service template
95 public ToscaServiceTemplate updateServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate)
96 throws PfModelException;
99 * Delete service template.
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
106 public ToscaServiceTemplate deleteServiceTemplate(@NonNull final String name, @NonNull final String version)
107 throws PfModelException;
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
117 public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
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
127 public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
130 * Get filtered policy types.
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
136 public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
137 throws PfModelException;
140 * Get filtered policy types.
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
146 public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
147 throws PfModelException;
150 * Create policy types.
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
156 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
157 throws PfModelException;
160 * Update policy types.
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
166 public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
167 throws PfModelException;
170 * Delete policy type.
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
177 public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
178 throws PfModelException;
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
188 public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
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
198 public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
201 * Get filtered policies.
203 * @param filter the filter for the policies to get
204 * @return the policies found
205 * @throws PfModelException on errors getting policies
207 public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
210 * Get filtered policies.
212 * @param filter the filter for the policies to get
213 * @return the policies found
214 * @throws PfModelException on errors getting policies
216 public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
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
225 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
226 throws PfModelException;
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
235 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
236 throws PfModelException;
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
246 public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
247 throws PfModelException;
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
256 public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
259 * Get filtered PDP groups.
261 * @param filter the filter for the PDP groups to get
262 * @return the PDP groups found
263 * @throws PfModelException on errors getting policies
265 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
268 * Creates PDP groups.
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
274 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
277 * Updates PDP groups.
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
283 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
286 * Update a PDP subgroup.
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
292 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
293 throws PfModelException;
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
303 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
304 throws PfModelException;
307 * Delete a PDP group.
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
313 public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
316 * Get PDP statistics.
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
322 public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException;
326 * Get filtered PdpStatistics.
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
338 public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup,
339 Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) throws PfModelException;
342 * Creates PDP statistics.
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
348 public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
349 throws PfModelException;
352 * Updates PDP statistics.
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
358 public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
359 throws PfModelException;
362 * Delete a PDP statistics.
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
369 public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException;