VES Heartbeat and Software Management Feature
[oam/tr069-adapter.git] / netconf-server / src / main / java / org / commscope / tr069adapter / netconf / restapi / NetConfServerManagerRestApi.java
1 /*\r
2  * ============LICENSE_START========================================================================\r
3  * ONAP : tr-069-adapter\r
4  * =================================================================================================\r
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
6  * =================================================================================================\r
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
9  * may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
14  * either express or implied. See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  * ===============LICENSE_END=======================================================================\r
17  */\r
18 \r
19 package org.commscope.tr069adapter.netconf.restapi;\r
20 \r
21 import java.util.List;\r
22 \r
23 import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;\r
24 import org.commscope.tr069adapter.netconf.server.NetConfServerManagerImpl;\r
25 import org.slf4j.Logger;\r
26 import org.slf4j.LoggerFactory;\r
27 import org.springframework.beans.factory.annotation.Autowired;\r
28 import org.springframework.web.bind.annotation.GetMapping;\r
29 import org.springframework.web.bind.annotation.PostMapping;\r
30 import org.springframework.web.bind.annotation.RequestMapping;\r
31 import org.springframework.web.bind.annotation.RequestParam;\r
32 import org.springframework.web.bind.annotation.RestController;\r
33 \r
34 @RestController\r
35 @RequestMapping("/netConfServerManagerService")\r
36 public class NetConfServerManagerRestApi {\r
37 \r
38   private static final Logger LOG = LoggerFactory.getLogger(NetConfServerManagerRestApi.class);\r
39 \r
40   @Autowired\r
41   NetConfServerManagerImpl manager;\r
42 \r
43   @PostMapping("/createServer")\r
44   public NetConfServerDetails createNetConfServerInstance(@RequestParam String deviceId,\r
45       @RequestParam String enodeBName) {\r
46     LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}", deviceId,\r
47         enodeBName);\r
48     NetConfServerDetails serverDetails = manager.createServer(deviceId, enodeBName);\r
49     LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails);\r
50     return serverDetails;\r
51   }\r
52 \r
53   @GetMapping("/listServers")\r
54   public List<NetConfServerDetails> listNetConfServersInfo() {\r
55     LOG.info("Received request to list all NetConf Servers information");\r
56     List<NetConfServerDetails> serverDetails = manager.getServersInfo();\r
57     LOG.info("Successfully processed request to list all NetConf Servers information");\r
58     return serverDetails;\r
59   }\r
60 \r
61   @PostMapping("/unregisterServer")\r
62   public String unregisterNetConfServerInstance(@RequestParam String deviceId,\r
63       @RequestParam String enodeBName) {\r
64     LOG.info("Received request for Unregister NetConf Server for deviceID: {}, enodeBName: {} ",\r
65         deviceId, enodeBName);\r
66     String result = manager.unregister(deviceId, enodeBName);\r
67     LOG.info("Unregister request is processed. NetConf Server for deviceID: {} , unregisted= {}",\r
68         deviceId, result);\r
69     return result;\r
70   }\r
71 \r
72 }\r