2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.provider;
23 import java.util.Date;
24 import java.util.List;
25 import lombok.NonNull;
26 import org.onap.policy.models.base.PfModelException;
27 import org.onap.policy.models.pdp.concepts.Pdp;
28 import org.onap.policy.models.pdp.concepts.PdpGroup;
29 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
30 import org.onap.policy.models.pdp.concepts.PdpStatistics;
31 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
33 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
35 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
36 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
37 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
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;
197 * Get legacy operational policy.
199 * @param policyId ID of the policy
200 * @param policyVersion version of the policy, set to null to get the latest policy
201 * @return the policies found
202 * @throws PfModelException on errors getting policies
204 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId, final String policyVersion)
205 throws PfModelException;
208 * Create legacy operational policy.
210 * @param legacyOperationalPolicy the definition of the policy to be created.
211 * @return the created policy
212 * @throws PfModelException on errors creating policies
214 public LegacyOperationalPolicy createOperationalPolicy(
215 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
218 * Update legacy operational policy.
220 * @param legacyOperationalPolicy the definition of the policy to be updated
221 * @return the updated policy
222 * @throws PfModelException on errors updating policies
224 public LegacyOperationalPolicy updateOperationalPolicy(
225 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
228 * Delete legacy operational policy.
230 * @param policyId ID of the policy.
231 * @param policyVersion version of the policy
232 * @return the deleted policy
233 * @throws PfModelException on errors deleting policies
235 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId,
236 @NonNull final String policyVersion) throws PfModelException;
241 * @param name the name of the policy to get, null to get all PDP groups
242 * @return the PDP groups found
243 * @throws PfModelException on errors getting PDP groups
245 public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
248 * Get filtered PDP groups.
250 * @param filter the filter for the PDP groups to get
251 * @return the PDP groups found
252 * @throws PfModelException on errors getting policies
254 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
257 * Creates PDP groups.
259 * @param pdpGroups a specification of the PDP groups to create
260 * @return the PDP groups created
261 * @throws PfModelException on errors creating PDP groups
263 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
266 * Updates PDP groups.
268 * @param pdpGroups a specification of the PDP groups to update
269 * @return the PDP groups updated
270 * @throws PfModelException on errors updating PDP groups
272 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
275 * Update a PDP subgroup.
277 * @param pdpGroupName the name of the PDP group of the PDP subgroup
278 * @param pdpSubGroup the PDP subgroup to be updated
279 * @throws PfModelException on errors updating PDP subgroups
281 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
282 throws PfModelException;
287 * @param pdpGroupName the name of the PDP group of the PDP subgroup
288 * @param pdpSubGroup the PDP subgroup to be updated
289 * @param pdp the PDP to be updated
290 * @throws PfModelException on errors updating PDP subgroups
292 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
293 throws PfModelException;
296 * Delete a PDP group.
298 * @param name the name of the policy to get, null to get all PDP groups
299 * @return the PDP group deleted
300 * @throws PfModelException on errors deleting PDP groups
302 public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
305 * Get PDP statistics.
307 * @param name the name of the PDP group to get statistics for, null to get all PDP groups
308 * @return the statistics found
309 * @throws PfModelException on errors getting statistics
311 public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException;
315 * Get filtered PdpStatistics.
317 * @param name the pdpInstance name for the PDP statistics to get
318 * @param pdpGroupName pdpGroupName to filter statistics
319 * @param pdpSubGroup pdpSubGroupType name to filter statistics
320 * @param startTimeStamp startTimeStamp to filter statistics
321 * @param endTimeStamp endTimeStamp to filter statistics
322 * @param sortOrder sortOrder to query database
323 * @param getRecordNum Total query count from database
324 * @return the PDP statistics found
325 * @throws PfModelException on errors getting policies
327 public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup,
328 Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) throws PfModelException;
331 * Creates PDP statistics.
333 * @param pdpStatisticsList a specification of the PDP statistics to create
334 * @return the PDP statistics created
335 * @throws PfModelException on errors creating PDP statistics
337 public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
338 throws PfModelException;
341 * Updates PDP statistics.
343 * @param pdpStatisticsList a specification of the PDP statistics to update
344 * @return the PDP statistics updated
345 * @throws PfModelException on errors updating PDP statistics
347 public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
348 throws PfModelException;
351 * Delete a PDP statistics.
353 * @param name the name of the policy to get, null to get all PDP statistics
354 * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp
355 * @return the PDP statistics deleted
356 * @throws PfModelException on errors deleting PDP statistics
358 public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException;