2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019,2021 Nordix Foundation.
4 * Modifications Copyright (C) 2019 AT&T Intellectual Property.
5 * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.pap.main.rest;
25 import io.swagger.annotations.ApiOperation;
26 import io.swagger.annotations.ApiResponse;
27 import io.swagger.annotations.ApiResponses;
28 import io.swagger.annotations.Authorization;
29 import lombok.RequiredArgsConstructor;
30 import org.onap.policy.common.endpoints.report.HealthCheckReport;
31 import org.springframework.http.ResponseEntity;
32 import org.springframework.web.bind.annotation.GetMapping;
33 import org.springframework.web.bind.annotation.RequestMapping;
34 import org.springframework.web.bind.annotation.RestController;
37 * Class to provide REST endpoints for PAP component health check.
39 * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
42 @RequestMapping(path = "/policy/pap/v1")
43 @RequiredArgsConstructor
44 public class HealthCheckRestControllerV1 extends PapRestControllerV1 {
46 private final HealthCheckProvider provider;
48 @GetMapping("healthcheck")
49 @ApiOperation(value = "Perform healthcheck",
50 notes = "Returns healthy status of the Policy Administration component",
51 response = HealthCheckReport.class, authorizations = @Authorization(value = AUTHORIZATION_TYPE))
52 @ApiResponses(value = {@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
53 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
54 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)})
55 public ResponseEntity<HealthCheckReport> healthcheck() {
56 return ResponseEntity.ok().body(provider.performHealthCheck());