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.List;
26 import lombok.NonNull;
28 import org.onap.policy.models.base.PfModelException;
29 import org.onap.policy.models.pdp.concepts.Pdp;
30 import org.onap.policy.models.pdp.concepts.PdpGroup;
31 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
32 import org.onap.policy.models.pdp.concepts.PdpStatistics;
33 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
35 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
36 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
38 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
39 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
40 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
41 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
44 * This interface describes the operations that are provided to users and components for reading objects from and
45 * writing objects to the database.
47 * @author Liam Fallon (liam.fallon@est.tech)
49 public interface PolicyModelsProvider extends AutoCloseable {
51 * Open the policy model provider initializing whatever internal handling it needs.
53 * @throws PfModelException on errors opening the models provider
55 public void init() throws PfModelException;
58 public void close() throws PfModelException;
63 * @param name the name of the policy type to get, set to null to get all policy types
64 * @param version the version of the policy type to get, set to null to get all versions
65 * @return the policy types found
66 * @throws PfModelException on errors getting policy types
68 public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException;
73 * @param name the name of the policy type to get, set to null to get all policy types
74 * @param version the version of the policy type to get, set to null to get all versions
75 * @return the policy types found
76 * @throws PfModelException on errors getting policy types
78 public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
81 * Get filtered policy types.
83 * @param filter the filter for the policy types to get
84 * @return the policy types found
85 * @throws PfModelException on errors getting policy types
87 public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull final ToscaPolicyTypeFilter filter)
88 throws PfModelException;
91 * Get filtered policy types.
93 * @param filter the filter for the policy types to get
94 * @return the policy types found
95 * @throws PfModelException on errors getting policy types
97 public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull final ToscaPolicyTypeFilter filter)
98 throws PfModelException;
101 * Create policy types.
103 * @param serviceTemplate the service template containing the definition of the policy types to be created
104 * @return the TOSCA service template containing the created policy types
105 * @throws PfModelException on errors creating policy types
107 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
108 throws PfModelException;
111 * Create policy types.
113 * @param serviceTemplate the service template containing the definition of the policy types to be modified
114 * @return the TOSCA service template containing the modified policy types
115 * @throws PfModelException on errors updating policy types
117 public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
118 throws PfModelException;
121 * Delete policy type.
123 * @param name the name of the policy type to delete.
124 * @param version the version of the policy type to delete.
125 * @return the TOSCA service template containing the policy type that was deleted
126 * @throws PfModelException on errors deleting policy types
128 public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
129 throws PfModelException;
134 * @param name the name of the policy to get, null to get all policies
135 * @param version the version of the policy to get, null to get all versions of a policy
136 * @return the policies found
137 * @throws PfModelException on errors getting policies
139 public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
144 * @param name the name of the policy to get, null to get all policies
145 * @param version the version of the policy to get, null to get all versions of a policy
146 * @return the policies found
147 * @throws PfModelException on errors getting policies
149 public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
152 * Get filtered policies.
154 * @param filter the filter for the policies to get
155 * @return the policies found
156 * @throws PfModelException on errors getting policies
158 public ToscaServiceTemplate getFilteredPolicies(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
161 * Get filtered policies.
163 * @param filter the filter for the policies to get
164 * @return the policies found
165 * @throws PfModelException on errors getting policies
167 public List<ToscaPolicy> getFilteredPolicyList(@NonNull final ToscaPolicyFilter filter) throws PfModelException;
172 * @param serviceTemplate the service template containing the definitions of the new policies to be created.
173 * @return the TOSCA service template containing the policy types that were created
174 * @throws PfModelException on errors creating policies
176 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
177 throws PfModelException;
182 * @param serviceTemplate the service template containing the definitions of the policies to be updated.
183 * @return the TOSCA service template containing the policies that were updated
184 * @throws PfModelException on errors updating policies
186 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
187 throws PfModelException;
192 * @param name the name of the policy to delete.
193 * @param version the version of the policy to delete.
194 * @return the TOSCA service template containing the policy that was deleted
195 * @throws PfModelException on errors deleting a policy
197 public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
198 throws PfModelException;
201 * Get legacy operational policy.
203 * @param policyId ID of the policy.
204 * @return the policies found
205 * @throws PfModelException on errors getting policies
207 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
210 * Create legacy operational policy.
212 * @param legacyOperationalPolicy the definition of the policy to be created.
213 * @return the created policy
214 * @throws PfModelException on errors creating policies
216 public LegacyOperationalPolicy createOperationalPolicy(
217 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
220 * Update legacy operational policy.
222 * @param legacyOperationalPolicy the definition of the policy to be updated
223 * @return the updated policy
224 * @throws PfModelException on errors updating policies
226 public LegacyOperationalPolicy updateOperationalPolicy(
227 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
230 * Delete legacy operational policy.
232 * @param policyId ID of the policy.
233 * @return the deleted policy
234 * @throws PfModelException on errors deleting policies
236 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
239 * Get legacy guard policy.
241 * @param policyId ID of the policy.
242 * @return the policies found
243 * @throws PfModelException on errors getting policies
245 public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
248 * Create legacy guard policy.
250 * @param legacyGuardPolicy the definition of the policy to be created.
251 * @return the created policy
252 * @throws PfModelException on errors creating policies
254 public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
255 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
258 * Update legacy guard policy.
260 * @param legacyGuardPolicy the definition of the policy to be updated
261 * @return the updated policy
262 * @throws PfModelException on errors updating policies
264 public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
265 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
268 * Delete legacy guard policy.
270 * @param policyId ID of the policy.
271 * @return the deleted policy
272 * @throws PfModelException on errors deleting policies
274 public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
275 throws PfModelException;
280 * @param name the name of the policy to get, null to get all PDP groups
281 * @param version the version of the policy to get, null to get all versions of a PDP group
282 * @return the PDP groups found
283 * @throws PfModelException on errors getting PDP groups
285 public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException;
288 * Get filtered PDP groups.
290 * @param filter the filter for the PDP groups to get
291 * @return the PDP groups found
292 * @throws PfModelException on errors getting policies
294 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
297 * Creates PDP groups.
299 * @param pdpGroups a specification of the PDP groups to create
300 * @return the PDP groups created
301 * @throws PfModelException on errors creating PDP groups
303 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
306 * Updates PDP groups.
308 * @param pdpGroups a specification of the PDP groups to update
309 * @return the PDP groups updated
310 * @throws PfModelException on errors updating PDP groups
312 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
315 * Update a PDP subgroup.
317 * @param pdpGroupName the name of the PDP group of the PDP subgroup
318 * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
319 * @param pdpSubGroup the PDP subgroup to be updated
320 * @throws PfModelException on errors updating PDP subgroups
322 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
323 @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException;
328 * @param pdpGroupName the name of the PDP group of the PDP subgroup
329 * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
330 * @param pdpSubGroup the PDP subgroup to be updated
331 * @param pdp the PDP to be updated
332 * @throws PfModelException on errors updating PDP subgroups
334 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
335 @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) throws PfModelException;
338 * Delete a PDP group.
340 * @param name the name of the policy to get, null to get all PDP groups
341 * @param version the version of the policy to get, null to get all versions of a PDP group
342 * @return the PDP group deleted
343 * @throws PfModelException on errors deleting PDP groups
345 public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException;
348 * Get PDP statistics.
350 * @param name the name of the PDP group to get statistics for, null to get all PDP groups
351 * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
352 * @return the statistics found
353 * @throws PfModelException on errors getting statistics
355 public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException;
358 * Update PDP statistics for a PDP.
360 * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
361 * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
362 * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
363 * @param pdpInstanceId the instance ID of the PDP to update statistics for
364 * @throws PfModelException on errors updating statistics
366 public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
367 @NonNull final String pdpType, @NonNull final String pdpInstanceId,
368 @NonNull final PdpStatistics pdppStatistics) throws PfModelException;