2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * SPDX-License-Identifier: Apache-2.0
21 * ============LICENSE_END=========================================================
24 package org.onap.policy.api.main.rest.provider.statistics;
26 import lombok.RequiredArgsConstructor;
27 import org.springframework.stereotype.Component;
30 * Class to hold statistical data for API access.
32 * @author Chenfei Gao (cgao@research.att.com)
35 @RequiredArgsConstructor
36 public class ApiStatisticsManager {
38 private final StatisticsReport report;
40 private long totalPolicyDeleteCount;
41 private long totalPolicyTypeDeleteCount;
42 private long policyDeleteSuccessCount;
43 private long policyDeleteFailureCount;
44 private long policyTypeDeleteSuccessCount;
45 private long policyTypeDeleteFailureCount;
48 * Method to update the total api call count.
50 * @return the updated value of totalApiCallCount
52 public long updateTotalApiCallCount() {
53 return ++report.totalApiCallCount;
57 * Method to update the successful api call count.
59 * @return the updated value of apiCallSuccessCount
61 public long updateApiCallSuccessCount() {
62 return ++report.apiCallSuccessCount;
66 * Method to update the failed api call count.
68 * @return the updated value of apiCallFailureCount
70 public long updateApiCallFailureCount() {
71 return ++report.apiCallFailureCount;
75 * Method to update the total policy GET count.
77 * @return the updated value of totalPolicyGetCount
79 public long updateTotalPolicyGetCount() {
80 return ++report.totalPolicyGetCount;
84 * Method to update the total policy POST count.
86 * @return the updated value of totalPolicyPostCount
88 public long updateTotalPolicyPostCount() {
89 return ++report.totalPolicyPostCount;
93 * Method to update the total policy DELETE count.
95 * @return the updated value of totalPolicyDeleteCount
97 public long updateTotalPolicyDeleteCount() {
98 return ++totalPolicyDeleteCount;
102 * Method to update the total policyType GET count.
104 * @return the updated value of totalPolicyTypeGetCount
106 public long updateTotalPolicyTypeGetCount() {
107 return ++report.totalPolicyTypeGetCount;
111 * Method to update the total policyType POST count.
113 * @return the updated value of totalPolicyTypePostCount
115 public long updateTotalPolicyTypePostCount() {
116 return ++report.totalPolicyTypePostCount;
120 * Method to update the total policyType DELETE count.
122 * @return the updated value of totalPolicyTypeDeleteCount
124 public long updateTotalPolicyTypeDeleteCount() {
125 return ++totalPolicyTypeDeleteCount;
129 * Method to update successful policy GET count.
131 * @return the updated value of policyGetSuccessCount
133 public long updatePolicyGetSuccessCount() {
134 return ++report.policyGetSuccessCount;
138 * Method to update failed policy GET count.
140 * @return the updated value of policyGetFailureCount
142 public long updatePolicyGetFailureCount() {
143 return ++report.policyGetFailureCount;
147 * Method to update successful policy POST count.
149 * @return the updated value of policyPostSuccessCount
151 public long updatePolicyPostSuccessCount() {
152 return ++report.policyPostSuccessCount;
156 * Method to update failed policy POST count.
158 * @return the updated value of policyPostFailureCount
160 public long updatePolicyPostFailureCount() {
161 return ++report.policyPostFailureCount;
165 * Method to update successful policy DELETE count.
167 * @return the updated value of policyDeleteSuccessCount
169 public long updatePolicyDeleteSuccessCount() {
170 return ++policyDeleteSuccessCount;
174 * Method to update failed policy DELETE count.
176 * @return the updated value of policyDeleteFailureCount
178 public long updatePolicyDeleteFailureCount() {
179 return ++policyDeleteFailureCount;
183 * Method to update successful policyType GET count.
185 * @return the updated value of policyTypeGetSuccessCount
187 public long updatePolicyTypeGetSuccessCount() {
188 return ++report.policyTypeGetSuccessCount;
192 * Method to update failed policyType GET count.
194 * @return the updated value of policyTypeGetFailureCount
196 public long updatePolicyTypeGetFailureCount() {
197 return ++report.policyTypeGetFailureCount;
201 * Method to update successful policyType POST count.
203 * @return the updated value of policyTypePostSuccessCount
205 public long updatePolicyTypePostSuccessCount() {
206 return ++report.policyTypePostSuccessCount;
210 * Method to update failed policyType POST count.
212 * @return the updated value of policyTypePostFailureCount
214 public long updatePolicyTypePostFailureCount() {
215 return ++report.policyTypePostFailureCount;
219 * Method to update successful policyType DELETE count.
221 * @return the updated value of policyTypeDeleteSuccessCount
223 public long updatePolicyTypeDeleteSuccessCount() {
224 return ++policyTypeDeleteSuccessCount;
228 * Method to update failed policyType DELETE count.
230 * @return the updated value of policyTypePostFailureCount
232 public long updatePolicyTypeDeleteFailureCount() {
233 return ++policyTypeDeleteFailureCount;