Remove 'All rights reserved.' on apache 2 license
[externalapi/nbi.git] / src / main / java / org / onap / nbi / apis / serviceinventory / ServiceInventoryResource.java
1 /**
2  *     Copyright (c) 2018 Orange
3  *
4  *     Licensed under the Apache License, Version 2.0 (the "License");
5  *     you may not use this file except in compliance with the License.
6  *     You may obtain a copy of the License at
7  *
8  *         http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *     Unless required by applicable law or agreed to in writing, software
11  *     distributed under the License is distributed on an "AS IS" BASIS,
12  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *     See the License for the specific language governing permissions and
14  *     limitations under the License.
15  */
16 package org.onap.nbi.apis.serviceinventory;
17
18 import java.util.LinkedHashMap;
19 import java.util.List;
20 import org.onap.nbi.commons.JsonRepresentation;
21 import org.onap.nbi.commons.ResourceManagement;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.http.MediaType;
24 import org.springframework.http.ResponseEntity;
25 import org.springframework.util.MultiValueMap;
26 import org.springframework.web.bind.annotation.GetMapping;
27 import org.springframework.web.bind.annotation.PathVariable;
28 import org.springframework.web.bind.annotation.RequestMapping;
29 import org.springframework.web.bind.annotation.RequestParam;
30 import org.springframework.web.bind.annotation.RestController;
31
32 @RestController
33 @RequestMapping("/service")
34 public class ServiceInventoryResource extends ResourceManagement {
35
36     @Autowired
37     ServiceInventoryService serviceInventoryService;
38
39     @GetMapping(value = "/{serviceId}", produces = MediaType.APPLICATION_JSON_VALUE)
40     public ResponseEntity<Object> getServiceInventory(@PathVariable String serviceId,
41             @RequestParam MultiValueMap<String, String> params) {
42
43         LinkedHashMap response = serviceInventoryService.get(serviceId, params);
44
45         JsonRepresentation filter = new JsonRepresentation(params);
46         return this.getResponse(response, filter);
47
48     }
49
50     @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
51     public ResponseEntity<Object> findServiceInventory(@RequestParam MultiValueMap<String, String> params) {
52
53         List<LinkedHashMap> response = serviceInventoryService.find(params);
54         JsonRepresentation filter = new JsonRepresentation(params);
55         return this.findResponse(response, filter, null);
56
57     }
58
59
60 }