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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.pdp.persistence.provider;
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.List;
28 import lombok.NonNull;
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;
40 * This class provides the provision of information on PAP concepts in the database to callers.
42 * @author Liam Fallon (liam.fallon@est.tech)
44 public class PdpProvider {
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
54 public PdpGroups getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
55 throws PfModelException {
56 return new PdpGroups();
60 * Get latest PDP Groups.
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
67 public PdpGroups getLatestPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
68 return new PdpGroups();
72 * Get a filtered list of PDP groups.
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
79 public PdpGroups getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpType,
80 @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
81 return new PdpGroups();
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
92 public PdpGroups createPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups)
93 throws PfModelException {
94 return new PdpGroups();
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
105 public PdpGroups updatePdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups)
106 throws PfModelException {
107 return new PdpGroups();
112 * Update a PDP subgroup.
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
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
126 * Delete a PDP group.
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
134 public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name, @NonNull final String version)
135 throws PfModelException {
136 return new PdpGroup();
141 * Get PDP statistics.
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
149 public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version)
150 throws PfModelException {
151 return new ArrayList<>();
155 * Update PDP statistics for a PDP.
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
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
171 * Get deployed policies.
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
178 public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(@NonNull final PfDao dao, final String name)
179 throws PfModelException {
180 return new LinkedHashMap<>();