3f51ba4667c5638594d963bd2664570f7ce916cc
[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 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 package org.onap.policy.drools.healthcheck;
21
22 import javax.ws.rs.GET;
23 import javax.ws.rs.Path;
24 import javax.ws.rs.Produces;
25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.Response;
27
28 import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
29
30 import io.swagger.annotations.Api;
31 import io.swagger.annotations.ApiOperation;
32 import io.swagger.annotations.Info;
33 import io.swagger.annotations.SwaggerDefinition;
34 import io.swagger.annotations.Tag;
35
36 @Path("/")
37 @Api
38 @Produces(MediaType.APPLICATION_JSON)
39 @SwaggerDefinition(
40     info = @Info(
41         description = "PDP-D Healthcheck Service",
42         version = "v1.0",
43         title = "PDP-D Healthcheck"
44     ),
45     consumes = {MediaType.APPLICATION_JSON},
46     produces = {MediaType.APPLICATION_JSON},
47     schemes = {SwaggerDefinition.Scheme.HTTP},
48     tags = {
49         @Tag(name = "pdp-d-healthcheck", description = "Drools PDP Healthcheck Operations")
50     }
51 )
52 public class RestHealthCheck {
53         
54     @GET
55     @Path("healthcheck")
56     @Produces(MediaType.APPLICATION_JSON)
57     @ApiOperation(
58                 value="Perform a system healthcheck", 
59                 notes="Provides healthy status of the PDP-D plus the components defined in its configuration by using a REST interface",
60                 response=Reports.class
61     )
62     public Response healthcheck() {  
63                 return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
64     }
65     
66     @GET
67     @Path("healthcheck/configuration")
68     @Produces(MediaType.APPLICATION_JSON)
69     @ApiOperation(
70                 value="Configuration", 
71                 notes="Provides the Healthcheck server configuration and monitored REST clients",
72                 response=HealthCheck.class
73     )
74     public HealthCheck configuration() {  
75         return HealthCheck.monitor;
76     }
77 }