e8d9153219fe59cfff9400087a8f572d770e422c
[policy/drools-pdp.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.onap.policy.drools.server.restful;
21
22 import io.swagger.annotations.Api;
23 import io.swagger.annotations.ApiOperation;
24 import java.util.Properties;
25 import javax.ws.rs.Consumes;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.Path;
28 import javax.ws.rs.Produces;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
31 import org.onap.policy.common.endpoints.event.comm.TopicSource;
32 import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
33 import org.onap.policy.drools.legacy.config.LegacyConfigFeature;
34
35 /**
36  * REST Legacy Configuration Manager.
37  */
38
39 @Path("/policy/pdp/engine/legacy/config")
40 @Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
41 @Consumes({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
42 @Api
43 public class RestLegacyConfigManager {
44
45     /**
46      * GET properties.
47      */
48     @GET
49     @Path("properties")
50     @ApiOperation(value = "Retrieves the legacy configuration properties",
51             notes = "Legacy Configuration Properties", response = Properties.class)
52     public Response properties() {
53         return Response.status(Response.Status.OK)
54                        .entity(LegacyConfigFeature.getLegacyConfig().getProperties()).build();
55     }
56
57     /**
58      * GET the topic source.
59      */
60     @GET
61     @Path("topic/source")
62     @ApiOperation(value = "Retrieves the legacy configuration topic source",
63             notes = "Legacy Configuration Source", response = TopicSource.class)
64     public Response source() {
65         return Response.status(Response.Status.OK)
66                        .entity(LegacyConfigFeature.getLegacyConfig().getSource()).build();
67     }
68 }