add rest serve and distribution framework
[multicloud/framework.git] / artifactbroker / main / src / main / java / org / onap / policy / distribution / main / rest / DistributionRestController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.distribution.main.rest;
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.common.endpoints.report.HealthCheckReport;
36
37 /**
38  * Class to provide distribution REST services.
39  *
40  * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
41  */
42 @Path("/")
43 @Api
44 @Produces(MediaType.APPLICATION_JSON)
45 @SwaggerDefinition(
46         info = @Info(description = "Policy Distribution Service", version = "v1.0", title = "Policy Distribution"),
47         consumes = { MediaType.APPLICATION_JSON }, produces = { MediaType.APPLICATION_JSON },
48         schemes = { SwaggerDefinition.Scheme.HTTP },
49         tags = { @Tag(name = "policy-distribution", description = "Policy Distribution Service Operations") })
50 public class DistributionRestController {
51
52     @GET
53     @Path("healthcheck")
54     @Produces(MediaType.APPLICATION_JSON)
55     @ApiOperation(value = "Perform a system healthcheck",
56             notes = "Provides healthy status of the Policy Distribution component", response = HealthCheckReport.class)
57     public Response healthcheck() {
58         return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
59     }
60
61     @GET
62     @Path("statistics")
63     @Produces(MediaType.APPLICATION_JSON)
64     @ApiOperation(value = "Fetch current statistics",
65             notes = "Provides current statistics of the Policy Distribution component",
66             response = StatisticsReport.class)
67     public Response statistics() {
68         return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build();
69     }
70 }