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 lombok.NonNull;
25 import org.onap.policy.models.base.PfConceptKey;
26 import org.onap.policy.models.base.PfModelException;
27 import org.onap.policy.models.pap.concepts.PdpGroups;
28 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
29 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
30 import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
33 * This interface describes the operations that are provided to users and components for reading
34 * objects from and writing objects to the database.
36 * @author Liam Fallon (liam.fallon@est.tech)
38 public interface PolicyModelsProvider extends AutoCloseable {
40 * Open the policy model provider initializing whatever internal handling it needs.
42 * @throws PfModelException on errors opening the models provider
44 public void init() throws PfModelException;
49 * @param policyTypeKey the policy type key for the policy types to be retrieved. A null key
50 * name returns all policy types. A null key version returns all versions of the policy
51 * type name specified in the key.
52 * @return the policy types found
53 * @throws PfModelException on errors getting policy types
55 public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
58 * Create policy types.
60 * @param serviceTemplate the service template containing the definition of the policy types to
62 * @return the TOSCA service template containing the created policy types
63 * @throws PfModelException on errors creating policy types
65 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
66 throws PfModelException;
69 * Create policy types.
71 * @param serviceTemplate the service template containing the definition of the policy types to
73 * @return the TOSCA service template containing the modified policy types
74 * @throws PfModelException on errors updating policy types
76 public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
77 throws PfModelException;
80 * Delete policy types.
82 * @param policyTypeKey the policy type key for the policy types to be deleted, if the version
83 * of the key is null, all versions of the policy type are deleted.
84 * @return the TOSCA service template containing the policy types that were deleted
85 * @throws PfModelException on errors deleting policy types
87 public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
92 * @param policyKey the policy key for the policies to be retrieved. The parent name and version
93 * must be specified. A null local name returns all policies for a parent policy type.
94 * @return the policies found
95 * @throws PfModelException on errors getting policies
97 public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
102 * @param serviceTemplate the service template containing the definitions of the new policies to
104 * @return the TOSCA service template containing the policy types that were created
105 * @throws PfModelException on errors creating policies
107 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
108 throws PfModelException;
114 * @param serviceTemplate the service template containing the definitions of the policies to be
116 * @return the TOSCA service template containing the policies that were updated
117 * @throws PfModelException on errors updating policies
119 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
120 throws PfModelException;
125 * @param policyKey the policy key
126 * @return the TOSCA service template containing the policy types that were deleted
127 * @throws PfModelException on errors deleting policies
129 public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
132 * Get legacy operational policy.
134 * @param policyId ID of the policy.
135 * @return the policies found
136 * @throws PfModelException on errors getting policies
138 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
141 * Create legacy operational policy.
143 * @param legacyOperationalPolicy the definition of the policy to be created.
144 * @return the created policy
145 * @throws PfModelException on errors creating policies
147 public LegacyOperationalPolicy createOperationalPolicy(
148 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
151 * Update legacy operational policy.
153 * @param legacyOperationalPolicy the definition of the policy to be updated
154 * @return the updated policy
155 * @throws PfModelException on errors updating policies
157 public LegacyOperationalPolicy updateOperationalPolicy(
158 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
161 * Delete legacy operational policy.
163 * @param policyId ID of the policy.
164 * @return the deleted policy
165 * @throws PfModelException on errors deleting policies
167 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
170 * Get legacy guard policy.
172 * @param policyId ID of the policy.
173 * @return the policies found
174 * @throws PfModelException on errors getting policies
176 public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException;
179 * Create legacy guard policy.
181 * @param legacyGuardPolicy the definition of the policy to be created.
182 * @return the created policy
183 * @throws PfModelException on errors creating policies
185 public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
186 throws PfModelException;
189 * Update legacy guard policy.
191 * @param legacyGuardPolicy the definition of the policy to be updated
192 * @return the updated policy
193 * @throws PfModelException on errors updating policies
195 public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
196 throws PfModelException;
199 * Delete legacy guard policy.
201 * @param policyId ID of the policy.
202 * @return the deleted policy
203 * @throws PfModelException on errors deleting policies
205 public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException;
210 * @param pdpGroupFilter a filter for the get
211 * @return the PDP groups found
212 * @throws PfModelException on errors getting PDP groups
214 public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
217 * Creates PDP groups.
219 * @param pdpGroups a specification of the PDP groups to create
220 * @return the PDP groups created
221 * @throws PfModelException on errors creating PDP groups
223 public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
226 * Updates PDP groups.
228 * @param pdpGroups a specification of the PDP groups to update
229 * @return the PDP groups updated
230 * @throws PfModelException on errors updating PDP groups
232 public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
237 * @param pdpGroupFilter a filter for the get
238 * @return the PDP groups deleted
239 * @throws PfModelException on errors deleting PDP groups
241 public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;