c0d95e27552137fc2c5859853887cd521625413e
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / provider / statistics / ApiStatisticsManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy API
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  * SPDX-License-Identifier: Apache-2.0
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.policy.api.main.rest.provider.statistics;
25
26 import lombok.RequiredArgsConstructor;
27 import org.springframework.stereotype.Component;
28
29 /**
30  * Class to hold statistical data for API access.
31  *
32  * @author Chenfei Gao (cgao@research.att.com)
33  */
34 @Component
35 @RequiredArgsConstructor
36 public class ApiStatisticsManager {
37
38     private final StatisticsReport report;
39
40     private long totalPolicyDeleteCount;
41     private long totalPolicyTypeDeleteCount;
42     private long policyDeleteSuccessCount;
43     private long policyDeleteFailureCount;
44     private long policyTypeDeleteSuccessCount;
45     private long policyTypeDeleteFailureCount;
46
47     /**
48      * Method to update the total api call count.
49      *
50      * @return the updated value of totalApiCallCount
51      */
52     public long updateTotalApiCallCount() {
53         return ++report.totalApiCallCount;
54     }
55
56     /**
57      * Method to update the successful api call count.
58      *
59      * @return the updated value of apiCallSuccessCount
60      */
61     public long updateApiCallSuccessCount() {
62         return ++report.apiCallSuccessCount;
63     }
64
65     /**
66      * Method to update the failed api call count.
67      *
68      * @return the updated value of apiCallFailureCount
69      */
70     public long updateApiCallFailureCount() {
71         return ++report.apiCallFailureCount;
72     }
73
74     /**
75      * Method to update the total policy GET count.
76      *
77      * @return the updated value of totalPolicyGetCount
78      */
79     public long updateTotalPolicyGetCount() {
80         return ++report.totalPolicyGetCount;
81     }
82
83     /**
84      * Method to update the total policy POST count.
85      *
86      * @return the updated value of totalPolicyPostCount
87      */
88     public long updateTotalPolicyPostCount() {
89         return ++report.totalPolicyPostCount;
90     }
91
92     /**
93      * Method to update the total policy DELETE count.
94      *
95      * @return the updated value of  totalPolicyDeleteCount
96      */
97     public long updateTotalPolicyDeleteCount() {
98         return ++totalPolicyDeleteCount;
99     }
100
101     /**
102      * Method to update the total policyType GET count.
103      *
104      * @return the updated value of totalPolicyTypeGetCount
105      */
106     public long updateTotalPolicyTypeGetCount() {
107         return ++report.totalPolicyTypeGetCount;
108     }
109
110     /**
111      * Method to update the total policyType POST count.
112      *
113      * @return the updated value of totalPolicyTypePostCount
114      */
115     public long updateTotalPolicyTypePostCount() {
116         return ++report.totalPolicyTypePostCount;
117     }
118
119     /**
120      * Method to update the total policyType DELETE count.
121      *
122      * @return the updated value of totalPolicyTypeDeleteCount
123      */
124     public long updateTotalPolicyTypeDeleteCount() {
125         return ++totalPolicyTypeDeleteCount;
126     }
127
128     /**
129      * Method to update successful policy GET count.
130      *
131      * @return the updated value of policyGetSuccessCount
132      */
133     public long updatePolicyGetSuccessCount() {
134         return ++report.policyGetSuccessCount;
135     }
136
137     /**
138      * Method to update failed policy GET count.
139      *
140      * @return the updated value of policyGetFailureCount
141      */
142     public long updatePolicyGetFailureCount() {
143         return ++report.policyGetFailureCount;
144     }
145
146     /**
147      * Method to update successful policy POST count.
148      *
149      * @return the updated value of policyPostSuccessCount
150      */
151     public long updatePolicyPostSuccessCount() {
152         return ++report.policyPostSuccessCount;
153     }
154
155     /**
156      * Method to update failed policy POST count.
157      *
158      * @return the updated value of policyPostFailureCount
159      */
160     public long updatePolicyPostFailureCount() {
161         return ++report.policyPostFailureCount;
162     }
163
164     /**
165      * Method to update successful policy DELETE count.
166      *
167      * @return the updated value of policyDeleteSuccessCount
168      */
169     public long updatePolicyDeleteSuccessCount() {
170         return ++policyDeleteSuccessCount;
171     }
172
173     /**
174      * Method to update failed policy DELETE count.
175      *
176      * @return the updated value of policyDeleteFailureCount
177      */
178     public long updatePolicyDeleteFailureCount() {
179         return ++policyDeleteFailureCount;
180     }
181
182     /**
183      * Method to update successful policyType GET count.
184      *
185      * @return the updated value of policyTypeGetSuccessCount
186      */
187     public long updatePolicyTypeGetSuccessCount() {
188         return ++report.policyTypeGetSuccessCount;
189     }
190
191     /**
192      * Method to update failed policyType GET count.
193      *
194      * @return the updated value of policyTypeGetFailureCount
195      */
196     public long updatePolicyTypeGetFailureCount() {
197         return ++report.policyTypeGetFailureCount;
198     }
199
200     /**
201      * Method to update successful policyType POST count.
202      *
203      * @return the updated value of policyTypePostSuccessCount
204      */
205     public long updatePolicyTypePostSuccessCount() {
206         return ++report.policyTypePostSuccessCount;
207     }
208
209     /**
210      * Method to update failed policyType POST count.
211      *
212      * @return the updated value of policyTypePostFailureCount
213      */
214     public long updatePolicyTypePostFailureCount() {
215         return ++report.policyTypePostFailureCount;
216     }
217
218     /**
219      * Method to update successful policyType DELETE count.
220      *
221      * @return the updated value of policyTypeDeleteSuccessCount
222      */
223     public long updatePolicyTypeDeleteSuccessCount() {
224         return ++policyTypeDeleteSuccessCount;
225     }
226
227     /**
228      * Method to update failed policyType DELETE count.
229      *
230      * @return the updated value of policyTypePostFailureCount
231      */
232     public long updatePolicyTypeDeleteFailureCount() {
233         return ++policyTypeDeleteFailureCount;
234     }
235 }