summaryrefslogtreecommitdiffstats
path: root/graph-inventory
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@est.tech>2020-08-18 12:08:03 +0000
committerGerrit Code Review <gerrit@onap.org>2020-08-18 12:08:03 +0000
commit87260307fcdb8b4296558f564d36ad18653268cd (patch)
tree7ced2f21909f37d6a5214fc020af28768d6f3c08 /graph-inventory
parent78d36ba305b6544bcdac46fcb1b9fd8eddf20fa7 (diff)
parente01546664d8d945ae83c625ab278b04ee0b9a331 (diff)
Merge "[SO] create service upgrade workflow"
Diffstat (limited to 'graph-inventory')
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java7
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java24
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);
+ }
+ }
}