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 * @param policyVersion version of the policy, set to null to get the latest policy
205 * @return the policies found
206 * @throws PfModelException on errors getting policies
208 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId, final String policyVersion)
209 throws PfModelException;
212 * Create legacy operational policy.
214 * @param legacyOperationalPolicy the definition of the policy to be created.
215 * @return the created policy
216 * @throws PfModelException on errors creating policies
218 public LegacyOperationalPolicy createOperationalPolicy(
219 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
222 * Update legacy operational policy.
224 * @param legacyOperationalPolicy the definition of the policy to be updated
225 * @return the updated policy
226 * @throws PfModelException on errors updating policies
228 public LegacyOperationalPolicy updateOperationalPolicy(
229 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
232 * Delete legacy operational policy.
234 * @param policyId ID of the policy.
235 * @param policyVersion version of the policy, set to null to get the latest policy
236 * @return the deleted policy
237 * @throws PfModelException on errors deleting policies
239 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId,
240 @NonNull final String policyVersion) throws PfModelException;
243 * Get legacy guard policy.
245 * @param policyId ID of the policy
246 * @param policyVersion version of the policy, set to null to get the latest policy
247 * @return the policies found
248 * @throws PfModelException on errors getting policies
250 public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId,
251 final String policyVersion) throws PfModelException;
254 * Create legacy guard policy.
256 * @param legacyGuardPolicy the definition of the policy to be created.
257 * @return the created policy
258 * @throws PfModelException on errors creating policies
260 public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
261 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
264 * Update legacy guard policy.
266 * @param legacyGuardPolicy the definition of the policy to be updated
267 * @return the updated policy
268 * @throws PfModelException on errors updating policies
270 public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
271 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
274 * Delete legacy guard policy.
276 * @param policyId ID of the policy.
277 * @param policyVersion version of the policy, set to null to get the latest policy
278 * @return the deleted policy
279 * @throws PfModelException on errors deleting policies
281 public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId,
282 @NonNull final String policyVersion) throws PfModelException;
287 * @param name the name of the policy to get, null to get all PDP groups
288 * @return the PDP groups found
289 * @throws PfModelException on errors getting PDP groups
291 public List<PdpGroup> getPdpGroups(final String name) throws PfModelException;
294 * Get filtered PDP groups.
296 * @param filter the filter for the PDP groups to get
297 * @return the PDP groups found
298 * @throws PfModelException on errors getting policies
300 public List<PdpGroup> getFilteredPdpGroups(@NonNull final PdpGroupFilter filter) throws PfModelException;
303 * Creates PDP groups.
305 * @param pdpGroups a specification of the PDP groups to create
306 * @return the PDP groups created
307 * @throws PfModelException on errors creating PDP groups
309 public List<PdpGroup> createPdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
312 * Updates PDP groups.
314 * @param pdpGroups a specification of the PDP groups to update
315 * @return the PDP groups updated
316 * @throws PfModelException on errors updating PDP groups
318 public List<PdpGroup> updatePdpGroups(@NonNull final List<PdpGroup> pdpGroups) throws PfModelException;
321 * Update a PDP subgroup.
323 * @param pdpGroupName the name of the PDP group of the PDP subgroup
324 * @param pdpSubGroup the PDP subgroup to be updated
325 * @throws PfModelException on errors updating PDP subgroups
327 public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup)
328 throws PfModelException;
333 * @param pdpGroupName the name of the PDP group of the PDP subgroup
334 * @param pdpSubGroup the PDP subgroup to be updated
335 * @param pdp the PDP to be updated
336 * @throws PfModelException on errors updating PDP subgroups
338 public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp)
339 throws PfModelException;
342 * Delete a PDP group.
344 * @param name the name of the policy to get, null to get all PDP groups
345 * @return the PDP group deleted
346 * @throws PfModelException on errors deleting PDP groups
348 public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
351 * Get PDP statistics.
353 * @param name the name of the PDP group to get statistics for, null to get all PDP groups
354 * @return the statistics found
355 * @throws PfModelException on errors getting statistics
357 public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException;
360 * Update PDP statistics for a PDP.
362 * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
363 * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
364 * @param pdpInstanceId the instance ID of the PDP to update statistics for
365 * @param pdpStatistics the PDP statistics
366 * @throws PfModelException on errors updating statistics
368 public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpType,
369 @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException;