Merge "Add serialization for Tosca Model"
[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.tosca.concepts.ToscaServiceTemplate;
28 import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
29 import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
30
31 /**
32  * This interface describes the operations that are provided to users and components for reading
33  * objects from and writing objects to the database.
34  *
35  * @author Liam Fallon (liam.fallon@est.tech)
36  */
37 public interface PolicyModelsProvider {
38
39     /**
40      * Get policy types.
41      *
42      * @param policyTypeKey the policy type key for the policy types to be retrieved. A null key
43      *        name returns all policy types. A null key version returns all versions of the policy
44      *        type name specified in the key.
45      * @return the policy types found
46      * @throws PfModelException on errors getting policy types
47      */
48     public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
49
50     /**
51      * Create policy types.
52      *
53      * @param serviceTemplate the service template containing the definition of the policy types to
54      *        be created
55      * @return the TOSCA service template containing the created policy types
56      * @throws PfModelException on errors creating policy types
57      */
58     public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
59             throws PfModelException;
60
61     /**
62      * Create policy types.
63      *
64      * @param serviceTemplate the service template containing the definition of the policy types to
65      *        be modified
66      * @return the TOSCA service template containing the modified policy types
67      * @throws PfModelException on errors updating policy types
68      */
69     public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
70             throws PfModelException;
71
72     /**
73      * Delete policy types.
74      *
75      * @param policyTypeKey the policy type key for the policy types to be deleted, if the version
76      *        of the key is null, all versions of the policy type are deleted.
77      * @return the TOSCA service template containing the policy types that were deleted
78      * @throws PfModelException on errors deleting policy types
79      */
80     public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException;
81
82     /**
83      * Get policies.
84      *
85      * @param policyKey the policy key for the policies to be retrieved. The parent name and version
86      *        must be specified. A null local name returns all policies for a parent policy type.
87      * @return the policies found
88      * @throws PfModelException on errors getting policies
89      */
90     public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
91
92     /**
93      * Create policies.
94      *
95      * @param serviceTemplate the service template containing the definitions of the new policies to
96      *        be created.
97      * @return the TOSCA service template containing the policy types that were created
98      * @throws PfModelException on errors creating policies
99      */
100     public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
101             throws PfModelException;
102
103
104     /**
105      * Update policies.
106      *
107      * @param serviceTemplate the service template containing the definitions of the policies to be
108      *        updated.
109      * @return the TOSCA service template containing the policies that were updated
110      * @throws PfModelException on errors updating policies
111      */
112     public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
113             throws PfModelException;
114
115     /**
116      * Delete policies.
117      *
118      * @param policyKey the policy key
119      * @return the TOSCA service template containing the policy types that were deleted
120      * @throws PfModelException on errors deleting policies
121      */
122     public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
123
124     /**
125      * Get legacy operational policy.
126      *
127      * @param policyId ID of the policy.
128      * @return the policies found
129      * @throws PfModelException on errors getting policies
130      */
131     public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
132
133     /**
134      * Create legacy operational policy.
135      *
136      * @param legacyOperationalPolicy the definition of the policy to be created.
137      * @return the created policy
138      * @throws PfModelException on errors creating policies
139      */
140     public LegacyOperationalPolicy createOperationalPolicy(
141             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
142
143     /**
144      * Update legacy operational policy.
145      *
146      * @param legacyOperationalPolicy the definition of the policy to be updated
147      * @return the updated policy
148      * @throws PfModelException on errors updating policies
149      */
150     public LegacyOperationalPolicy updateOperationalPolicy(
151             @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
152
153     /**
154      * Delete legacy operational policy.
155      *
156      * @param policyId ID of the policy.
157      * @return the deleted policy
158      * @throws PfModelException on errors deleting policies
159      */
160     public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
161
162     /**
163      * Get legacy guard policy.
164      *
165      * @param policyId ID of the policy.
166      * @return the policies found
167      * @throws PfModelException on errors getting policies
168      */
169     public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException;
170
171     /**
172      * Create legacy guard policy.
173      *
174      * @param legacyGuardPolicy the definition of the policy to be created.
175      * @return the created policy
176      * @throws PfModelException on errors creating policies
177      */
178     public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
179             throws PfModelException;
180
181     /**
182      * Update legacy guard policy.
183      *
184      * @param legacyGuardPolicy the definition of the policy to be updated
185      * @return the updated policy
186      * @throws PfModelException on errors updating policies
187      */
188     public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
189             throws PfModelException;
190
191     /**
192      * Delete legacy guard policy.
193      *
194      * @param policyId ID of the policy.
195      * @return the deleted policy
196      * @throws PfModelException on errors deleting policies
197      */
198     public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException;
199
200     /**
201      * Get PDP groups.
202      *
203      * @param somePdpGroupFilter a filter for the get
204      * @return the PDP groups found
205      * @throws PfModelException on errors getting PDP groups
206      */
207     public Object getPdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException;
208
209     /**
210      * Creates PDP groups.
211      *
212      * @param somePdpGroupSpecification a specification for the PDP group
213      * @throws PfModelException on errors creating PDP groups
214      */
215     public Object createPdpGroups(@NonNull final Object somePdpGroupSpecification) throws PfModelException;
216
217
218     /**
219      * Updates PDP groups.
220      *
221      * @param somePdpGroupSpecification a specification for the PDP group
222      * @throws PfModelException on errors updating PDP groups
223      */
224     public Object updatePdpGroups(@NonNull final Object somePdpGroupSpecification) throws PfModelException;
225
226     /**
227      * Delete PDP groups.
228      *
229      * @param somePdpGroupFilter a filter for the get
230      * @throws PfModelException on errors deleting PDP groups
231      */
232     public Object deletePdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException;
233 }