2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 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;
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.legacy.concepts.LegacyGuardPolicyInput;
39 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
40 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
43 * This interface describes the operations that are provided to users and components for reading objects from and
44 * writing objects to the database.
46 * @author Liam Fallon (liam.fallon@est.tech)
48 public interface PolicyModelsProvider extends AutoCloseable {
50 * Open the policy model provider initializing whatever internal handling it needs.
52 * @throws PfModelException on errors opening the models provider
54 public void init() throws PfModelException;
57 public void close() throws PfModelException;
62 * @param name the name of the policy type to get, set to null to get all policy types
63 * @param version the version of the policy type to get, set to null to get all versions
64 * @return the policy types found
65 * @throws PfModelException on errors getting policy types
67 public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
72 * @param name the name of the policy type to get, set to null to get all policy types
73 * @param version the version of the policy type to get, set to null to get all versions
74 * @return the policy types found
75 * @throws PfModelException on errors getting policy types
77 public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
80 * Get filtered policy types.
82 * @param filter the filter for the policy types to get
83 * @return the policy types found
84 * @throws PfModelException on errors getting policy types
86 public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
87 throws PfModelException;
90 * Get filtered policy types.
92 * @param filter the filter for the policy types to get
93 * @return the policy types found
94 * @throws PfModelException on errors getting policy types
96 public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
97 throws PfModelException;
100 * Create policy types.
102 * @param serviceTemplate the service template containing the definition of the policy types to be created
103 * @return the TOSCA service template containing the created policy types
104 * @throws PfModelException on errors creating policy types
106 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
107 throws PfModelException;
110 * Create policy types.
112 * @param serviceTemplate the service template containing the definition of the policy types to be modified
113 * @return the TOSCA service template containing the modified policy types
114 * @throws PfModelException on errors updating policy types
116 public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
117 throws PfModelException;
120 * Delete policy type.
122 * @param name the name of the policy type to delete.
123 * @param version the version of the policy type to delete.
124 * @return the TOSCA service template containing the policy type that was deleted
125 * @throws PfModelException on errors deleting policy types
127 public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
128 throws PfModelException;
133 * @param name the name of the policy to get, null to get all policies
134 * @param version the version of the policy to get, null to get all versions of a policy
135 * @return the policies found
136 * @throws PfModelException on errors getting policies
138 public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
143 * @param name the name of the policy to get, null to get all policies
144 * @param version the version of the policy to get, null to get all versions of a policy
145 * @return the policies found
146 * @throws PfModelException on errors getting policies
148 public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
151 * Get filtered policies.
153 * @param filter the filter for the policies to get
154 * @return the policies found
155 * @throws PfModelException on errors getting policies
157 public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
160 * Get filtered policies.
162 * @param filter the filter for the policies to get
163 * @return the policies found
164 * @throws PfModelException on errors getting policies
166 public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
171 * @param serviceTemplate the service template containing the definitions of the new policies to be created.
172 * @return the TOSCA service template containing the policy types that were created
173 * @throws PfModelException on errors creating policies
175 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
176 throws PfModelException;
181 * @param serviceTemplate the service template containing the definitions of the policies to be updated.
182 * @return the TOSCA service template containing the policies that were updated
183 * @throws PfModelException on errors updating policies
185 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
186 throws PfModelException;
191 * @param name the name of the policy to delete.
192 * @param version the version of the policy to delete.
193 * @return the TOSCA service template containing the policy that was deleted
194 * @throws PfModelException on errors deleting a policy
196 public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
197 throws PfModelException;
200 * Get legacy operational policy.
202 * @param policyId ID of the policy
203 * @param policyVersion version of the policy, set to null to get the latest policy
204 * @return the policies found
205 * @throws PfModelException on errors getting policies
207 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId, final String policyVersion)
208 throws PfModelException;
211 * Create legacy operational policy.
213 * @param legacyOperationalPolicy the definition of the policy to be created.
214 * @return the created policy
215 * @throws PfModelException on errors creating policies
217 public LegacyOperationalPolicy createOperationalPolicy(
218 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
221 * Update legacy operational policy.
223 * @param legacyOperationalPolicy the definition of the policy to be updated
224 * @return the updated policy
225 * @throws PfModelException on errors updating policies
227 public LegacyOperationalPolicy updateOperationalPolicy(
228 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
231 * Delete legacy operational policy.
233 * @param policyId ID of the policy.
234 * @param policyVersion version of the policy
235 * @return the deleted policy
236 * @throws PfModelException on errors deleting policies
238 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId,
239 @NonNull final String policyVersion) throws PfModelException;
242 * Get legacy guard policy.
244 * @param policyId ID of the policy
245 * @param policyVersion version of the policy, set to null to get the latest policy
246 * @return the policies found
247 * @throws PfModelException on errors getting policies
249 public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId,
250 final String policyVersion) throws PfModelException;
253 * Create legacy guard policy.
255 * @param legacyGuardPolicy the definition of the policy to be created.
256 * @return the created policy
257 * @throws PfModelException on errors creating policies
259 public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
260 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
263 * Update legacy guard policy.
265 * @param legacyGuardPolicy the definition of the policy to be updated
266 * @return the updated policy
267 * @throws PfModelException on errors updating policies
269 public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
270 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
273 * Delete legacy guard policy.
275 * @param policyId ID of the policy.
276 * @param policyVersion version of the policy
277 * @return the deleted policy
278 * @throws PfModelException on errors deleting policies
280 public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId,
281 @NonNull final String policyVersion) throws PfModelException;
286 * @param name the name of the policy to get, null to get all PDP groups
287 * @return the PDP groups found
288 * @throws PfModelException on errors getting PDP groups
290 public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
293 * Get filtered PDP groups.
295 * @param filter the filter for the PDP groups to get
296 * @return the PDP groups found
297 * @throws PfModelException on errors getting policies
299 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
302 * Creates PDP groups.
304 * @param pdpGroups a specification of the PDP groups to create
305 * @return the PDP groups created
306 * @throws PfModelException on errors creating PDP groups
308 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
311 * Updates PDP groups.
313 * @param pdpGroups a specification of the PDP groups to update
314 * @return the PDP groups updated
315 * @throws PfModelException on errors updating PDP groups
317 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
320 * Update a PDP subgroup.
322 * @param pdpGroupName the name of the PDP group of the PDP subgroup
323 * @param pdpSubGroup the PDP subgroup to be updated
324 * @throws PfModelException on errors updating PDP subgroups
326 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
327 throws PfModelException;
332 * @param pdpGroupName the name of the PDP group of the PDP subgroup
333 * @param pdpSubGroup the PDP subgroup to be updated
334 * @param pdp the PDP to be updated
335 * @throws PfModelException on errors updating PDP subgroups
337 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
338 throws PfModelException;
341 * Delete a PDP group.
343 * @param name the name of the policy to get, null to get all PDP groups
344 * @return the PDP group deleted
345 * @throws PfModelException on errors deleting PDP groups
347 public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
350 * Get PDP statistics.
352 * @param name the name of the PDP group to get statistics for, null to get all PDP groups
353 * @return the statistics found
354 * @throws PfModelException on errors getting statistics
356 public List<PdpStatistics> getPdpStatistics(final String name, final Date timestamp) throws PfModelException;
360 * Get filtered PdpStatistics.
362 * @param name the pdpInstance name for the PDP statistics to get
363 * @param pdpGroupName pdpGroupName to filter statistics
364 * @param pdpSubGroup pdpSubGroupType name to filter statistics
365 * @param startTimeStamp startTimeStamp to filter statistics
366 * @param endTimeStamp endTimeStamp to filter statistics
367 * @return the PDP statistics found
368 * @throws PfModelException on errors getting policies
370 public List<PdpStatistics> getFilteredPdpStatistics(String name, @NonNull String pdpGroupName, String pdpSubGroup,
371 Date startTimeStamp, Date endTimeStamp) throws PfModelException;
374 * Creates PDP statistics.
376 * @param pdpStatisticsList a specification of the PDP statistics to create
377 * @return the PDP statistics created
378 * @throws PfModelException on errors creating PDP statistics
380 public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
381 throws PfModelException;
384 * Updates PDP statistics.
386 * @param pdpStatisticsList a specification of the PDP statistics to update
387 * @return the PDP statistics updated
388 * @throws PfModelException on errors updating PDP statistics
390 public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
391 throws PfModelException;
394 * Delete a PDP statistics.
396 * @param name the name of the policy to get, null to get all PDP statistics
397 * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp
398 * @return the PDP statistics deleted
399 * @throws PfModelException on errors deleting PDP statistics
401 public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Date timestamp) throws PfModelException;