Add support for legacy guard policies
[policy/models.git] / models-provider / src / main / java / org / onap / policy / models / provider / PolicyModelsProvider.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.models.provider;
22
23 import java.util.Map;
24
25 import lombok.NonNull;
26
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;
34
35 /**
36  * This interface describes the operations that are provided to users and components for reading objects from and
37  * writing objects to the database.
38  *
39  * @author Liam Fallon (liam.fallon@est.tech)
40  */
41 public interface PolicyModelsProvider extends AutoCloseable {
42     /**
43      * Open the policy model provider initializing whatever internal handling it needs.
44      *
45      * @throws PfModelException on errors opening the models provider
46      */
47     public void init() throws PfModelException;
48
49     /**
50      * Get policy types.
51      *
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
56      */
57     public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
58
59     /**
60      * Create policy types.
61      *
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
65      */
66     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
67             throws PfModelException;
68
69     /**
70      * Create policy types.
71      *
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
75      */
76     public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
77             throws PfModelException;
78
79     /**
80      * Delete policy types.
81      *
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
86      */
87     public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
88
89     /**
90      * Get policies.
91      *
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
96      */
97     public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
98
99     /**
100      * Create policies.
101      *
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
105      */
106     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
107             throws PfModelException;
108
109
110     /**
111      * Update policies.
112      *
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
116      */
117     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
118             throws PfModelException;
119
120     /**
121      * Delete policies.
122      *
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
126      */
127     public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
128
129     /**
130      * Get legacy operational policy.
131      *
132      * @param policyId ID of the policy.
133      * @return the policies found
134      * @throws PfModelException on errors getting policies
135      */
136     public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
137
138     /**
139      * Create legacy operational policy.
140      *
141      * @param legacyOperationalPolicy the definition of the policy to be created.
142      * @return the created policy
143      * @throws PfModelException on errors creating policies
144      */
145     public LegacyOperationalPolicy createOperationalPolicy(
146             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
147
148     /**
149      * Update legacy operational policy.
150      *
151      * @param legacyOperationalPolicy the definition of the policy to be updated
152      * @return the updated policy
153      * @throws PfModelException on errors updating policies
154      */
155     public LegacyOperationalPolicy updateOperationalPolicy(
156             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
157
158     /**
159      * Delete legacy operational policy.
160      *
161      * @param policyId ID of the policy.
162      * @return the deleted policy
163      * @throws PfModelException on errors deleting policies
164      */
165     public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
166
167     /**
168      * Get legacy guard policy.
169      *
170      * @param policyId ID of the policy.
171      * @return the policies found
172      * @throws PfModelException on errors getting policies
173      */
174     public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
175
176     /**
177      * Create legacy guard policy.
178      *
179      * @param legacyGuardPolicy the definition of the policy to be created.
180      * @return the created policy
181      * @throws PfModelException on errors creating policies
182      */
183     public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
184             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
185
186     /**
187      * Update legacy guard policy.
188      *
189      * @param legacyGuardPolicy the definition of the policy to be updated
190      * @return the updated policy
191      * @throws PfModelException on errors updating policies
192      */
193     public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
194             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
195
196     /**
197      * Delete legacy guard policy.
198      *
199      * @param policyId ID of the policy.
200      * @return the deleted policy
201      * @throws PfModelException on errors deleting policies
202      */
203     public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
204             throws PfModelException;
205
206     /**
207      * Get PDP groups.
208      *
209      * @param pdpGroupFilter a filter for the get
210      * @return the PDP groups found
211      * @throws PfModelException on errors getting PDP groups
212      */
213     public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
214
215     /**
216      * Creates PDP groups.
217      *
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
221      */
222     public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
223
224     /**
225      * Updates PDP groups.
226      *
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
230      */
231     public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
232
233     /**
234      * Delete PDP groups.
235      *
236      * @param pdpGroupFilter a filter for the get
237      * @return the PDP groups deleted
238      * @throws PfModelException on errors deleting PDP groups
239      */
240     public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
241 }