Adding rest service for so monitoring
[so.git] / adapters / mso-requests-db-adapter / src / main / java / org / onap / so / adapters / requestsdb / InfraActiveRequestsRepositoryCustomController.java
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
26 import org.onap.so.db.request.beans.InfraActiveRequests;
27 import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
28 import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.web.bind.annotation.PathVariable;
31 import org.springframework.web.bind.annotation.RequestBody;
32 import org.springframework.web.bind.annotation.RequestMapping;
33 import org.springframework.web.bind.annotation.RequestMethod;
34 import org.springframework.web.bind.annotation.RequestParam;
35 import org.springframework.web.bind.annotation.RestController;
36
37 @RestController
38 public class InfraActiveRequestsRepositoryCustomController {
39
40     @Autowired
41     InfraActiveRequestsRepository infraActiveRequestsRepository;
42
43     @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
44     public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(@RequestBody Map<String, String> orchestrationMap) {
45         return infraActiveRequestsRepository.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
46     }
47
48     @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive")
49     public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(@RequestBody Map<String, List<String>> orchestrationMap) {
50         return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap);
51     }
52
53     @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
54     public InfraActiveRequests checkVnfIdStatus(@PathVariable("operationalEnvironmentId") String operationalEnvironmentId) {
55         return infraActiveRequestsRepository.checkVnfIdStatus(operationalEnvironmentId);
56     }
57
58     @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/checkInstanceNameDuplicate")
59     public InfraActiveRequests checkInstanceNameDuplicate(@RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) {
60         return infraActiveRequestsRepository.checkInstanceNameDuplicate(instanceNameDuplicateCheckRequest.getInstanceIdMap(), instanceNameDuplicateCheckRequest.getInstanceName(), instanceNameDuplicateCheckRequest.getRequestScope());
61     }
62     
63     @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/v1/getInfraActiveRequests")
64     public List<InfraActiveRequests> getInfraActiveRequests(@RequestBody Map<String, String[]> filters,
65             @RequestParam("from") long startTime, @RequestParam("to") long endTime,
66             @RequestParam(value = "maxResult", required = false) Integer maxResult) {
67         return infraActiveRequestsRepository.getInfraActiveRequests(filters, startTime, endTime, maxResult);
68     }
69 }