WIP: Refactoring the Intent REST API.
NOTE: All changes are Work-in-Progress, and they are in the process
of being actively updated and refactored.
* The new implementation is in onos/core/intent/runtime/web
The old implementation in the onos/core/datagrid/web is kept until
the refactoring is completed.
* The new REST API base path is /wm/onos/intent
* The initial set of (new) APIs is the following:
- /wm/onos/intent/high
GET all high-level intent
POST (create) a collection of high-level intents
DELETE all intents
- /wm/onos/intent/high/{intent-id}
GET a high-level intent object
DELETE a high-level intent object
- /wm/onos/intent/low
GET all low-level intents
- /wm/onos/intent/low/{intent-id}
GET a low-level intent object
- /wm/onos/intent/path/switch/{src-dpid}/shortest-path/{dst-dpid}
GET a Shortest Path between two Switch DPIDs
* The Application-Level Intent object is specified in class
onos/api/intent/ApplicationIntent.java
TODO (list incomplete):
- Return the appropriate REST codes and return values for each REST operation
- Add the appropriate Java APIs so each REST call would make a single
Java call.
- If necessary, rename API class ApplicationIntent to something more
appropriate, and use it in the Java API.
- Re-think/refactor the ApplicationIntent so it becomes a more solid base for
all (high-level) intents.
- The corresponding Java APIs for each REST call should be synchronous
(for some definition of the expected operation outcome).
- Implement intent/intents Java API delete operation that requires a
single call instead of two calls (delete and purge)
- Refactor the High and Low Level intents, such that they don't use
inheritance from a common base class.
- Cleanup the return Intent objects representation in JSON. E.g.,
the Dpid JSON should be just "dpid": <value> instead of
"dpid": {
"value": <value>
}
Change-Id: Ia994a2026f57a1f176c5321c1952325e3b986097
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/web/IntentWebRoutable.java b/src/main/java/net/onrc/onos/core/intent/runtime/web/IntentWebRoutable.java
new file mode 100644
index 0000000..4c32c47
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/web/IntentWebRoutable.java
@@ -0,0 +1,49 @@
+package net.onrc.onos.core.intent.runtime.web;
+
+import net.floodlightcontroller.restserver.RestletRoutable;
+
+import org.restlet.Context;
+import org.restlet.Restlet;
+import org.restlet.routing.Router;
+
+/**
+ * REST API implementation for the Intents.
+ */
+public class IntentWebRoutable implements RestletRoutable {
+ /**
+ * Creates the Restlet router and bind to the proper resources.
+ */
+ @Override
+ public Restlet getRestlet(Context context) {
+ Router router = new Router(context);
+ // GET all high-level intents
+ // POST (create) a collection of high-level intents
+ // DELETE all intents (TODO: delete a collection of high-level intents)
+ router.attach("/high", IntentHighResource.class);
+
+ // GET a high-level intent object
+ // PUT (update) a high-level intent object (entire object) (LATER?)
+ // DELETE a high-level intent object
+ router.attach("/high/{intent-id}", IntentHighObjectResource.class);
+
+ // GET all low-level intents
+ router.attach("/low", IntentLowResource.class);
+
+ // GET a low-level intent object
+ router.attach("/low/{intent-id}", IntentLowObjectResource.class);
+
+ // GET a Shortest Path between two Switch DPIDs
+ router.attach("/path/switch/{src-dpid}/shortest-path/{dst-dpid}",
+ ShortestPathResource.class);
+
+ return router;
+ }
+
+ /**
+ * Sets the base path for the Intents.
+ */
+ @Override
+ public String basePath() {
+ return "/wm/onos/intent";
+ }
+}