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;
25 import lombok.NonNull;
27 import org.onap.policy.models.base.PfModelException;
28 import org.onap.policy.models.pdp.concepts.PdpGroups;
29 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
30 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
31 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
32 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
35 * This interface describes the operations that are provided to users and components for reading objects from and
36 * writing objects to the database.
38 * @author Liam Fallon (liam.fallon@est.tech)
40 public interface PolicyModelsProvider extends AutoCloseable {
42 * Open the policy model provider initializing whatever internal handling it needs.
44 * @throws PfModelException on errors opening the models provider
46 public void init() throws PfModelException;
51 * @param name the name of the policy type to get.
52 * @param version the version of the policy type to get.
53 * @return the policy types found
54 * @throws PfModelException on errors getting policy types
56 public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
57 throws PfModelException;
60 * Create policy types.
62 * @param serviceTemplate the service template containing the definition of the policy types to be created
63 * @return the TOSCA service template containing the created policy types
64 * @throws PfModelException on errors creating policy types
66 public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
67 throws PfModelException;
70 * Create policy types.
72 * @param serviceTemplate the service template containing the definition of the policy types to be modified
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 name the name of the policy type to delete.
83 * @param version the version of the policy type to delete.
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 String name, @NonNull final String version)
88 throws PfModelException;
93 * @param name the name of the policy to get.
94 * @param version the version of the policy to get.
95 * @return the policies found
96 * @throws PfModelException on errors getting policies
98 public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
99 throws PfModelException;
104 * @param serviceTemplate the service template containing the definitions of the new policies to be created.
105 * @return the TOSCA service template containing the policy types that were created
106 * @throws PfModelException on errors creating policies
108 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
109 throws PfModelException;
115 * @param serviceTemplate the service template containing the definitions of the policies to be updated.
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 name the name of the policy to delete.
126 * @param version the version of the policy to delete.
127 * @return the TOSCA service template containing the policy types that were deleted
128 * @throws PfModelException on errors deleting policies
130 public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
131 throws PfModelException;
134 * Get legacy operational policy.
136 * @param policyId ID of the policy.
137 * @return the policies found
138 * @throws PfModelException on errors getting policies
140 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
143 * Create legacy operational policy.
145 * @param legacyOperationalPolicy the definition of the policy to be created.
146 * @return the created policy
147 * @throws PfModelException on errors creating policies
149 public LegacyOperationalPolicy createOperationalPolicy(
150 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
153 * Update legacy operational policy.
155 * @param legacyOperationalPolicy the definition of the policy to be updated
156 * @return the updated policy
157 * @throws PfModelException on errors updating policies
159 public LegacyOperationalPolicy updateOperationalPolicy(
160 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
163 * Delete legacy operational policy.
165 * @param policyId ID of the policy.
166 * @return the deleted policy
167 * @throws PfModelException on errors deleting policies
169 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
172 * Get legacy guard policy.
174 * @param policyId ID of the policy.
175 * @return the policies found
176 * @throws PfModelException on errors getting policies
178 public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
181 * Create legacy guard policy.
183 * @param legacyGuardPolicy the definition of the policy to be created.
184 * @return the created policy
185 * @throws PfModelException on errors creating policies
187 public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
188 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
191 * Update legacy guard policy.
193 * @param legacyGuardPolicy the definition of the policy to be updated
194 * @return the updated policy
195 * @throws PfModelException on errors updating policies
197 public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
198 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
201 * Delete legacy guard policy.
203 * @param policyId ID of the policy.
204 * @return the deleted policy
205 * @throws PfModelException on errors deleting policies
207 public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
208 throws PfModelException;
213 * @param pdpGroupFilter a filter for the get
214 * @return the PDP groups found
215 * @throws PfModelException on errors getting PDP groups
217 public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
220 * Creates PDP groups.
222 * @param pdpGroups a specification of the PDP groups to create
223 * @return the PDP groups created
224 * @throws PfModelException on errors creating PDP groups
226 public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
229 * Updates PDP groups.
231 * @param pdpGroups a specification of the PDP groups to update
232 * @return the PDP groups updated
233 * @throws PfModelException on errors updating PDP groups
235 public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
240 * @param pdpGroupFilter a filter for the get
241 * @return the PDP groups deleted
242 * @throws PfModelException on errors deleting PDP groups
244 public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;