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;
40 * This interface describes the operations that are provided to users and components for reading objects from and
41 * writing objects to the database.
43 * @author Liam Fallon (liam.fallon@est.tech)
45 public interface PolicyModelsProvider extends AutoCloseable {
47 * Open the policy model provider initializing whatever internal handling it needs.
49 * @throws PfModelException on errors opening the models provider
51 public void init() throws PfModelException;
54 public void close() throws PfModelException;
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
64 public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
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
74 public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
77 * Get filtered policy types.
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
83 public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
84 throws PfModelException;
87 * Get filtered policy types.
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
93 public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
94 throws PfModelException;
97 * Create policy types.
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
103 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
104 throws PfModelException;
107 * Create policy types.
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
113 public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
114 throws PfModelException;
117 * Delete policy type.
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
124 public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
125 throws PfModelException;
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
135 public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
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
145 public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
148 * Get filtered policies.
150 * @param filter the filter for the policies to get
151 * @return the policies found
152 * @throws PfModelException on errors getting policies
154 public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
157 * Get filtered policies.
159 * @param filter the filter for the policies to get
160 * @return the policies found
161 * @throws PfModelException on errors getting policies
163 public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
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
172 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
173 throws PfModelException;
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
182 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
183 throws PfModelException;
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
193 public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
194 throws PfModelException;
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
203 public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
206 * Get filtered PDP groups.
208 * @param filter the filter for the PDP groups to get
209 * @return the PDP groups found
210 * @throws PfModelException on errors getting policies
212 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
215 * Creates PDP groups.
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
221 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
224 * Updates PDP groups.
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
230 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
233 * Update a PDP subgroup.
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
239 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
240 throws PfModelException;
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
250 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
251 throws PfModelException;
254 * Delete a PDP group.
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
260 public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
263 * Get PDP statistics.
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
269 public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException;
273 * Get filtered PdpStatistics.
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
285 public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup,
286 Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) throws PfModelException;
289 * Creates PDP statistics.
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
295 public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
296 throws PfModelException;
299 * Updates PDP statistics.
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
305 public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
306 throws PfModelException;
309 * Delete a PDP statistics.
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
316 public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException;