From e01546664d8d945ae83c625ab278b04ee0b9a331 Mon Sep 17 00:00:00 2001 From: tragait Date: Thu, 23 Jul 2020 17:49:06 +0100 Subject: [SO] create service upgrade workflow Issue-ID: SO-2925 Signed-off-by: tragait Change-Id: Ia10497fed1f42dea3e0469bc08ba0169862d3e71 Signed-off-by: tragait --- .../onap/aaiclient/client/aai/AAIRestClientI.java | 7 +++++++ .../aaiclient/client/aai/AAIRestClientImpl.java | 24 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'graph-inventory/aai-client/src/main/java/org') diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java index ef6ca00a32..3b08761568 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java @@ -26,6 +26,7 @@ import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.ServiceInstance; public interface AAIRestClientI { @@ -40,4 +41,10 @@ public interface AAIRestClientI { void createPnf(String pnfId, Pnf pnf); void updatePnf(String pnfId, Pnf pnf); + + Optional getServiceInstanceById(String serviceInstanceId, String serviceType, + String globalSubscriberId); + + void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId, + ServiceInstance serviceInstance); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java index 886891a34e..0aff965ac0 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java @@ -31,14 +31,18 @@ import javax.ws.rs.core.Response; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aaiclient.client.aai.entities.CustomQuery; import org.onap.aaiclient.client.aai.entities.Results; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.graphinventory.Format; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AAIRestClientImpl implements AAIRestClientI { + private final Logger log = LoggerFactory.getLogger(getClass()); private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; @Override @@ -97,4 +101,24 @@ public class AAIRestClientImpl implements AAIRestClientI { public void updatePnf(String pnfId, Pnf pnf) { new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); } + + @Override + public Optional getServiceInstanceById(String globalSubscriberId, String serviceType, + String serviceInstanceId) { + Response response = new AAIResourcesClient().getFullResponse(AAIUriFactory + .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)); + return Optional.ofNullable(response.readEntity(ServiceInstance.class)); + } + + @Override + public void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId, + ServiceInstance serviceInstance) { + try { + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, serviceType, serviceInstanceId), serviceInstance); + } catch (Throwable ex) { + log.error("Exception happened while updating ServiceInstance, Exception: {}", ex.getLocalizedMessage()); + throw new RuntimeException(ex); + } + } } -- cgit 1.2.3-korg