diff options
author | tragait <rahul.tyagi@est.tech> | 2020-07-23 17:49:06 +0100 |
---|---|---|
committer | tragait <rahul.tyagi@est.tech> | 2020-08-18 11:40:36 +0100 |
commit | e01546664d8d945ae83c625ab278b04ee0b9a331 (patch) | |
tree | 8bafaa6365cd410a937c69444bef903f64665ad7 /graph-inventory/aai-client/src/main/java/org/onap/aaiclient | |
parent | c1b7f3805a5a3ed2ec8abcecb86f33415e4f0759 (diff) |
[SO] create service upgrade workflow
Issue-ID: SO-2925
Signed-off-by: tragait <rahul.tyagi@est.tech>
Change-Id: Ia10497fed1f42dea3e0469bc08ba0169862d3e71
Signed-off-by: tragait <rahul.tyagi@est.tech>
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient')
2 files changed, 31 insertions, 0 deletions
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<ServiceInstance> 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<ServiceInstance> 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); + } + } } |