use of org.onap.aaiclient.client.aai.AAIRestClientI in project so by onap.
the class ServiceLevelRequestDispatcher method getAndSetPnfNameFromServiceInstance.
private void getAndSetPnfNameFromServiceInstance(final String serviceInstanceId, final String serviceType, final String globalSubscriberId, DelegateExecution delegateExecution) {
AAIRestClientI restClient = new AAIRestClientImpl();
Optional<ServiceInstance> optionalSi = restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
optionalSi.ifPresentOrElse(serviceInstance -> {
final List<String> pnfNameList = serviceInstance.getRelationshipList().getRelationship().stream().filter(x -> x.getRelatedTo().contains("pnf")).flatMap(x -> x.getRelationshipData().stream()).filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).map(x -> x.getRelationshipValue()).collect(Collectors.toList());
if (pnfNameList == null || pnfNameList.size() == 0) {
logger.warn("Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId());
return;
}
delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME_LIST, pnfNameList);
delegateExecution.setVariable(ServiceLevelConstants.PNF_SIZE, pnfNameList.size());
delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF);
}, () -> {
throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
});
}
use of org.onap.aaiclient.client.aai.AAIRestClientI in project so by onap.
the class UpdateServiceInstanceInAai method getAndSetServiceInstance.
private void getAndSetServiceInstance(final String serviceInstanceId, final String serviceType, final String globalSubscriberId, String modelVersionId) {
AAIRestClientI restClient = new AAIRestClientImpl();
Optional<ServiceInstance> optionalSi = restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
if (!optionalSi.isPresent()) {
// throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
}
ServiceInstance serviceInstance = optionalSi.get();
serviceInstance.setModelVersionId(modelVersionId);
restClient.updateServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, serviceInstance);
}
Aggregations