blob: 07ad80416b152fbea826d79ca1a2b5d379a606ed [file] [log] [blame]
Aharoni, Pavel (pa0916)0a8080c2018-11-22 15:45:19 +02001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
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 */
20package org.onap.osam.controllers;
21
22import io.swagger.annotations.ApiOperation;
23import org.onap.osam.common.dto.AccessPodDTO;
24import org.onap.osam.common.dto.ChassisDTO;
25import org.springframework.beans.factory.annotation.Autowired;
26import org.springframework.http.HttpEntity;
27import org.springframework.http.ResponseEntity;
28import org.springframework.web.bind.annotation.*;
29import org.springframework.web.client.RestTemplate;
30
31import java.util.Arrays;
32import java.util.List;
33
34// TODO log
35@RestController
36@RequestMapping("accessPod")
37public class OnapEnablerAccessPodController extends OnapEnablerController {
38
39 private static final String ACCESS_POD = "accessPod";
40
41 @Autowired
42 public OnapEnablerAccessPodController(RestTemplate restTemplate){
43 this.restTemplate = restTemplate;
44 }
45
46 @ApiOperation(value = "Get all PODs registered in OSAM Core",
47 response = AccessPodDTO.class,
48 responseContainer = "List")
49 @RequestMapping(method = RequestMethod.GET)
50 public List<AccessPodDTO> getAccessPods() {
51 return Arrays.asList(restTemplate.getForObject(buildRequestPath(ACCESS_POD), AccessPodDTO[].class));
52 }
53
54 @ApiOperation(value = "Register a new POD in OSAM Core",
55 response = AccessPodDTO.class)
56 @RequestMapping(method = RequestMethod.POST)
57 public ResponseEntity<AccessPodDTO> postAccessPod(@RequestBody AccessPodDTO accessPodDTO) {
58 return restTemplate.postForEntity(buildRequestPath(ACCESS_POD), new HttpEntity<>(accessPodDTO), AccessPodDTO.class);
59 }
60
61 @ApiOperation(value = "Unregister a POD from OSAM Core by pnfId field")
62 @RequestMapping(method = RequestMethod.DELETE, value = "pnf/{pnfId}")
63 public void deleteAccessPodByPnfId(@PathVariable String pnfId) {
64 restTemplate.delete(buildRequestPath(ACCESS_POD, "pnf", pnfId));
65 }
66
67 @ApiOperation(value = "Unregister a POD from OSAM Core by id field")
68 @RequestMapping(method = RequestMethod.DELETE, value = "{id}")
69 public void deleteAccessPod(@PathVariable Long id) {
70 restTemplate.delete(buildRequestPath(ACCESS_POD, String.valueOf(id)));
71 }
72
73
74
75}