From a95005030698acf9def8849f44e1649d0bcf00d8 Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Mon, 16 Sep 2019 13:37:01 +0300 Subject: Add cloud-region and nf-role as an optional search criteria Issue-ID: VID-596 Signed-off-by: Alexey Sandler Change-Id: I72d9c2c9dc3f39fcc3c87e083ac230d20135e979 --- .../src/main/java/org/onap/vid/aai/AaiClient.java | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java') diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index c82f5485e..644309d95 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -289,7 +289,7 @@ public class AaiClient implements AaiClientInterface { } @Override - public AaiResponse getVnfsByParamsForChangeManagement(String subscriberId, String serviceType, @Nullable String nfRole, + public AaiResponse getVnfsByParamsForChangeManagement(String subscriberId, String serviceType, @Nullable String nfRole, @Nullable String cloudRegion) { String payloadAsString = ""; ResponseWithRequestInfo response; @@ -302,19 +302,43 @@ public class AaiClient implements AaiClientInterface { ExceptionUtils.rethrow(e); } response = doAaiPut(QUERY_FORMAT_SIMPLE, payloadAsString, false, false); - AaiResponseWithRequestInfo aaiResponse = processAaiResponse(response, JsonNode.class, false); + AaiResponseWithRequestInfo aaiResponse = processAaiResponse(response, AaiGetVnfResponse.class, false); verifyAaiResponseValidityOrThrowExc(aaiResponse, aaiResponse.getAaiResponse().getHttpCode()); return aaiResponse.getAaiResponse(); } private ImmutableMap getMapForAAIQueryByParams(String subscriberId, String serviceType, @Nullable String nfRole, @Nullable String cloudRegion) { - String nfRoleParam = nfRole != null ? "?nfRole=" + nfRole : ""; - String query = "query/vnfs-fromServiceInstance-filter" + nfRoleParam; + // in a case cloudRegion is null using query/vnfs-fromServiceInstance-filter, + // otherwise using query/vnfs-fromServiceInstance-filterByCloudRegion + if (nfRole != null){ + if (cloudRegion != null){ + return ImmutableMap.of( + "start", ImmutableList + .of("/business/customers/customer/" + subscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances"), + "query", "query/vnfs-fromServiceInstance-filterByCloudRegion?nfRole=" + nfRole + "&cloudRegionID=" + cloudRegion + "" + ); + }else { + return ImmutableMap.of( + "start", ImmutableList + .of("/business/customers/customer/" + subscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances"), + "query", "query/vnfs-fromServiceInstance-filter?nfRole=" + nfRole + "" + ); + } + } + + if (cloudRegion != null){ + return ImmutableMap.of( + "start", ImmutableList + .of("/business/customers/customer/" + subscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances"), + "query", "query/vnfs-fromServiceInstance-filterByCloudRegion?cloudRegionID=" + cloudRegion + "" + ); + } + return ImmutableMap.of( "start", ImmutableList .of("/business/customers/customer/" + subscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances"), - "query", query + "query", "query/vnfs-fromServiceInstance-filter" ); } -- cgit 1.2.3-korg