5047cb2663b5543db5091de44982dd7608aeb2d2
[policy/drools-pdp.git] / feature-healthcheck / src / main / java / org / onap / policy / drools / healthcheck / RestHealthCheck.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * feature-healthcheck
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.drools.healthcheck;
22
23 import io.swagger.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.Info;
26 import io.swagger.annotations.SwaggerDefinition;
27 import io.swagger.annotations.Tag;
28
29 import javax.ws.rs.GET;
30 import javax.ws.rs.Path;
31 import javax.ws.rs.Produces;
32 import javax.ws.rs.core.MediaType;
33 import javax.ws.rs.core.Response;
34
35 import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
36
37 @Path("/")
38 @Api
39 @Produces(MediaType.APPLICATION_JSON)
40 @SwaggerDefinition(
41     info = @Info(
42         description = "PDP-D Healthcheck Service",
43         version = "v1.0",
44         title = "PDP-D Healthcheck"
45     ),
46     consumes = {MediaType.APPLICATION_JSON},
47     produces = {MediaType.APPLICATION_JSON},
48     schemes = {SwaggerDefinition.Scheme.HTTP},
49     tags = {
50         @Tag(name = "pdp-d-healthcheck", description = "Drools PDP Healthcheck Operations")
51     }
52     )
53 public class RestHealthCheck {
54
55     @GET
56     @Path("healthcheck")
57     @Produces(MediaType.APPLICATION_JSON)
58     @ApiOperation(
59             value = "Perform a system healthcheck", 
60             notes = "Provides healthy status of the PDP-D plus the components defined in its "
61                 + "configuration by using a REST interface",
62             response = Reports.class
63             )
64     public Response healthcheck() {  
65         return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
66     }
67
68     @GET
69     @Path("healthcheck/configuration")
70     @Produces(MediaType.APPLICATION_JSON)
71     @ApiOperation(
72             value = "Configuration", 
73             notes = "Provides the Healthcheck server configuration and monitored REST clients",
74             response = HealthCheck.class
75             )
76     public HealthCheck configuration() {  
77         return HealthCheck.monitor;
78     }
79 }