summaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client
diff options
context:
space:
mode:
Diffstat (limited to 'graph-inventory/aai-client')
-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);
+ }
+ }
}