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 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 io.swagger.annotations.Api;
\r
29 import io.swagger.annotations.ApiOperation;
\r
30 import io.swagger.annotations.ApiParam;
\r
31 import io.swagger.annotations.ApiResponse;
\r
32 import io.swagger.annotations.ApiResponses;
\r
33 import io.swagger.annotations.Authorization;
\r
34 import io.swagger.annotations.BasicAuthDefinition;
\r
35 import io.swagger.annotations.Extension;
\r
36 import io.swagger.annotations.ExtensionProperty;
\r
37 import io.swagger.annotations.Info;
\r
38 import io.swagger.annotations.ResponseHeader;
\r
39 import io.swagger.annotations.SecurityDefinition;
\r
40 import io.swagger.annotations.SwaggerDefinition;
\r
41 import java.net.HttpURLConnection;
\r
42 import java.util.List;
\r
43 import java.util.UUID;
\r
44 import javax.ws.rs.core.Response.Status;
\r
45 import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
\r
46 import org.onap.policy.api.main.rest.provider.HealthCheckProvider;
\r
47 import org.onap.policy.api.main.rest.provider.PolicyProvider;
\r
48 import org.onap.policy.api.main.rest.provider.PolicyTypeProvider;
\r
49 import org.onap.policy.api.main.rest.provider.StatisticsProvider;
\r
50 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
\r
51 import org.onap.policy.common.endpoints.report.HealthCheckReport;
\r
52 import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
\r
53 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
\r
54 import org.onap.policy.models.base.PfModelException;
\r
55 import org.onap.policy.models.base.PfModelRuntimeException;
\r
56 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
\r
57 import org.slf4j.Logger;
\r
58 import org.slf4j.LoggerFactory;
\r
59 import org.springframework.beans.factory.annotation.Autowired;
\r
60 import org.springframework.http.HttpMethod;
\r
61 import org.springframework.http.HttpStatus;
\r
62 import org.springframework.http.ResponseEntity;
\r
63 import org.springframework.web.bind.annotation.DeleteMapping;
\r
64 import org.springframework.web.bind.annotation.ExceptionHandler;
\r
65 import org.springframework.web.bind.annotation.GetMapping;
\r
66 import org.springframework.web.bind.annotation.PathVariable;
\r
67 import org.springframework.web.bind.annotation.PostMapping;
\r
68 import org.springframework.web.bind.annotation.RequestBody;
\r
69 import org.springframework.web.bind.annotation.RequestHeader;
\r
70 import org.springframework.web.bind.annotation.RequestMapping;
\r
71 import org.springframework.web.bind.annotation.RequestParam;
\r
72 import org.springframework.web.bind.annotation.RestController;
\r
75 * Class to provide REST API services.
\r
77 * @author Chenfei Gao (cgao@research.att.com)
\r
80 @RequestMapping(path = "/policy/api/v1", produces = { "application/json", "application/yaml" })
\r
81 @Api(value = "Policy Design API")
\r
84 description = "Policy Design API is publicly exposed for clients to Create/Read/Update/Delete"
\r
85 + " policy types, policy type implementation and policies which can be recognized"
\r
86 + " and executable by incorporated policy engines. It is an"
\r
87 + " independent component running rest service that takes all policy design API calls"
\r
88 + " from clients and then assign them to different API working functions. Besides"
\r
89 + " that, API is also exposed for clients to retrieve healthcheck status of this API"
\r
90 + " rest service and the statistics report including the counters of API invocation.",
\r
91 version = "1.0.0", title = "Policy Design",
\r
92 extensions = {@Extension(properties = {@ExtensionProperty(name = "planned-retirement-date", value = "tbd"),
\r
93 @ExtensionProperty(name = "component", value = "Policy Framework")})}),
\r
94 schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
\r
95 securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
\r
96 public class ApiRestController extends CommonRestController {
\r
98 private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestController.class);
\r
100 private static final String ERROR_MESSAGE_NO_POLICIES_FOUND = "No policies found";
\r
102 private static final String EXTENSION_NAME = "interface info";
\r
104 private static final String API_VERSION_NAME = "api-version";
\r
105 private static final String API_VERSION = "1.0.0";
\r
107 private static final String LAST_MOD_NAME = "last-mod-release";
\r
109 private static final String AUTHORIZATION_TYPE = "basicAuth";
\r
111 private static final String VERSION_MINOR_NAME = "X-MinorVersion";
\r
112 private static final String VERSION_MINOR_DESCRIPTION =
\r
113 "Used to request or communicate a MINOR version back from the client"
\r
114 + " to the server, and from the server back to the client";
\r
116 private static final String VERSION_PATCH_NAME = "X-PatchVersion";
\r
117 private static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
\r
118 + " troubleshooting purposes only, and will not be provided by" + " the client on request";
\r
120 private static final String VERSION_LATEST_NAME = "X-LatestVersion";
\r
121 private static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
\r
123 private static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
\r
124 private static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
\r
125 private static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";
\r
127 private static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
\r
128 private static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
\r
129 private static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
\r
130 private static final String NOT_FOUND_MESSAGE = "Resource Not Found";
\r
131 private static final String INVALID_BODY_MESSAGE = "Invalid Body";
\r
132 private static final String INVALID_PAYLOAD_MESSAGE = "Not Acceptable Payload";
\r
133 private static final String HTTP_CONFLICT_MESSAGE = "Delete Conflict, Rule Violation";
\r
135 private enum Target {
\r
142 private PolicyProvider policyProvider;
\r
145 private HealthCheckProvider healthCheckProvider;
\r
148 private PolicyTypeProvider policyTypeProvider;
\r
151 private ApiStatisticsManager mgr;
\r
154 private StatisticsProvider statisticsProvider;
\r
157 * Retrieves the healthcheck status of the API component.
\r
159 * @return the Response object containing the results of the API operation
\r
161 @GetMapping("/healthcheck")
\r
162 @ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component",
\r
163 response = HealthCheckReport.class,
\r
164 responseHeaders = {
\r
165 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
166 description = VERSION_MINOR_DESCRIPTION,
\r
167 response = String.class),
\r
168 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
169 description = VERSION_PATCH_DESCRIPTION,
\r
170 response = String.class),
\r
171 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
172 response = String.class),
\r
173 @ResponseHeader(name = REQUEST_ID_NAME,
\r
174 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
175 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"HealthCheck", },
\r
177 @Extension(name = EXTENSION_NAME, properties = {
\r
178 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
179 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
180 @ApiResponses(value = {
\r
181 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
182 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
183 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
184 public ResponseEntity<HealthCheckReport> getHealthCheck(
\r
185 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
186 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
187 updateApiStatisticsCounter(Target.OTHER, HttpStatus.OK, HttpMethod.GET);
\r
188 return makeOkResponse(requestId, healthCheckProvider.performHealthCheck());
\r
192 * Retrieves the statistics report of the API component.
\r
194 * @return the Response object containing the results of the API operation
\r
196 @GetMapping("/statistics")
\r
197 @ApiOperation(value = "Retrieve current statistics",
\r
198 notes = "Returns current statistics including the counters of API invocation",
\r
199 response = StatisticsReport.class,
\r
200 responseHeaders = {
\r
201 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
202 description = VERSION_MINOR_DESCRIPTION,
\r
203 response = String.class),
\r
204 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
205 description = VERSION_PATCH_DESCRIPTION,
\r
206 response = String.class),
\r
207 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
208 response = String.class),
\r
209 @ResponseHeader(name = REQUEST_ID_NAME,
\r
210 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
211 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Statistics", },
\r
213 @Extension(name = EXTENSION_NAME, properties = {
\r
214 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
215 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
216 @ApiResponses(value = {
\r
217 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
218 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
219 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
220 public ResponseEntity<StatisticsReport> getStatistics(
\r
221 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
222 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
223 updateApiStatisticsCounter(Target.OTHER, HttpStatus.OK, HttpMethod.GET);
\r
224 return makeOkResponse(requestId, statisticsProvider.fetchCurrentStatistics());
\r
228 * Retrieves all available policy types.
\r
230 * @return the Response object containing the results of the API operation
\r
232 @GetMapping("/policytypes")
\r
233 @ApiOperation(value = "Retrieve existing policy types",
\r
234 notes = "Returns a list of existing policy types stored in Policy Framework",
\r
235 response = ToscaServiceTemplate.class,
\r
236 responseHeaders = {
\r
237 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
238 description = VERSION_MINOR_DESCRIPTION,
\r
239 response = String.class),
\r
240 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
241 description = VERSION_PATCH_DESCRIPTION,
\r
242 response = String.class),
\r
243 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
244 response = String.class),
\r
245 @ResponseHeader(name = REQUEST_ID_NAME,
\r
246 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
247 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
249 @Extension(name = EXTENSION_NAME, properties = {
\r
250 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
251 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
252 @ApiResponses(value = {
\r
253 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
254 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
255 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
256 public ResponseEntity<ToscaServiceTemplate> getAllPolicyTypes(
\r
257 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
258 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
260 ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(null, null);
\r
261 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
262 return makeOkResponse(requestId, serviceTemplate);
\r
263 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
264 final var msg = "GET /policytypes";
\r
265 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
266 .getStatusCode()), HttpMethod.GET);
\r
267 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
272 * Retrieves all versions of a particular policy type.
\r
274 * @param policyTypeId the ID of specified policy type
\r
276 * @return the Response object containing the results of the API operation
\r
278 @GetMapping("/policytypes/{policyTypeId}")
\r
279 @ApiOperation(value = "Retrieve all available versions of a policy type",
\r
280 notes = "Returns a list of all available versions for the specified policy type",
\r
281 response = ToscaServiceTemplate.class,
\r
282 responseHeaders = {
\r
283 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
284 description = VERSION_MINOR_DESCRIPTION,
\r
285 response = String.class),
\r
286 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
287 description = VERSION_PATCH_DESCRIPTION,
\r
288 response = String.class),
\r
289 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
290 response = String.class),
\r
291 @ResponseHeader(name = REQUEST_ID_NAME,
\r
292 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
293 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
295 @Extension(name = EXTENSION_NAME, properties = {
\r
296 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
297 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
298 @ApiResponses(value = {
\r
299 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
300 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
301 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
302 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
303 public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(
\r
304 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
305 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
306 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
308 ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, null);
\r
309 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
310 return makeOkResponse(requestId, serviceTemplate);
\r
311 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
312 var msg = String.format("GET /policytypes/%s", policyTypeId);
\r
313 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
314 .getStatusCode()), HttpMethod.GET);
\r
315 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
320 * Retrieves specified version of a particular policy type.
\r
322 * @param policyTypeId the ID of specified policy type
\r
323 * @param versionId the version of specified policy type
\r
325 * @return the Response object containing the results of the API operation
\r
327 @GetMapping("/policytypes/{policyTypeId}/versions/{versionId}")
\r
328 @ApiOperation(value = "Retrieve one particular version of a policy type",
\r
329 notes = "Returns a particular version for the specified policy type", response = ToscaServiceTemplate.class,
\r
330 responseHeaders = {
\r
331 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
332 description = VERSION_MINOR_DESCRIPTION,
\r
333 response = String.class),
\r
334 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
335 description = VERSION_PATCH_DESCRIPTION,
\r
336 response = String.class),
\r
337 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
338 response = String.class),
\r
339 @ResponseHeader(name = REQUEST_ID_NAME,
\r
340 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
341 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
343 @Extension(name = EXTENSION_NAME, properties = {
\r
344 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
345 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
346 @ApiResponses(value = {
\r
347 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
348 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
349 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
350 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
351 public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(
\r
352 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
353 @PathVariable("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
\r
354 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
355 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
357 ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, versionId);
\r
358 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
359 return makeOkResponse(requestId, serviceTemplate);
\r
360 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
361 var msg = String.format("GET /policytypes/%s/versions/%s", policyTypeId, versionId);
\r
362 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
363 .getStatusCode()), HttpMethod.GET);
\r
364 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
369 * Retrieves latest version of a particular policy type.
\r
371 * @param policyTypeId the ID of specified policy type
\r
373 * @return the Response object containing the results of the API operation
\r
375 @GetMapping("/policytypes/{policyTypeId}/versions/latest")
\r
376 @ApiOperation(value = "Retrieve latest version of a policy type",
\r
377 notes = "Returns latest version for the specified policy type", response = ToscaServiceTemplate.class,
\r
378 responseHeaders = {
\r
379 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
380 description = VERSION_MINOR_DESCRIPTION,
\r
381 response = String.class),
\r
382 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
383 description = VERSION_PATCH_DESCRIPTION,
\r
384 response = String.class),
\r
385 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
386 response = String.class),
\r
387 @ResponseHeader(name = REQUEST_ID_NAME,
\r
388 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
389 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
391 @Extension(name = EXTENSION_NAME, properties = {
\r
392 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
393 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
394 @ApiResponses(value = {
\r
395 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
396 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
397 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
398 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
399 public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(
\r
400 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
401 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
402 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
404 ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchLatestPolicyTypes(policyTypeId);
\r
405 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
\r
406 return makeOkResponse(requestId, serviceTemplate);
\r
407 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
408 var msg = String.format("GET /policytypes/%s/versions/latest", policyTypeId);
\r
409 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
410 .getStatusCode()), HttpMethod.GET);
\r
411 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
416 * Creates a new policy type.
\r
418 * @param body the body of policy type following TOSCA definition
\r
420 * @return the Response object containing the results of the API operation
\r
422 @PostMapping("/policytypes")
\r
423 @ApiOperation(value = "Create a new policy type", notes = "Client should provide TOSCA body of the new policy type",
\r
424 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
425 response = ToscaServiceTemplate.class,
\r
426 responseHeaders = {
\r
427 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
428 description = VERSION_MINOR_DESCRIPTION,
\r
429 response = String.class),
\r
430 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
431 description = VERSION_PATCH_DESCRIPTION,
\r
432 response = String.class),
\r
433 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
434 response = String.class),
\r
435 @ResponseHeader(name = REQUEST_ID_NAME,
\r
436 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
438 @Extension(name = EXTENSION_NAME, properties = {
\r
439 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
440 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
441 @ApiResponses(value = {
\r
442 @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
\r
443 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
444 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
445 @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
\r
446 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
447 public ResponseEntity<ToscaServiceTemplate> createPolicyType(
\r
448 @RequestBody @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,
\r
449 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
450 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
451 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
452 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));
\r
455 ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(body);
\r
456 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.POST);
\r
457 return makeOkResponse(requestId, serviceTemplate);
\r
458 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
459 final var msg = "POST /policytypes";
\r
460 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
461 .getStatusCode()), HttpMethod.POST);
\r
462 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
467 * Deletes specified version of a particular policy type.
\r
469 * @param policyTypeId the ID of specified policy type
\r
470 * @param versionId the version of specified policy type
\r
472 * @return the Response object containing the results of the API operation
\r
474 @DeleteMapping("/policytypes/{policyTypeId}/versions/{versionId}")
\r
475 @ApiOperation(value = "Delete one version of a policy type",
\r
476 notes = "Rule 1: pre-defined policy types cannot be deleted;"
\r
477 + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted."
\r
478 + "The parameterizing TOSCA policies must be deleted first;",
\r
479 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
\r
480 response = ToscaServiceTemplate.class,
\r
481 responseHeaders = {
\r
482 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
483 description = VERSION_MINOR_DESCRIPTION,
\r
484 response = String.class),
\r
485 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
486 description = VERSION_PATCH_DESCRIPTION,
\r
487 response = String.class),
\r
488 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
489 response = String.class),
\r
490 @ResponseHeader(name = REQUEST_ID_NAME,
\r
491 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
493 @Extension(name = EXTENSION_NAME, properties = {
\r
494 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
495 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
496 @ApiResponses(value = {
\r
497 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
498 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
499 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
500 @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
\r
501 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
502 public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(
\r
503 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
504 @PathVariable("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
\r
505 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
506 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
508 ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(policyTypeId, versionId);
\r
509 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.DELETE);
\r
510 return makeOkResponse(requestId, serviceTemplate);
\r
511 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
512 var msg = String.format("DELETE /policytypes/%s/versions/%s", policyTypeId, versionId);
\r
513 updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
514 .getStatusCode()), HttpMethod.DELETE);
\r
515 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
520 * Retrieves all versions of a particular policy.
\r
522 * @param policyTypeId the ID of specified policy type
\r
523 * @param policyTypeVersion the version of specified policy type
\r
525 * @return the Response object containing the results of the API operation
\r
527 @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
\r
529 value = "Retrieve all versions of a policy created for a particular policy type version",
\r
530 notes = "Returns a list of all versions of specified policy created for the specified policy type version",
\r
531 response = ToscaServiceTemplate.class,
\r
532 responseHeaders = {
\r
533 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
534 description = VERSION_MINOR_DESCRIPTION,
\r
535 response = String.class),
\r
536 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
537 description = VERSION_PATCH_DESCRIPTION,
\r
538 response = String.class),
\r
539 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
540 response = String.class),
\r
541 @ResponseHeader(name = REQUEST_ID_NAME,
\r
542 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
543 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy,"},
\r
545 @Extension(name = EXTENSION_NAME, properties = {
\r
546 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
547 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
\r
551 @ApiResponses(value = {
\r
552 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
553 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
554 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
555 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
\r
557 public ResponseEntity<ToscaServiceTemplate> getAllPolicies(
\r
558 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
559 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
560 required = true) String policyTypeVersion,
\r
561 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
562 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
563 @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
\r
564 + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
566 ToscaServiceTemplate serviceTemplate =
\r
567 policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);
\r
568 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
569 return makeOkResponse(requestId, serviceTemplate);
\r
570 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
571 var msg = String.format("GET /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
\r
572 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
573 .getStatusCode()), HttpMethod.GET);
\r
574 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
579 * Retrieves all versions of a particular policy.
\r
581 * @param policyTypeId the ID of specified policy type
\r
582 * @param policyTypeVersion the version of specified policy type
\r
583 * @param policyId the ID of specified policy
\r
585 * @return the Response object containing the results of the API operation
\r
587 @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}")
\r
588 @ApiOperation(value = "Retrieve all version details of a policy created for a particular policy type version",
\r
589 notes = "Returns a list of all version details of the specified policy", response = ToscaServiceTemplate.class,
\r
590 responseHeaders = {
\r
591 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
592 description = VERSION_MINOR_DESCRIPTION,
\r
593 response = String.class),
\r
594 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
595 description = VERSION_PATCH_DESCRIPTION,
\r
596 response = String.class),
\r
597 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
598 response = String.class),
\r
599 @ResponseHeader(name = REQUEST_ID_NAME,
\r
600 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
601 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
603 @Extension(name = EXTENSION_NAME, properties = {
\r
604 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
605 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
\r
609 @ApiResponses(value = {
\r
610 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
611 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
612 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
613 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
\r
615 public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(
\r
616 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
617 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
618 required = true) String policyTypeVersion,
\r
619 @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
\r
620 @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
621 @RequestParam(name = "mode", defaultValue = "bare")
\r
622 @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
\r
623 + " REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
625 ToscaServiceTemplate serviceTemplate =
\r
626 policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);
\r
627 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
628 return makeOkResponse(requestId, serviceTemplate);
\r
629 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
630 var msg = String.format("/policytypes/%s/versions/$s/policies/%s",
\r
631 policyTypeId, policyTypeVersion, policyId);
\r
632 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
633 .getStatusCode()), HttpMethod.GET);
\r
634 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
639 * Retrieves the specified version of a particular policy.
\r
641 * @param policyTypeId the ID of specified policy type
\r
642 * @param policyTypeVersion the version of specified policy type
\r
643 * @param policyId the ID of specified policy
\r
644 * @param policyVersion the version of specified policy
\r
646 * @return the Response object containing the results of the API operation
\r
648 @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")
\r
649 @ApiOperation(value = "Retrieve one version of a policy created for a particular policy type version",
\r
650 notes = "Returns a particular version of specified policy created for the specified policy type version",
\r
651 response = ToscaServiceTemplate.class,
\r
652 responseHeaders = {
\r
653 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
654 description = VERSION_MINOR_DESCRIPTION,
\r
655 response = String.class),
\r
656 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
657 description = VERSION_PATCH_DESCRIPTION,
\r
658 response = String.class),
\r
659 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
660 response = String.class),
\r
661 @ResponseHeader(name = REQUEST_ID_NAME,
\r
662 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
663 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
665 @Extension(name = EXTENSION_NAME, properties = {
\r
666 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
667 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
\r
671 @ApiResponses(value = {
\r
672 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
673 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
674 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
675 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
\r
677 public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(
\r
678 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
679 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
680 required = true) String policyTypeVersion,
\r
681 @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
\r
682 @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
\r
683 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
684 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
685 @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare policies"
\r
686 + " (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
688 ToscaServiceTemplate serviceTemplate =
\r
689 policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);
\r
690 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
691 return makeOkResponse(requestId, serviceTemplate);
\r
692 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
693 var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/%s",
\r
694 policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
695 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
696 .getStatusCode()), HttpMethod.GET);
\r
697 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
702 * Retrieves the latest version of a particular policy.
\r
704 * @param policyTypeId the ID of specified policy type
\r
705 * @param policyTypeVersion the version of specified policy type
\r
706 * @param policyId the ID of specified policy
\r
708 * @return the Response object containing the results of the API operation
\r
710 @GetMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/latest")
\r
711 @ApiOperation(value = "Retrieve the latest version of a particular policy",
\r
712 notes = "Returns the latest version of specified policy", response = ToscaServiceTemplate.class,
\r
713 responseHeaders = {
\r
714 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
715 description = VERSION_MINOR_DESCRIPTION,
\r
716 response = String.class),
\r
717 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
718 description = VERSION_PATCH_DESCRIPTION,
\r
719 response = String.class),
\r
720 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
721 response = String.class),
\r
722 @ResponseHeader(name = REQUEST_ID_NAME,
\r
723 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
724 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
726 @Extension(name = EXTENSION_NAME, properties = {
\r
727 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
728 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
729 @ApiResponses(value = {
\r
730 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
731 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
732 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
733 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
734 public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(
\r
735 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
736 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
737 required = true) String policyTypeVersion,
\r
738 @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
\r
739 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
740 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
741 @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, TERSE for bare "
\r
742 + "policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
744 ToscaServiceTemplate serviceTemplate =
\r
745 policyProvider.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);
\r
746 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
747 return makeOkResponse(requestId, serviceTemplate);
\r
748 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
749 var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/latest",
\r
750 policyTypeId, policyTypeVersion, policyId);
\r
751 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
752 .getStatusCode()), HttpMethod.GET);
\r
753 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
758 * Creates a new policy for a particular policy type and version.
\r
760 * @param policyTypeId the ID of specified policy type
\r
761 * @param policyTypeVersion the version of specified policy type
\r
762 * @param body the body of policy following TOSCA definition
\r
764 * @return the Response object containing the results of the API operation
\r
766 @PostMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
\r
767 @ApiOperation(value = "Create a new policy for a policy type version",
\r
768 notes = "Client should provide TOSCA body of the new policy",
\r
769 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
770 response = ToscaServiceTemplate.class,
\r
771 responseHeaders = {
\r
772 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
773 description = VERSION_MINOR_DESCRIPTION,
\r
774 response = String.class),
\r
775 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
776 description = VERSION_PATCH_DESCRIPTION,
\r
777 response = String.class),
\r
778 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
779 response = String.class),
\r
780 @ResponseHeader(name = REQUEST_ID_NAME,
\r
781 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
783 @Extension(name = EXTENSION_NAME, properties = {
\r
784 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
785 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
786 @ApiResponses(value = {
\r
787 @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
\r
788 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
789 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
790 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
791 @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
\r
792 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
793 public ResponseEntity<ToscaServiceTemplate> createPolicy(
\r
794 @PathVariable("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
\r
795 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
796 required = true) String policyTypeVersion,
\r
797 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
798 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
799 @RequestBody @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
\r
800 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
801 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
\r
802 "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));
\r
805 ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(policyTypeId, policyTypeVersion, body);
\r
806 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
\r
807 return makeOkResponse(requestId, serviceTemplate);
\r
808 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
809 var msg = String.format("POST /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
\r
810 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
811 .getStatusCode()), HttpMethod.POST);
\r
812 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
817 * Deletes the specified version of a particular policy.
\r
819 * @param policyTypeId the ID of specified policy type
\r
820 * @param policyTypeVersion the version of specified policy type
\r
821 * @param policyId the ID of specified policy
\r
822 * @param policyVersion the version of specified policy
\r
824 * @return the Response object containing the results of the API operation
\r
826 @DeleteMapping("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/"
\r
827 + "versions/{policyVersion}")
\r
828 @ApiOperation(value = "Delete a particular version of a policy",
\r
829 notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
\r
830 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
831 response = ToscaServiceTemplate.class,
\r
832 responseHeaders = {
\r
833 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
834 description = VERSION_MINOR_DESCRIPTION,
\r
835 response = String.class),
\r
836 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
837 description = VERSION_PATCH_DESCRIPTION,
\r
838 response = String.class),
\r
839 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
840 response = String.class),
\r
841 @ResponseHeader(name = REQUEST_ID_NAME,
\r
842 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
844 @Extension(name = EXTENSION_NAME, properties = {
\r
845 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
846 @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
\r
847 @ApiResponses(value = {
\r
848 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
849 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
850 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
851 @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
\r
852 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
853 public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicy(
\r
854 @PathVariable("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,
\r
855 @PathVariable("policyTypeVersion") @ApiParam(value = "Version of policy type",
\r
856 required = true) String policyTypeVersion,
\r
857 @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
\r
858 @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
\r
859 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
860 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
862 ToscaServiceTemplate serviceTemplate =
\r
863 policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
864 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
\r
865 return makeOkResponse(requestId, serviceTemplate);
\r
866 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
867 var msg = String.format("DELETE /policytypes/%s/versions/%s/policies/%s/versions/%s",
\r
868 policyTypeId, policyTypeVersion, policyId, policyVersion);
\r
869 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
870 .getStatusCode()), HttpMethod.DELETE);
\r
871 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
876 * Retrieves all the available policies.
\r
878 * @return the Response object containing the results of the API operation
\r
880 @GetMapping("/policies")
\r
881 @ApiOperation(value = "Retrieve all versions of available policies",
\r
882 notes = "Returns all version of available policies",
\r
883 response = ToscaServiceTemplate.class,
\r
884 responseHeaders = {
\r
885 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
886 description = VERSION_MINOR_DESCRIPTION,
\r
887 response = String.class),
\r
888 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
889 description = VERSION_PATCH_DESCRIPTION,
\r
890 response = String.class),
\r
891 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
892 response = String.class),
\r
893 @ResponseHeader(name = REQUEST_ID_NAME,
\r
894 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
895 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
897 @Extension(name = EXTENSION_NAME, properties = {
\r
898 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
899 @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
\r
903 @ApiResponses(value = {
\r
904 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
905 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
906 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
907 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
\r
909 public ResponseEntity<ToscaServiceTemplate> getPolicies(
\r
910 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
911 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
912 @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
\r
913 + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
915 ToscaServiceTemplate serviceTemplate =
\r
916 policyProvider.fetchPolicies(null, null, null, null, mode);
\r
917 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
918 return makeOkResponse(requestId, serviceTemplate);
\r
919 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
920 final var msg = "GET /policies/ --";
\r
921 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
922 .getStatusCode()), HttpMethod.GET);
\r
923 if (pfme.getErrorResponse().getResponseCode().equals(Status.NOT_FOUND)) {
\r
924 pfme.getErrorResponse().setErrorMessage(ERROR_MESSAGE_NO_POLICIES_FOUND);
\r
925 pfme.getErrorResponse().setErrorDetails(List.of(ERROR_MESSAGE_NO_POLICIES_FOUND));
\r
927 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
932 * Retrieves the specified version of a particular policy.
\r
934 * @param policyId the Name of specified policy
\r
935 * @param policyVersion the version of specified policy
\r
937 * @return the Response object containing the results of the API operation
\r
939 @GetMapping("/policies/{policyId}/versions/{policyVersion}")
\r
940 @ApiOperation(value = "Retrieve specific version of a specified policy",
\r
941 notes = "Returns a particular version of specified policy",
\r
942 response = ToscaServiceTemplate.class,
\r
943 responseHeaders = {
\r
944 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
945 description = VERSION_MINOR_DESCRIPTION,
\r
946 response = String.class),
\r
947 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
948 description = VERSION_PATCH_DESCRIPTION,
\r
949 response = String.class),
\r
950 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
951 response = String.class),
\r
952 @ResponseHeader(name = REQUEST_ID_NAME,
\r
953 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
954 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
956 @Extension(name = EXTENSION_NAME, properties = {
\r
957 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
958 @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
\r
962 @ApiResponses(value = {
\r
963 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
964 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
965 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
966 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
\r
968 public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(
\r
969 @PathVariable("policyId") @ApiParam(value = "Name of policy", required = true) String policyId,
\r
970 @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
\r
971 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
972 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
973 @RequestParam(name = "mode", defaultValue = "bare") @ApiParam("Fetch mode for policies, BARE for bare"
\r
974 + " policies (default), REFERENCED for fully referenced policies") PolicyFetchMode mode) {
\r
976 ToscaServiceTemplate serviceTemplate =
\r
977 policyProvider.fetchPolicies(null, null, policyId, policyVersion, mode);
\r
978 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
\r
979 return makeOkResponse(requestId, serviceTemplate);
\r
980 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
981 var msg = String.format("GET /policies/%s/versions/%s", policyId, policyVersion);
\r
982 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
983 .getStatusCode()), HttpMethod.GET);
\r
984 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
989 * Creates one or more new policies in one call.
\r
991 * @param body the body of policy following TOSCA definition
\r
993 * @return the Response object containing the results of the API operation
\r
995 @PostMapping("/policies")
\r
996 @ApiOperation(value = "Create one or more new policies",
\r
997 notes = "Client should provide TOSCA body of the new polic(ies)",
\r
998 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
999 response = ToscaServiceTemplate.class,
\r
1000 responseHeaders = {
\r
1001 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
1002 description = VERSION_MINOR_DESCRIPTION,
\r
1003 response = String.class),
\r
1004 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
1005 description = VERSION_PATCH_DESCRIPTION,
\r
1006 response = String.class),
\r
1007 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
1008 response = String.class),
\r
1009 @ResponseHeader(name = REQUEST_ID_NAME,
\r
1010 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
1012 @Extension(name = EXTENSION_NAME, properties = {
\r
1013 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
1014 @ExtensionProperty(name = LAST_MOD_NAME, value = "El Alto")})})
\r
1015 @ApiResponses(value = {
\r
1016 @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
\r
1017 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
1018 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
1019 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
1020 @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
\r
1021 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
1022 public ResponseEntity<ToscaServiceTemplate> createPolicies(
\r
1023 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
1024 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
\r
1025 @RequestBody @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
\r
1026 if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
\r
1027 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policies", toJson(body));
\r
1030 ToscaServiceTemplate serviceTemplate = policyProvider.createPolicies(body);
\r
1031 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
\r
1032 return makeOkResponse(requestId, serviceTemplate);
\r
1033 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
1034 final var msg = "POST /policies";
\r
1035 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
1036 .getStatusCode()), HttpMethod.POST);
\r
1037 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
1042 * Deletes the specified version of a particular policy.
\r
1044 * @param policyId the ID of specified policy
\r
1045 * @param policyVersion the version of specified policy
\r
1047 * @return the Response object containing the results of the API operation
\r
1049 @DeleteMapping("/policies/{policyId}/versions/{policyVersion}")
\r
1050 @ApiOperation(value = "Delete a particular version of a policy",
\r
1051 notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
\r
1052 authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
\r
1053 response = ToscaServiceTemplate.class,
\r
1054 responseHeaders = {
\r
1055 @ResponseHeader(name = VERSION_MINOR_NAME,
\r
1056 description = VERSION_MINOR_DESCRIPTION,
\r
1057 response = String.class),
\r
1058 @ResponseHeader(name = VERSION_PATCH_NAME,
\r
1059 description = VERSION_PATCH_DESCRIPTION,
\r
1060 response = String.class),
\r
1061 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
\r
1062 response = String.class),
\r
1063 @ResponseHeader(name = REQUEST_ID_NAME,
\r
1064 description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
\r
1066 @Extension(name = EXTENSION_NAME, properties = {
\r
1067 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
\r
1068 @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")})})
\r
1069 @ApiResponses(value = {
\r
1070 @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
\r
1071 @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
\r
1072 @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
\r
1073 @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
\r
1074 @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
\r
1075 public ResponseEntity<ToscaServiceTemplate> deleteSpecificPolicy(
\r
1076 @PathVariable("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
\r
1077 @PathVariable("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
\r
1078 @RequestHeader(name = REQUEST_ID_NAME, required = false)
\r
1079 @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
\r
1081 ToscaServiceTemplate serviceTemplate =
\r
1082 policyProvider.deletePolicy(null, null, policyId, policyVersion);
\r
1083 updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
\r
1084 return makeOkResponse(requestId, serviceTemplate);
\r
1085 } catch (PfModelException | PfModelRuntimeException pfme) {
\r
1086 var msg = String.format("DELETE /policies/%s/versions/%s", policyId, policyVersion);
\r
1087 updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
\r
1088 .getStatusCode()), HttpMethod.DELETE);
\r
1089 throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
\r
1093 @ExceptionHandler(value = {PolicyApiRuntimeException.class})
\r
1094 protected ResponseEntity<Object> handleException(PolicyApiRuntimeException ex) {
\r
1095 LOGGER.warn(ex.getMessage(), ex.getCause());
\r
1096 return makeErrorResponse(ex.getRequestId(), ex.getErrorResponse(),
\r
1097 ex.getErrorResponse().getResponseCode().getStatusCode());
\r
1100 private void updateApiStatisticsCounter(Target target, HttpStatus result, HttpMethod http) {
\r
1101 mgr.updateTotalApiCallCount();
\r
1104 updatePolicyStats(result, http);
\r
1107 updatePolicyTypeStats(result, http);
\r
1110 mgr.updateApiCallSuccessCount();
\r
1115 private void updatePolicyStats(HttpStatus result, HttpMethod http) {
\r
1116 if (result.equals(HttpStatus.OK)) {
\r
1119 mgr.updateApiCallSuccessCount();
\r
1120 mgr.updateTotalPolicyGetCount();
\r
1121 mgr.updatePolicyGetSuccessCount();
\r
1124 mgr.updateApiCallSuccessCount();
\r
1125 mgr.updateTotalPolicyPostCount();
\r
1126 mgr.updatePolicyPostSuccessCount();
\r
1129 mgr.updateApiCallSuccessCount();
\r
1130 mgr.updateTotalPolicyDeleteCount();
\r
1131 mgr.updatePolicyDeleteSuccessCount();
\r
1134 mgr.updateApiCallSuccessCount();
\r
1140 mgr.updateApiCallFailureCount();
\r
1141 mgr.updateTotalPolicyGetCount();
\r
1142 mgr.updatePolicyGetFailureCount();
\r
1145 mgr.updateApiCallFailureCount();
\r
1146 mgr.updateTotalPolicyPostCount();
\r
1147 mgr.updatePolicyPostFailureCount();
\r
1150 mgr.updateApiCallFailureCount();
\r
1151 mgr.updateTotalPolicyDeleteCount();
\r
1152 mgr.updatePolicyDeleteFailureCount();
\r
1155 mgr.updateApiCallFailureCount();
\r
1161 private void updatePolicyTypeStats(HttpStatus result, HttpMethod http) {
\r
1162 if (result.equals(HttpStatus.OK)) {
\r
1165 mgr.updateApiCallSuccessCount();
\r
1166 mgr.updateTotalPolicyTypeGetCount();
\r
1167 mgr.updatePolicyTypeGetSuccessCount();
\r
1170 mgr.updateApiCallSuccessCount();
\r
1171 mgr.updateTotalPolicyTypePostCount();
\r
1172 mgr.updatePolicyTypePostSuccessCount();
\r
1175 mgr.updateApiCallSuccessCount();
\r
1176 mgr.updateTotalPolicyTypeDeleteCount();
\r
1177 mgr.updatePolicyTypeDeleteSuccessCount();
\r
1180 mgr.updateApiCallSuccessCount();
\r
1186 mgr.updateApiCallFailureCount();
\r
1187 mgr.updateTotalPolicyTypeGetCount();
\r
1188 mgr.updatePolicyTypeGetFailureCount();
\r
1191 mgr.updateApiCallFailureCount();
\r
1192 mgr.updateTotalPolicyTypePostCount();
\r
1193 mgr.updatePolicyTypePostFailureCount();
\r
1196 mgr.updateApiCallFailureCount();
\r
1197 mgr.updateTotalPolicyTypeDeleteCount();
\r
1198 mgr.updatePolicyTypeDeleteFailureCount();
\r
1201 mgr.updateApiCallFailureCount();
\r