blob: 18ea729a402c941d257726a7f108de5081eaa38f [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM Core
4 * ================================================================================
5 * Copyright (C) 2018 Netsia
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
22
23package org.onap.osam.controller;
24
25import lombok.extern.slf4j.Slf4j;
26import org.onap.osam.api.service.AccessPodService;
27import org.onap.osam.api.service.DeviceService;
Aharoni, Pavel (pa0916)0a8080c2018-11-22 15:45:19 +020028import org.onap.osam.common.dto.AccessPodDTO;
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +030029import org.onap.osam.helper.DTOMapper;
30import org.onap.osam.model.dao.AccessPod;
31import org.onap.osam.model.dao.Chassis;
32import org.springframework.beans.factory.annotation.Autowired;
33import org.springframework.http.ResponseEntity;
34import org.springframework.web.bind.annotation.GetMapping;
35import org.springframework.web.bind.annotation.PathVariable;
36import org.springframework.web.bind.annotation.RequestMapping;
37import org.springframework.web.bind.annotation.RestController;
38
39import java.util.List;
40
41/**
42 * Created by cemturker on 03.10.2018.
43 */
44@RestController
45@RequestMapping("topology")
46@Slf4j
47public class TopologyController extends AbstractController {
48 private AccessPodService accessPodService;
49 private DeviceService deviceService;
50
51 @Autowired
52 public TopologyController(AccessPodService accessPodService,
53 DeviceService deviceService) {
54 super(log);
55 this.accessPodService = accessPodService;
56 this.deviceService = deviceService;
57 }
58
59 @GetMapping("/accessPod/{pnfId}")
60 public ResponseEntity<AccessPodDTO> getTopologyWithPnfId(@PathVariable("pnfId") String pnfId) {
61 try{
62 log.info("GetTopology with pnfId:{} is received.",pnfId);
63 AccessPod accessPod = accessPodService.findByPnfId(pnfId);
64 List<Chassis> chassisList = deviceService.getByPnfId(pnfId);
65 return ResponseEntity.ok(DTOMapper.representTheAccessPod(chassisList,accessPod));
66 }catch (Exception e) {
67 return super.proceedException(e);
68 }
69 }
70}