[ONOS-6547] Add method to obtain intent's installables in REST API.
Change-Id: I80bbb25ecda292bb4f658d0d76fd49d7fabe8732
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
index 7686a55..b21ca4e 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
@@ -18,7 +18,7 @@
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.core.CoreService;
-import org.onosproject.net.NetworkResource;
+import org.onosproject.net.Link;
import org.onosproject.net.ResourceGroup;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.Intent;
@@ -67,9 +67,16 @@
final ArrayNode jsonResources = result.putArray(RESOURCES);
- for (final NetworkResource resource : intent.resources()) {
- jsonResources.add(resource.toString());
- }
+ intent.resources()
+ .parallelStream()
+ .forEach(
+ resource -> {
+ if (resource instanceof Link) {
+ jsonResources.add(context.codec(Link.class).encode((Link) resource, context));
+ } else {
+ jsonResources.add(resource.toString());
+ }
+ });
IntentService service = context.getService(IntentService.class);
IntentState state = service.getIntentState(intent.key());