Merge "Fix policy-models-pdp dependency"
[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.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;
33
34 /**
35  * This interface describes the operations that are provided to users and components for reading objects from and
36  * writing objects to the database.
37  *
38  * @author Liam Fallon (liam.fallon@est.tech)
39  */
40 public interface PolicyModelsProvider extends AutoCloseable {
41     /**
42      * Open the policy model provider initializing whatever internal handling it needs.
43      *
44      * @throws PfModelException on errors opening the models provider
45      */
46     public void init() throws PfModelException;
47
48     /**
49      * Get policy types.
50      *
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
55      */
56     public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
57             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 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
86      */
87     public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
88             throws PfModelException;
89
90     /**
91      * Get policies.
92      *
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
97      */
98     public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
99             throws PfModelException;
100
101     /**
102      * Create policies.
103      *
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
107      */
108     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
109             throws PfModelException;
110
111
112     /**
113      * Update policies.
114      *
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
118      */
119     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
120             throws PfModelException;
121
122     /**
123      * Delete policies.
124      *
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
129      */
130     public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
131             throws PfModelException;
132
133     /**
134      * Get legacy operational policy.
135      *
136      * @param policyId ID of the policy.
137      * @return the policies found
138      * @throws PfModelException on errors getting policies
139      */
140     public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
141
142     /**
143      * Create legacy operational policy.
144      *
145      * @param legacyOperationalPolicy the definition of the policy to be created.
146      * @return the created policy
147      * @throws PfModelException on errors creating policies
148      */
149     public LegacyOperationalPolicy createOperationalPolicy(
150             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
151
152     /**
153      * Update legacy operational policy.
154      *
155      * @param legacyOperationalPolicy the definition of the policy to be updated
156      * @return the updated policy
157      * @throws PfModelException on errors updating policies
158      */
159     public LegacyOperationalPolicy updateOperationalPolicy(
160             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
161
162     /**
163      * Delete legacy operational policy.
164      *
165      * @param policyId ID of the policy.
166      * @return the deleted policy
167      * @throws PfModelException on errors deleting policies
168      */
169     public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
170
171     /**
172      * Get legacy guard policy.
173      *
174      * @param policyId ID of the policy.
175      * @return the policies found
176      * @throws PfModelException on errors getting policies
177      */
178     public Map<String, LegacyGuardPolicyOutput> getGuardPolicy(@NonNull final String policyId) throws PfModelException;
179
180     /**
181      * Create legacy guard policy.
182      *
183      * @param legacyGuardPolicy the definition of the policy to be created.
184      * @return the created policy
185      * @throws PfModelException on errors creating policies
186      */
187     public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
188             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
189
190     /**
191      * Update legacy guard policy.
192      *
193      * @param legacyGuardPolicy the definition of the policy to be updated
194      * @return the updated policy
195      * @throws PfModelException on errors updating policies
196      */
197     public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
198             @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException;
199
200     /**
201      * Delete legacy guard policy.
202      *
203      * @param policyId ID of the policy.
204      * @return the deleted policy
205      * @throws PfModelException on errors deleting policies
206      */
207     public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(@NonNull final String policyId)
208             throws PfModelException;
209
210     /**
211      * Get PDP groups.
212      *
213      * @param pdpGroupFilter a filter for the get
214      * @return the PDP groups found
215      * @throws PfModelException on errors getting PDP groups
216      */
217     public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
218
219     /**
220      * Creates PDP groups.
221      *
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
225      */
226     public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
227
228     /**
229      * Updates PDP groups.
230      *
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
234      */
235     public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
236
237     /**
238      * Delete PDP groups.
239      *
240      * @param pdpGroupFilter a filter for the get
241      * @return the PDP groups deleted
242      * @throws PfModelException on errors deleting PDP groups
243      */
244     public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
245 }