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.PfConceptKey;
28 import org.onap.policy.models.base.PfModelException;
29 import org.onap.policy.models.pdp.concepts.PdpGroups;
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;
33 import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
36 * This interface describes the operations that are provided to users and components for reading objects from and
37 * writing objects to the database.
39 * @author Liam Fallon (liam.fallon@est.tech)
41 public interface PolicyModelsProvider extends AutoCloseable {
43 * Open the policy model provider initializing whatever internal handling it needs.
45 * @throws PfModelException on errors opening the models provider
47 public void init() throws PfModelException;
52 * @param policyTypeKey the policy type key for the policy types to be retrieved. A null key name returns all policy
53 * types. A null key version returns all versions of the policy type name specified in the key.
54 * @return the policy types found
55 * @throws PfModelException on errors getting policy types
57 public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) 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 policyTypeKey the policy type key for the policy types to be deleted, if the version of the key is null,
83 * 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 must be specified.
93 * 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 be created.
103 * @return the TOSCA service template containing the policy types that were created
104 * @throws PfModelException on errors creating policies
106 public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
107 throws PfModelException;
113 * @param serviceTemplate the service template containing the definitions of the policies to be updated.
114 * @return the TOSCA service template containing the policies that were updated
115 * @throws PfModelException on errors updating policies
117 public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
118 throws PfModelException;
123 * @param policyKey the policy key
124 * @return the TOSCA service template containing the policy types that were deleted
125 * @throws PfModelException on errors deleting policies
127 public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
130 * Get legacy operational policy.
132 * @param policyId ID of the policy.
133 * @return the policies found
134 * @throws PfModelException on errors getting policies
136 public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
139 * Create legacy operational policy.
141 * @param legacyOperationalPolicy the definition of the policy to be created.
142 * @return the created policy
143 * @throws PfModelException on errors creating policies
145 public LegacyOperationalPolicy createOperationalPolicy(
146 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
149 * Update legacy operational policy.
151 * @param legacyOperationalPolicy the definition of the policy to be updated
152 * @return the updated policy
153 * @throws PfModelException on errors updating policies
155 public LegacyOperationalPolicy updateOperationalPolicy(
156 @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
159 * Delete legacy operational policy.
161 * @param policyId ID of the policy.
162 * @return the deleted policy
163 * @throws PfModelException on errors deleting policies
165 public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
168 * Get legacy guard policy.
170 * @param policyId ID of the policy.
171 * @return the policies found
172 * @throws PfModelException on errors getting policies
174 public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
177 * Create legacy guard policy.
179 * @param legacyGuardPolicy the definition of the policy to be created.
180 * @return the created policy
181 * @throws PfModelException on errors creating policies
183 public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
184 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
187 * Update legacy guard policy.
189 * @param legacyGuardPolicy the definition of the policy to be updated
190 * @return the updated policy
191 * @throws PfModelException on errors updating policies
193 public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
194 @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
197 * Delete legacy guard policy.
199 * @param policyId ID of the policy.
200 * @return the deleted policy
201 * @throws PfModelException on errors deleting policies
203 public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
204 throws PfModelException;
209 * @param pdpGroupFilter a filter for the get
210 * @return the PDP groups found
211 * @throws PfModelException on errors getting PDP groups
213 public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
216 * Creates PDP groups.
218 * @param pdpGroups a specification of the PDP groups to create
219 * @return the PDP groups created
220 * @throws PfModelException on errors creating PDP groups
222 public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
225 * Updates PDP groups.
227 * @param pdpGroups a specification of the PDP groups to update
228 * @return the PDP groups updated
229 * @throws PfModelException on errors updating PDP groups
231 public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
236 * @param pdpGroupFilter a filter for the get
237 * @return the PDP groups deleted
238 * @throws PfModelException on errors deleting PDP groups
240 public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;