Merge "Remove pdpType from PdpUpdate"
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / persistence / provider / PdpProvider.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.pdp.persistence.provider;
22
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import lombok.NonNull;
29
30 import org.apache.commons.lang3.tuple.Pair;
31 import org.onap.policy.models.base.PfModelException;
32 import org.onap.policy.models.dao.PfDao;
33 import org.onap.policy.models.pdp.concepts.PdpGroup;
34 import org.onap.policy.models.pdp.concepts.PdpGroups;
35 import org.onap.policy.models.pdp.concepts.PdpStatistics;
36 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
38
39 /**
40  * This class provides the provision of information on PAP concepts in the database to callers.
41  *
42  * @author Liam Fallon (liam.fallon@est.tech)
43  */
44 public class PdpProvider {
45     /**
46      * Get PDP groups.
47      *
48      * @param dao the DAO to use to access the database
49      * @param name the name of the policy to get, null to get all PDP groups
50      * @param version the version of the policy to get, null to get all versions of a PDP group
51      * @return the PDP groups found
52      * @throws PfModelException on errors getting PDP groups
53      */
54     public PdpGroups getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
55             throws PfModelException {
56         return new PdpGroups();
57     }
58
59     /**
60      * Get latest PDP Groups.
61      *
62      * @param dao the DAO to use to access the database
63      * @param name the name of the PDP group to get, null to get all PDP groups
64      * @return the PDP groups found
65      * @throws PfModelException on errors getting policies
66      */
67     public PdpGroups getLatestPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
68         return new PdpGroups();
69     }
70
71     /**
72      * Get a filtered list of PDP groups.
73      *
74      * @param dao the DAO to use to access the database
75      * @param pdpType The PDP type filter for the returned PDP groups
76      * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
77      * @return the PDP groups found
78      */
79     public PdpGroups getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpType,
80             @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
81         return new PdpGroups();
82     }
83
84     /**
85      * Creates PDP groups.
86      *
87      * @param dao the DAO to use to access the database
88      * @param pdpGroups a specification of the PDP groups to create
89      * @return the PDP groups created
90      * @throws PfModelException on errors creating PDP groups
91      */
92     public PdpGroups createPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups)
93             throws PfModelException {
94         return new PdpGroups();
95     }
96
97     /**
98      * Updates PDP groups.
99      *
100      * @param dao the DAO to use to access the database
101      * @param pdpGroups a specification of the PDP groups to update
102      * @return the PDP groups updated
103      * @throws PfModelException on errors updating PDP groups
104      */
105     public PdpGroups updatePdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups)
106             throws PfModelException {
107         return new PdpGroups();
108     }
109
110
111     /**
112      * Update a PDP subgroup.
113      *
114      * @param dao the DAO to use to access the database
115      * @param pdpGroupName the name of the PDP group of the PDP subgroup
116      * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
117      * @param pdpSubGroup the PDP subgroup to be updated
118      * @throws PfModelException on errors updating PDP subgroups
119      */
120     public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
121             @NonNull final String pdpGroupVersion, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
122         // Not implemented yet
123     }
124
125     /**
126      * Delete a PDP group.
127      *
128      * @param dao the DAO to use to access the database
129      * @param name the name of the policy to get, null to get all PDP groups
130      * @param version the version of the policy to get, null to get all versions of a PDP group
131      * @return the PDP group deleted
132      * @throws PfModelException on errors deleting PDP groups
133      */
134     public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name, @NonNull final String version)
135             throws PfModelException {
136         return new PdpGroup();
137
138     }
139
140     /**
141      * Get PDP statistics.
142      *
143      * @param dao the DAO to use to access the database
144      * @param name the name of the PDP group to get statistics for, null to get all PDP groups
145      * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
146      * @return the statistics found
147      * @throws PfModelException on errors getting statistics
148      */
149     public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version)
150             throws PfModelException {
151         return new ArrayList<>();
152     }
153
154     /**
155      * Update PDP statistics for a PDP.
156      *
157      * @param dao the DAO to use to access the database
158      * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
159      * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
160      * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
161      * @param pdpInstanceId the instance ID of the PDP to update statistics for
162      * @throws PfModelException on errors updating statistics
163      */
164     public void updatePdpStatistics(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
165             @NonNull final String pdpGroupVersion, @NonNull final String pdpType, @NonNull final String pdpInstanceId,
166             @NonNull final PdpStatistics pdppStatistics)  throws PfModelException {
167         // Not implemented yet
168     }
169
170     /**
171      * Get deployed policies.
172      *
173      * @param dao the DAO to use to access the database
174      * @param name the name of the policy to get, null to get all policies
175      * @return the policies deployed as a map of policy lists keyed by PDP group
176      * @throws PfModelException on errors getting policies
177      */
178     public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(@NonNull final PfDao dao, final String name)
179             throws PfModelException {
180         return new LinkedHashMap<>();
181     }
182 }