2adba81f9efb58d43d389a48cbb40f4821411e09
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
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 package org.onap.so.adapters.requestsdb;
22
23 import java.util.List;
24 import java.util.Map;
25 import org.onap.so.db.request.beans.InfraActiveRequests;
26 import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
27 import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.web.bind.annotation.PathVariable;
30 import org.springframework.web.bind.annotation.RequestBody;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.PostMapping;
33 import org.springframework.web.bind.annotation.GetMapping;
34 import org.springframework.web.bind.annotation.RequestMethod;
35 import org.springframework.web.bind.annotation.RequestParam;
36 import org.springframework.web.bind.annotation.RestController;
37
38 @RestController
39 public class InfraActiveRequestsRepositoryCustomController {
40
41     @Autowired
42     InfraActiveRequestsRepository infraActiveRequestsRepository;
43
44     @PostMapping(value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
45     public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
46             @RequestBody Map<String, String> orchestrationMap) {
47         return infraActiveRequestsRepository.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
48     }
49
50     @PostMapping(value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive")
51     public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
52             @RequestBody Map<String, List<String>> orchestrationMap) {
53         return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap);
54     }
55
56     @GetMapping(value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
57     public InfraActiveRequests checkVnfIdStatus(
58             @PathVariable("operationalEnvironmentId") String operationalEnvironmentId) {
59         return infraActiveRequestsRepository.checkVnfIdStatus(operationalEnvironmentId);
60     }
61
62     @PostMapping(value = "/infraActiveRequests/checkInstanceNameDuplicate")
63     public InfraActiveRequests checkInstanceNameDuplicate(
64             @RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) {
65         return infraActiveRequestsRepository.checkInstanceNameDuplicate(
66                 instanceNameDuplicateCheckRequest.getInstanceIdMap(),
67                 instanceNameDuplicateCheckRequest.getInstanceName(),
68                 instanceNameDuplicateCheckRequest.getRequestScope());
69     }
70
71     @PostMapping(value = "/infraActiveRequests/v1/getInfraActiveRequests")
72     public List<InfraActiveRequests> getInfraActiveRequests(@RequestBody Map<String, String[]> filters,
73             @RequestParam("from") long startTime, @RequestParam("to") long endTime,
74             @RequestParam(value = "maxResult", required = false) Integer maxResult) {
75         return infraActiveRequestsRepository.getInfraActiveRequests(filters, startTime, endTime, maxResult);
76     }
77
78     @GetMapping(value = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules")
79     public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() {
80         return infraActiveRequestsRepository.getInProgressVolumeGroupsAndVfModules();
81     }
82 }