Merge "Add input tosca examples for guard frequency"
[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 lombok.NonNull;
24
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;
31
32 /**
33  * This interface describes the operations that are provided to users and components for reading
34  * objects from and writing objects to the database.
35  *
36  * @author Liam Fallon (liam.fallon@est.tech)
37  */
38 public interface PolicyModelsProvider extends AutoCloseable {
39     /**
40      * Open the policy model provider initializing whatever internal handling it needs.
41      *
42      * @throws PfModelException on errors opening the models provider
43      */
44     public void init() throws PfModelException;
45
46     /**
47      * Get policy types.
48      *
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
54      */
55     public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
56
57     /**
58      * Create policy types.
59      *
60      * @param serviceTemplate the service template containing the definition of the policy types to
61      *        be created
62      * @return the TOSCA service template containing the created policy types
63      * @throws PfModelException on errors creating policy types
64      */
65     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
66             throws PfModelException;
67
68     /**
69      * Create policy types.
70      *
71      * @param serviceTemplate the service template containing the definition of the policy types to
72      *        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
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
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
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
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
103      *        be created.
104      * @return the TOSCA service template containing the policy types that were created
105      * @throws PfModelException on errors creating policies
106      */
107     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
108             throws PfModelException;
109
110
111     /**
112      * Update policies.
113      *
114      * @param serviceTemplate the service template containing the definitions of the policies to be
115      *        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 policyKey the policy key
126      * @return the TOSCA service template containing the policy types that were deleted
127      * @throws PfModelException on errors deleting policies
128      */
129     public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
130
131     /**
132      * Get legacy operational policy.
133      *
134      * @param policyId ID of the policy.
135      * @return the policies found
136      * @throws PfModelException on errors getting policies
137      */
138     public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
139
140     /**
141      * Create legacy operational policy.
142      *
143      * @param legacyOperationalPolicy the definition of the policy to be created.
144      * @return the created policy
145      * @throws PfModelException on errors creating policies
146      */
147     public LegacyOperationalPolicy createOperationalPolicy(
148             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
149
150     /**
151      * Update legacy operational policy.
152      *
153      * @param legacyOperationalPolicy the definition of the policy to be updated
154      * @return the updated policy
155      * @throws PfModelException on errors updating policies
156      */
157     public LegacyOperationalPolicy updateOperationalPolicy(
158             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
159
160     /**
161      * Delete legacy operational policy.
162      *
163      * @param policyId ID of the policy.
164      * @return the deleted policy
165      * @throws PfModelException on errors deleting policies
166      */
167     public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
168
169     /**
170      * Get legacy guard policy.
171      *
172      * @param policyId ID of the policy.
173      * @return the policies found
174      * @throws PfModelException on errors getting policies
175      */
176     public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException;
177
178     /**
179      * Create legacy guard policy.
180      *
181      * @param legacyGuardPolicy the definition of the policy to be created.
182      * @return the created policy
183      * @throws PfModelException on errors creating policies
184      */
185     public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
186             throws PfModelException;
187
188     /**
189      * Update legacy guard policy.
190      *
191      * @param legacyGuardPolicy the definition of the policy to be updated
192      * @return the updated policy
193      * @throws PfModelException on errors updating policies
194      */
195     public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
196             throws PfModelException;
197
198     /**
199      * Delete legacy guard policy.
200      *
201      * @param policyId ID of the policy.
202      * @return the deleted policy
203      * @throws PfModelException on errors deleting policies
204      */
205     public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException;
206
207     /**
208      * Get PDP groups.
209      *
210      * @param pdpGroupFilter a filter for the get
211      * @return the PDP groups found
212      * @throws PfModelException on errors getting PDP groups
213      */
214     public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
215
216     /**
217      * Creates PDP groups.
218      *
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
222      */
223     public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
224
225     /**
226      * Updates PDP groups.
227      *
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
231      */
232     public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
233
234     /**
235      * Delete PDP groups.
236      *
237      * @param pdpGroupFilter a filter for the get
238      * @return the PDP groups deleted
239      * @throws PfModelException on errors deleting PDP groups
240      */
241     public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
242 }