[ONOS-3394] Json models for REST api

Change-Id: I69c396ae08d25e83dce31e4d2ec92cd9a28c54f5
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
index 636fc33..b38633b 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java
@@ -44,6 +44,7 @@
      * Get all installed applications.
      * Returns array of all installed applications.
      *
+     * @rsModel Applications
      * @return 200 OK
      */
     @GET
@@ -56,7 +57,7 @@
     /**
      * Get application details.
      * Returns details of the specified application.
-     *
+     * @rsModel Application
      * @param name application name
      * @return 200 OK; 404; 401
      */
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java
index 312f6e3..16a4dc7 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java
@@ -49,6 +49,7 @@
      * Returns array of all cluster nodes.
      *
      * @return 200 OK
+     * @rsModel Cluster
      */
     @GET
     public Response getClusterNodes() {
@@ -62,6 +63,7 @@
      *
      * @param id cluster node identifier
      * @return 200 OK
+     * @rsModel ClusterNode
      */
     @GET
     @Path("{id}")
@@ -78,6 +80,7 @@
      * @param config cluster definition
      * @return 200 OK
      * @throws IOException to signify bad request
+     * @rsModel ClusterPost
      */
     @POST
     @Path("configuration")
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
index 0e88e34..252a3ba 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java
@@ -58,7 +58,7 @@
 
     /**
      * Get all flow entries. Returns array of all flow rules in the system.
-     *
+     * @rsModel Flows
      * @return array of all the intents in the system
      */
     @GET
@@ -80,7 +80,7 @@
     /**
      * Get flow entries of a device. Returns array of all flow rules for the
      * specified device.
-     *
+     * @rsModel Flows
      * @param deviceId device identifier
      * @return flow data as an array
      */
@@ -103,7 +103,7 @@
     /**
      * Get flow rule. Returns the flow entry specified by the device id and
      * flow rule id.
-     *
+     * @rsModel Flows
      * @param deviceId device identifier
      * @param flowId   flow rule identifier
      * @return flow data as an array
@@ -130,7 +130,7 @@
     /**
      * Create new flow rule. Creates and installs a new flow rule for the
      * specified device.
-     *
+     * @rsModel FlowsPost
      * @param deviceId device identifier
      * @param stream   flow rule JSON
      * @return status of the request - CREATED if the JSON is correct,
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
index b89f5ad..455e492 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
@@ -70,6 +70,7 @@
      * Returns array of all known end-station hosts.
      *
      * @return 200 OK
+     * @rsModel Hosts
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -85,6 +86,7 @@
      *
      * @param id host identifier
      * @return 200 OK
+     * @rsModel Host
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -103,6 +105,7 @@
      * @param mac  host MAC address
      * @param vlan host VLAN identifier
      * @return 200 OK
+     * @rsModel Host
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -122,6 +125,7 @@
      * @param stream input JSON
      * @return status of the request - CREATED if the JSON is correct,
      * BAD_REQUEST if the JSON is invalid
+     * @rsModel HostPut
      */
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
@@ -195,6 +199,7 @@
             while (ipStrings.hasNext()) {
                 ips.add(IpAddress.valueOf(ipStrings.next().asText()));
             }
+            //TODO remove elements from json node after reading them
             SparseAnnotations annotations = annotations(node);
             // Update host inventory
 
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java
index c627019..e36ea8a 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java
@@ -44,7 +44,7 @@
     /**
      * Get infrastructure links.
      * Returns array of all links, or links for the specified device or port.
-     *
+     * @rsModel LinksGet
      * @param deviceId  (optional) device identifier
      * @param port      (optional) port number
      * @param direction (optional) direction qualifier
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java
index 9714690..c14b4ec 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java
@@ -60,7 +60,7 @@
     /**
      * Get all shortest paths between any two hosts or devices.
      * Returns array of all shortest paths between any two elements.
-     *
+     * @rsModel Paths
      * @param src source identifier
      * @param dst destination identifier
      * @return path data
@@ -79,7 +79,7 @@
     /**
      * Get all shortest disjoint paths between any two hosts or devices.
      * Returns array of all shortest disjoint paths between any two elements.
-     *
+     * @rsModel Paths
      * @param src source identifier
      * @param dst destination identifier
      * @return path data
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java
index c91cb6d..7a45204 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java
@@ -59,7 +59,7 @@
 
     /**
      * Get load statistics for all links or for a specific link.
-     *
+     * @rsModel StatisticsFlowsLink
      * @param deviceId (optional) device ID for a specific link
      * @param port (optional) port number for a specified link
      * @return JSON encoded array lof Load objects
@@ -101,7 +101,7 @@
 
     /**
      * Get table statistics for all tables of all devices.
-     *
+     * @rsModel StatisticsFlowsTables
      * @return JSON encoded array of table statistics
      */
     @GET
@@ -111,11 +111,11 @@
         final FlowRuleService service = get(FlowRuleService.class);
         final Iterable<Device> devices = get(DeviceService.class).getDevices();
         final ObjectNode root = mapper().createObjectNode();
-        final ArrayNode rootArrayNode = root.putArray("device-table-statistics");
+        final ArrayNode rootArrayNode = root.putArray("statistics");
         for (final Device device : devices) {
             final ObjectNode deviceStatsNode = mapper().createObjectNode();
             deviceStatsNode.put("device", device.id().toString());
-            final ArrayNode statisticsNode = deviceStatsNode.putArray("table-statistics");
+            final ArrayNode statisticsNode = deviceStatsNode.putArray("table");
             final Iterable<TableStatisticsEntry> tableStatsEntries = service.getFlowTableStatistics(device.id());
             if (tableStatsEntries != null) {
                 for (final TableStatisticsEntry entry : tableStatsEntries) {
@@ -130,7 +130,7 @@
 
     /**
      * Get table statistics for all tables of a specified device.
-     *
+     * @rsModel StatisticsFlowsTables
      * @param deviceId device ID
      * @return JSON encoded array of table statistics
      */
@@ -142,11 +142,11 @@
         final Iterable<TableStatisticsEntry> tableStatisticsEntries =
                 service.getFlowTableStatistics(DeviceId.deviceId(deviceId));
         final ObjectNode root = mapper().createObjectNode();
-        final ArrayNode rootArrayNode = root.putArray("table-statistics");
+        final ArrayNode rootArrayNode = root.putArray("statistics");
 
         final ObjectNode deviceStatsNode = mapper().createObjectNode();
         deviceStatsNode.put("device", deviceId);
-        final ArrayNode statisticsNode = deviceStatsNode.putArray("table-statistics");
+        final ArrayNode statisticsNode = deviceStatsNode.putArray("table");
         for (final TableStatisticsEntry entry : tableStatisticsEntries) {
             statisticsNode.add(codec(TableStatisticsEntry.class).encode(entry, this));
         }
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java
index f6ae825..d51bd5a 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java
@@ -50,6 +50,7 @@
      * Get overview of current topology.
      *
      * @return topology overview
+     * @rsModel Topology
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -63,6 +64,7 @@
      * Get overview of topology SCCs.
      *
      * @return topology clusters overview
+     * @rsModel TopologyClusters
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -80,6 +82,7 @@
      *
      * @param clusterId id of the cluster to query
      * @return topology cluster details
+     * @rsModel TopologyCluster
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -103,6 +106,7 @@
      *
      * @param clusterId id of the cluster to query
      * @return topology cluster devices
+     * @rsModel TopologyClustersDevices
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -126,6 +130,7 @@
      *
      * @param clusterId id of the cluster to query
      * @return topology cluster links
+     * @rsModel LinksGet
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -136,7 +141,7 @@
 
         List<Link> links =
                 Lists.newArrayList(get(TopologyService.class)
-                        .getClusterLinks(topology, cluster));
+                                           .getClusterLinks(topology, cluster));
 
         return ok(encodeArray(Link.class, "links", links)).build();
     }
@@ -174,7 +179,8 @@
      *
      * @param connectPointString deviceid:portnumber
      * @return JSON representation of true if the connect point is broadcast,
-     *         false otherwise
+     * false otherwise
+     * @rsModel TopologyBroadcast
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -188,8 +194,8 @@
         boolean isBroadcast = get(TopologyService.class).isBroadcastPoint(topology, connectPoint);
 
         return ok(mapper()
-                .createObjectNode()
-                .put("broadcast", isBroadcast))
+                          .createObjectNode()
+                          .put("broadcast", isBroadcast))
                 .build();
     }
 
@@ -198,7 +204,8 @@
      *
      * @param connectPointString deviceid:portnumber
      * @return JSON representation of true if the connect point is broadcast,
-     *         false otherwise
+     * false otherwise
+     * @rsModel TopologyInfrastructure
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -212,8 +219,8 @@
         boolean isInfrastructure = get(TopologyService.class).isInfrastructure(topology, connectPoint);
 
         return ok(mapper()
-                .createObjectNode()
-                .put("infrastructure", isInfrastructure))
+                          .createObjectNode()
+                          .put("infrastructure", isInfrastructure))
                 .build();
     }