2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
\r
7 * Modifications Copyright (C) 2020-2022 Nordix Foundation.
\r
8 * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
\r
9 * ================================================================================
\r
10 * Licensed under the Apache License, Version 2.0 (the "License");
\r
11 * you may not use this file except in compliance with the License.
\r
12 * You may obtain a copy of the License at
\r
14 * http://www.apache.org/licenses/LICENSE-2.0
\r
16 * Unless required by applicable law or agreed to in writing, software
\r
17 * distributed under the License is distributed on an "AS IS" BASIS,
\r
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
19 * See the License for the specific language governing permissions and
\r
20 * limitations under the License.
\r
22 * SPDX-License-Identifier: Apache-2.0
\r
23 * ============LICENSE_END=========================================================
\r
26 package org.onap.policy.api.main.rest;
\r
28 import java.util.List;
\r
29 import java.util.UUID;
\r
30 import javax.ws.rs.core.Response.Status;
\r
31 import lombok.RequiredArgsConstructor;
\r
32 import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
\r
33 import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;
\r
34 import org.onap.policy.api.main.rest.provider.healthcheck.HealthCheckProvider;
\r
35 import org.onap.policy.api.main.rest.provider.statistics.ApiStatisticsManager;
\r
36 import org.onap.policy.api.main.rest.provider.statistics.StatisticsProvider;
\r
37 import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport;
\r
38 import org.onap.policy.api.main.service.ToscaServiceTemplateService;
\r
39 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
\r
40 import org.onap.policy.common.endpoints.report.HealthCheckReport;
\r
41 import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
\r
42 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
\r
43 import org.onap.policy.models.base.PfModelException;
\r
44 import org.onap.policy.models.base.PfModelRuntimeException;
\r
45 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
\r
46 import org.springframework.context.annotation.Profile;
\r
47 import org.springframework.http.HttpMethod;
\r
48 import org.springframework.http.HttpStatus;
\r
49 import org.springframework.http.ResponseEntity;
\r
50 import org.springframework.web.bind.annotation.RestController;
\r
53 * Class to provide REST API services.
\r
55 * @author Chenfei Gao (cgao@research.att.com)
\r
58 @RequiredArgsConstructor
\r
60 public class ApiRestController extends CommonRestController implements PolicyDesignApi {
\r
62 private enum Target {
\r
68 private final ToscaServiceTemplateService toscaServiceTemplateService;
\r
69 private final HealthCheckProvider healthCheckProvider;
\r
70 private final ApiStatisticsManager mgr;
\r
71 private final StatisticsProvider statisticsProvider;
\r
74 * Retrieves the healthcheck status of the API component.
\r
76 * @return the Response object containing the results of the API operation
\r
79 public ResponseEntity<HealthCheckReport> getHealthCheck(UUID requestId) {
\r
80 final var report = healthCheckProvider.performHealthCheck();
\r
81 updateApiStatisticsCounter(Target.OTHER, HttpStatus.resolve(report.getCode()), HttpMethod.GET);
\r
82 return makeResponse(requestId, report, report.getCode());
\r
86 * Retrieves the statistics report of the API component.
\r
88 * @return the Response object containing the results of the API operation
\r
91 public ResponseEntity<StatisticsReport> getStatistics(UUID requestId) {
\r
92 updateApiStatisticsCounter(Target.OTHER, HttpStatus.OK, HttpMethod.GET);
\r
93 return makeOkResponse(requestId, statisticsProvider.fetchCurrentStatistics());
\r
97 * Retrieves all available policy types.
\r
99 * @return the Response object containing the results of the API operation
\r
102 public ResponseEntity<ToscaServiceTemplate> getAllPolicyTypes(UUID requestId) {
\r
104 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(null, null);
\r
105 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
106 return makeOkResponse(requestId, serviceTemplate);
\r
107 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
108 final var msg = "GET /policytypes";
\r
109 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
110 .getStatusCode()), HttpMethod.GET);
\r
111 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
116 * Retrieves all versions of a particular policy type.
\r
118 * @param policyTypeId the ID of specified policy type
\r
120 * @return the Response object containing the results of the API operation
\r
123 public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(
\r
124 String policyTypeId,
\r
127 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);
\r
128 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
129 return makeOkResponse(requestId, serviceTemplate);
\r
130 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
131 var msg = String.format("GET /policytypes/%s", policyTypeId);
\r
132 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
133 .getStatusCode()), HttpMethod.GET);
\r
134 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
139 * Retrieves specified version of a particular policy type.
\r
141 * @param policyTypeId the ID of specified policy type
\r
142 * @param versionId the version of specified policy type
\r
144 * @return the Response object containing the results of the API operation
\r
147 public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(
\r
148 String policyTypeId,
\r
152 ToscaServiceTemplate serviceTemplate =
\r
153 toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);
\r
154 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
155 return makeOkResponse(requestId, serviceTemplate);
\r
156 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
157 var msg = String.format("GET /policytypes/%s/versions/%s", policyTypeId, versionId);
\r
158 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
159 .getStatusCode()), HttpMethod.GET);
\r
160 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
165 * Retrieves latest version of a particular policy type.
\r
167 * @param policyTypeId the ID of specified policy type
\r
169 * @return the Response object containing the results of the API operation
\r
172 public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(
\r
173 String policyTypeId,
\r
176 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);
\r
177 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
178 return makeOkResponse(requestId, serviceTemplate);
\r
179 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
180 var msg = String.format("GET /policytypes/%s/versions/latest", policyTypeId);
\r
181 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
182 .getStatusCode()), HttpMethod.GET);
\r
183 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
188 * Creates a new policy type.
\r
190 * @param body the body of policy type following TOSCA definition
\r
192 * @return the Response object containing the results of the API operation
\r
195 public ResponseEntity<ToscaServiceTemplate> createPolicyType(
\r
196 ToscaServiceTemplate body,
\r
198 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
199 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));
\r
202 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicyType(body);
\r
203 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.POST);
\r
204 return makeOkResponse(requestId, serviceTemplate);
\r
205 } catch (PfModelRuntimeException pfme) {
\r
206 final var msg = "POST /policytypes";
\r
207 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
208 .getStatusCode()), HttpMethod.POST);
\r
209 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
214 * Deletes specified version of a particular policy type.
\r
216 * @param policyTypeId the ID of specified policy type
\r
217 * @param versionId the version of specified policy type
\r
219 * @return the Response object containing the results of the API operation
\r
222 public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(
\r
223 String policyTypeId,
\r
227 ToscaServiceTemplate serviceTemplate =
\r
228 toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);
\r
229 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.DELETE);
\r
230 return makeOkResponse(requestId, serviceTemplate);
\r
231 } catch (PfModelRuntimeException pfme) {
\r
232 var msg = String.format("DELETE /policytypes/%s/versions/%s", policyTypeId, versionId);
\r
233 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
234 .getStatusCode()), HttpMethod.DELETE);
\r
235 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
240 * Retrieves all versions of a particular policy.
\r
242 * @param policyTypeId the ID of specified policy type
\r
243 * @param policyTypeVersion the version of specified policy type
\r
245 * @return the Response object containing the results of the API operation
\r
248 public ResponseEntity<ToscaServiceTemplate> getAllPolicies(
\r
249 String policyTypeId,
\r
250 String policyTypeVersion,
\r
251 PolicyFetchMode mode,
\r
254 ToscaServiceTemplate serviceTemplate =
\r
255 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);
\r
256 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
257 return makeOkResponse(requestId, serviceTemplate);
\r
258 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
259 var msg = String.format("GET /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
\r
260 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
261 .getStatusCode()), HttpMethod.GET);
\r
262 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
267 * Retrieves all versions of a particular policy.
\r
269 * @param policyTypeId the ID of specified policy type
\r
270 * @param policyTypeVersion the version of specified policy type
\r
271 * @param policyId the ID of specified policy
\r
273 * @return the Response object containing the results of the API operation
\r
276 public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(
\r
278 String policyTypeId,
\r
279 String policyTypeVersion,
\r
280 PolicyFetchMode mode,
\r
283 ToscaServiceTemplate serviceTemplate =
\r
284 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);
\r
285 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
286 return makeOkResponse(requestId, serviceTemplate);
\r
287 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
288 var msg = String.format("/policytypes/%s/versions/%s/policies/%s",
\r
289 policyTypeId, policyTypeVersion, policyId);
\r
290 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
291 .getStatusCode()), HttpMethod.GET);
\r
292 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
297 * Retrieves the specified version of a particular policy.
\r
299 * @param policyTypeId the ID of specified policy type
\r
300 * @param policyTypeVersion the version of specified policy type
\r
301 * @param policyId the ID of specified policy
\r
302 * @param policyVersion the version of specified policy
\r
304 * @return the Response object containing the results of the API operation
\r
307 public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(
\r
309 String policyTypeId,
\r
310 String policyTypeVersion,
\r
311 String policyVersion,
\r
312 PolicyFetchMode mode,
\r
315 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService
\r
316 .fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);
\r
317 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
318 return makeOkResponse(requestId, serviceTemplate);
\r
319 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
320 var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/%s",
\r
321 policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
322 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
323 .getStatusCode()), HttpMethod.GET);
\r
324 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
329 * Retrieves the latest version of a particular policy.
\r
331 * @param policyTypeId the ID of specified policy type
\r
332 * @param policyTypeVersion the version of specified policy type
\r
333 * @param policyId the ID of specified policy
\r
335 * @return the Response object containing the results of the API operation
\r
338 public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(
\r
340 String policyTypeId,
\r
341 String policyTypeVersion,
\r
342 PolicyFetchMode mode,
\r
345 ToscaServiceTemplate serviceTemplate =
\r
346 toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);
\r
347 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
348 return makeOkResponse(requestId, serviceTemplate);
\r
349 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
350 var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/latest",
\r
351 policyTypeId, policyTypeVersion, policyId);
\r
352 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
353 .getStatusCode()), HttpMethod.GET);
\r
354 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
359 * Creates a new policy for a particular policy type and version.
\r
361 * @param policyTypeId the ID of specified policy type
\r
362 * @param policyTypeVersion the version of specified policy type
\r
363 * @param body the body of policy following TOSCA definition
\r
365 * @return the Response object containing the results of the API operation
\r
368 public ResponseEntity<ToscaServiceTemplate> createPolicy(
\r
369 String policyTypeId,
\r
370 String policyTypeVersion,
\r
371 ToscaServiceTemplate body,
\r
373 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
374 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
\r
375 "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));
\r
378 ToscaServiceTemplate serviceTemplate =
\r
379 toscaServiceTemplateService.createPolicy(policyTypeId, policyTypeVersion, body);
\r
380 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
\r
381 return makeOkResponse(requestId, serviceTemplate);
\r
382 } catch (PfModelRuntimeException pfme) {
\r
383 var msg = String.format("POST /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
\r
384 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
385 .getStatusCode()), HttpMethod.POST);
\r
386 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
391 * Deletes the specified version of a particular policy.
\r
393 * @param policyTypeId the ID of specified policy type
\r
394 * @param policyTypeVersion the version of specified policy type
\r
395 * @param policyId the ID of specified policy
\r
396 * @param policyVersion the version of specified policy
\r
398 * @return the Response object containing the results of the API operation
\r
401 public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicy(
\r
402 String policyTypeId,
\r
403 String policyTypeVersion,
\r
405 String policyVersion,
\r
408 ToscaServiceTemplate serviceTemplate =
\r
409 toscaServiceTemplateService.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
410 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
\r
411 return makeOkResponse(requestId, serviceTemplate);
\r
412 } catch (PfModelRuntimeException pfme) {
\r
413 var msg = String.format("DELETE /policytypes/%s/versions/%s/policies/%s/versions/%s",
\r
414 policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
415 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
416 .getStatusCode()), HttpMethod.DELETE);
\r
417 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
422 * Retrieves all the available policies.
\r
424 * @return the Response object containing the results of the API operation
\r
427 public ResponseEntity<ToscaServiceTemplate> getPolicies(
\r
428 PolicyFetchMode mode,
\r
431 ToscaServiceTemplate serviceTemplate =
\r
432 toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);
\r
433 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
434 return makeOkResponse(requestId, serviceTemplate);
\r
435 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
436 final var msg = "GET /policies/ --";
\r
437 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
438 .getStatusCode()), HttpMethod.GET);
\r
439 if (pfme.getErrorResponse().getResponseCode().equals(Status.NOT_FOUND)) {
\r
440 pfme.getErrorResponse().setErrorMessage(ERROR_MESSAGE_NO_POLICIES_FOUND);
\r
441 pfme.getErrorResponse().setErrorDetails(List.of(ERROR_MESSAGE_NO_POLICIES_FOUND));
\r
443 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
448 * Retrieves the specified version of a particular policy.
\r
450 * @param policyId the Name of specified policy
\r
451 * @param policyVersion the version of specified policy
\r
453 * @return the Response object containing the results of the API operation
\r
456 public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(
\r
458 String policyVersion,
\r
459 PolicyFetchMode mode,
\r
462 ToscaServiceTemplate serviceTemplate =
\r
463 toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);
\r
464 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
465 return makeOkResponse(requestId, serviceTemplate);
\r
466 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
467 var msg = String.format("GET /policies/%s/versions/%s", policyId, policyVersion);
\r
468 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
469 .getStatusCode()), HttpMethod.GET);
\r
470 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
475 * Creates one or more new policies in one call.
\r
477 * @param body the body of policy following TOSCA definition
\r
479 * @return the Response object containing the results of the API operation
\r
482 public ResponseEntity<ToscaServiceTemplate> createPolicies(
\r
483 ToscaServiceTemplate body,
\r
485 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
486 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policies", toJson(body));
\r
489 ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicies(body);
\r
490 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
\r
491 return makeOkResponse(requestId, serviceTemplate);
\r
492 } catch (PfModelRuntimeException pfme) {
\r
493 final var msg = "POST /policies";
\r
494 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
495 .getStatusCode()), HttpMethod.POST);
\r
496 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
501 * Deletes the specified version of a particular policy.
\r
503 * @param policyId the ID of specified policy
\r
504 * @param policyVersion the version of specified policy
\r
506 * @return the Response object containing the results of the API operation
\r
509 public ResponseEntity<ToscaServiceTemplate> deleteSpecificPolicy(
\r
511 String policyVersion,
\r
514 ToscaServiceTemplate serviceTemplate =
\r
515 toscaServiceTemplateService.deletePolicy(null, null, policyId, policyVersion);
\r
516 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
\r
517 return makeOkResponse(requestId, serviceTemplate);
\r
518 } catch (PfModelRuntimeException pfme) {
\r
519 var msg = String.format("DELETE /policies/%s/versions/%s", policyId, policyVersion);
\r
520 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
521 .getStatusCode()), HttpMethod.DELETE);
\r
522 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
526 private void updateApiStatisticsCounter(Target target, HttpStatus result, HttpMethod http) {
\r
527 mgr.updateTotalApiCallCount();
\r
530 updatePolicyStats(result, http);
\r
533 updatePolicyTypeStats(result, http);
\r
536 mgr.updateApiCallSuccessCount();
\r
541 private void updatePolicyStats(HttpStatus result, HttpMethod http) {
\r
542 if (result.equals(HttpStatus.OK)) {
\r
545 mgr.updateApiCallSuccessCount();
\r
546 mgr.updateTotalPolicyGetCount();
\r
547 mgr.updatePolicyGetSuccessCount();
\r
550 mgr.updateApiCallSuccessCount();
\r
551 mgr.updateTotalPolicyPostCount();
\r
552 mgr.updatePolicyPostSuccessCount();
\r
555 mgr.updateApiCallSuccessCount();
\r
556 mgr.updateTotalPolicyDeleteCount();
\r
557 mgr.updatePolicyDeleteSuccessCount();
\r
560 mgr.updateApiCallSuccessCount();
\r
566 mgr.updateApiCallFailureCount();
\r
567 mgr.updateTotalPolicyGetCount();
\r
568 mgr.updatePolicyGetFailureCount();
\r
571 mgr.updateApiCallFailureCount();
\r
572 mgr.updateTotalPolicyPostCount();
\r
573 mgr.updatePolicyPostFailureCount();
\r
576 mgr.updateApiCallFailureCount();
\r
577 mgr.updateTotalPolicyDeleteCount();
\r
578 mgr.updatePolicyDeleteFailureCount();
\r
581 mgr.updateApiCallFailureCount();
\r
587 private void updatePolicyTypeStats(HttpStatus result, HttpMethod http) {
\r
588 if (result.equals(HttpStatus.OK)) {
\r
591 mgr.updateApiCallSuccessCount();
\r
592 mgr.updateTotalPolicyTypeGetCount();
\r
593 mgr.updatePolicyTypeGetSuccessCount();
\r
596 mgr.updateApiCallSuccessCount();
\r
597 mgr.updateTotalPolicyTypePostCount();
\r
598 mgr.updatePolicyTypePostSuccessCount();
\r
601 mgr.updateApiCallSuccessCount();
\r
602 mgr.updateTotalPolicyTypeDeleteCount();
\r
603 mgr.updatePolicyTypeDeleteSuccessCount();
\r
606 mgr.updateApiCallSuccessCount();
\r
612 mgr.updateApiCallFailureCount();
\r
613 mgr.updateTotalPolicyTypeGetCount();
\r
614 mgr.updatePolicyTypeGetFailureCount();
\r
617 mgr.updateApiCallFailureCount();
\r
618 mgr.updateTotalPolicyTypePostCount();
\r
619 mgr.updatePolicyTypePostFailureCount();
\r
622 mgr.updateApiCallFailureCount();
\r
623 mgr.updateTotalPolicyTypeDeleteCount();
\r
624 mgr.updatePolicyTypeDeleteFailureCount();
\r
627 mgr.updateApiCallFailureCount();
\r