2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * SPDX-License-Identifier: Apache-2.0
21 * ============LICENSE_END=========================================================
24 package org.onap.policy.api.main.rest;
26 import io.swagger.annotations.Api;
27 import io.swagger.annotations.ApiOperation;
28 import io.swagger.annotations.Info;
29 import io.swagger.annotations.SwaggerDefinition;
30 import io.swagger.annotations.Tag;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.Produces;
34 import javax.ws.rs.core.MediaType;
35 import javax.ws.rs.core.Response;
36 import org.onap.policy.common.endpoints.report.HealthCheckReport;
39 * Class to provide REST API services.
43 @Produces(MediaType.APPLICATION_JSON)
45 info = @Info(description = "Policy Api Service", version = "v2.0", title = "Policy Api"),
46 consumes = { MediaType.APPLICATION_JSON }, produces = { MediaType.APPLICATION_JSON },
47 schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS },
48 tags = { @Tag(name = "policy-api", description = "Policy Api Service Operations") })
49 public class ApiRestController {
53 @Produces(MediaType.APPLICATION_JSON)
54 @ApiOperation(value = "Perform a system healthcheck",
55 notes = "Provides healthy status of the Policy Api component", response = HealthCheckReport.class)
56 public Response healthcheck() {
57 return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
62 @Produces(MediaType.APPLICATION_JSON)
63 @ApiOperation(value = "Fetch current statistics",
64 notes = "Provides current statistics of the Policy API component",
65 response = StatisticsReport.class)
66 public Response statistics() {
67 return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build();