+ @Override
+ public AaiResponse<AaiGetVnfResponse> getVnfsByParamsForChangeManagement(String subscriberId, String serviceType, @Nullable String nfRole,
+ @Nullable String cloudRegion) {
+ String payloadAsString = "";
+ ResponseWithRequestInfo response;
+ ImmutableMap<String, Serializable> payload = getMapForAAIQueryByParams(subscriberId, serviceType,
+ nfRole, cloudRegion);
+ try {
+ payloadAsString = JACKSON_OBJECT_MAPPER.writeValueAsString(payload);
+ } catch (JsonProcessingException e) {
+ logger.error(e.getMessage());
+ ExceptionUtils.rethrow(e);
+ }
+ response = doAaiPut(QUERY_FORMAT_SIMPLE, payloadAsString, false, false);
+ AaiResponseWithRequestInfo<AaiGetVnfResponse> aaiResponse = processAaiResponse(response, AaiGetVnfResponse.class, false);
+ verifyAaiResponseValidityOrThrowExc(aaiResponse, aaiResponse.getAaiResponse().getHttpCode());
+ return aaiResponse.getAaiResponse();
+ }
+
+ private ImmutableMap<String, Serializable> getMapForAAIQueryByParams(String subscriberId,
+ String serviceType, @Nullable String nfRole, @Nullable String cloudRegion) {
+ // 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/" + encodePathSegment(subscriberId) + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances"),
+ "query", "query/vnfs-fromServiceInstance-filterByCloudRegion?nfRole=" + nfRole + "&cloudRegionID=" + cloudRegion + ""
+ );
+ }else {
+ return ImmutableMap.of(
+ "start", ImmutableList
+ .of("/business/customers/customer/" + encodePathSegment(subscriberId) + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances"),
+ "query", "query/vnfs-fromServiceInstance-filter?nfRole=" + nfRole + ""
+ );
+ }
+ }
+
+ if (cloudRegion != null){
+ return ImmutableMap.of(
+ "start", ImmutableList
+ .of("/business/customers/customer/" + encodePathSegment(subscriberId) + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances"),
+ "query", "query/vnfs-fromServiceInstance-filterByCloudRegion?cloudRegionID=" + cloudRegion + ""
+ );
+ }
+
+ return ImmutableMap.of(
+ "start", ImmutableList
+ .of("/business/customers/customer/" + encodePathSegment(subscriberId) + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances"),
+ "query", "query/vnfs-fromServiceInstance-filter"
+ );
+ }
+