From 4e965d4d4f40e17841e329d0cff938b029aed89a Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Tue, 6 Aug 2019 19:23:29 +0300 Subject: add endpoints for getVpnList and getActiveNetworkList Issue-ID: VID-378 Signed-off-by: Eylon Malin Change-Id: Iede126556df337b1ab70dd76c9452f4b51e11376 --- .../org/onap/vid/controller/AaiController2.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'vid-app-common/src/main') diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java index 19187e0fc..d7d2f85db 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java @@ -20,10 +20,14 @@ package org.onap.vid.controller; +import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.onap.vid.aai.AaiClientInterface; import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.onap.vid.aai.model.Permissions; +import org.onap.vid.model.aaiTree.Network; import org.onap.vid.model.aaiTree.RelatedVnf; +import org.onap.vid.model.aaiTree.VpnBinding; import org.onap.vid.roles.RoleProvider; import org.onap.vid.services.AaiService; import org.springframework.beans.factory.annotation.Autowired; @@ -94,5 +98,22 @@ public class AaiController2 extends VidRestrictedBaseController { return aaiService.searchGroupMembers(globalCustomerId, serviceType, invariantId, groupType, groupRole); } + @RequestMapping(value = "/aai_get_vpn_list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public List getVpnList() { + return aaiService.getVpnListByVpnType("SERVICE-INFRASTRUCTURE"); + } + @RequestMapping(value = "/aai_get_active_networks", + method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public List getActiveNetworkList( + @RequestParam("cloudRegion") String cloudRegion, + @RequestParam("tenantId") String tenantId, + @RequestParam(value = "networkRole", required = false) String networkRole) { + return aaiService.getL3NetworksByCloudRegion(cloudRegion, tenantId, networkRole) + .stream() + .filter(Network::isBoundToVpn) + .filter(network -> StringUtils.isNotEmpty(network.getInstanceName())) + .filter(network -> StringUtils.equalsIgnoreCase(network.getOrchStatus(), "active")) + .collect(Collectors.toList()); + } } -- cgit 1.2.3-korg