Fixing device key REST API bugs and adding json definitions.

Change-Id: I41a98702e781544fe6e0bebe3e281ff2bcd9a6fa
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/DeviceKeyWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/DeviceKeyWebResource.java
index 3e78825..c4020e1 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/DeviceKeyWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/DeviceKeyWebResource.java
@@ -56,9 +56,8 @@
      * Returns array of all device keys.
      *
      * @return 200 OK
+     * @onos.rsModel Devicekeys
      */
-// FIXME DeviceKeysGet.json not found
-//   * @onos.rsModel DeviceKeysGet
     @GET
     public Response getDeviceKeys() {
         Iterable<DeviceKey> deviceKeys = get(DeviceKeyService.class).getDeviceKeys();
@@ -69,11 +68,10 @@
      * Get a single device key by device key unique identifier.
      * Returns the specified device key.
      *
-     * @param id device identifier
-     * @return 200 OK
+     * @param id device key identifier
+     * @return 200 OK, 404 not found
+     * @onos.rsModel Devicekey
      */
-// FIXME DeviceKeyGet.json not found
-//   * @onos.rsModel DeviceKeyGet
     @GET
     @Path("{id}")
     public Response getDeviceKey(@PathParam("id") String id) {
@@ -83,14 +81,13 @@
     }
 
     /**
-     * Adds a new device key from the JSON request.
+     * Adds a new device key from the JSON input stream.
      *
-     * @param stream input JSON
+     * @param stream device key JSON stream
      * @return status of the request - CREATED if the JSON is correct,
      * BAD_REQUEST if the JSON is invalid
+     * @onos.rsModel Devicekey
      */
-// FIXME wrong schema definition?
-//   * @onos.rsModel IntentHost
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
@@ -117,8 +114,8 @@
     /**
      * Removes a device key by device key identifier.
      *
-     * @param id device identifier
-     * @return 200 OK
+     * @param id device key identifier
+     * @return 200 OK, 404 not found
      */
     @DELETE
     @Path("{id}")
diff --git a/web/api/src/main/resources/definitions/Devicekey.json b/web/api/src/main/resources/definitions/Devicekey.json
new file mode 100644
index 0000000..a8bee2d
--- /dev/null
+++ b/web/api/src/main/resources/definitions/Devicekey.json
@@ -0,0 +1,35 @@
+{
+  "type": "object",
+  "title": "Devicekey",
+  "required": [
+    "id",
+    "type",
+    "label"
+  ],
+  "properties": {
+    "id": {
+      "type": "String",
+      "example": "Device key unique identifier"
+    },
+    "type": {
+      "type": "String",
+      "example": "COMMUNITY_NAME, OR USERNAME_PASSWORD"
+    },
+    "label": {
+      "type": "String",
+      "example": "Device key user label"
+    },
+    "community_name": {
+      "type": "String",
+      "example": "Device key community name"
+    },
+    "username": {
+      "type": "String",
+      "example": "Device key username"
+    },
+    "password": {
+      "type": "String",
+      "example": "Device key password"
+    }
+  }
+}
diff --git a/web/api/src/main/resources/definitions/Devicekeys.json b/web/api/src/main/resources/definitions/Devicekeys.json
new file mode 100644
index 0000000..57871f5
--- /dev/null
+++ b/web/api/src/main/resources/definitions/Devicekeys.json
@@ -0,0 +1,51 @@
+{
+  "type": "object",
+  "title": "Devicekeys",
+  "required": [
+    "keys"
+  ],
+  "properties": {
+    "keys": {
+      "type": "array",
+      "xml": {
+        "name": "keys",
+        "wrapped": true
+      },
+      "items": {
+        "type": "object",
+        "title": "key",
+        "required": [
+          "id",
+          "type",
+          "label"
+        ],
+        "properties": {
+          "id": {
+            "type": "String",
+            "example": "Device key unique identifier"
+          },
+          "type": {
+            "type": "String",
+            "example": "COMMUNITY_NAME, OR USERNAME_PASSWORD"
+          },
+          "label": {
+            "type": "String",
+            "example": "Device key user label"
+          },
+          "community_name": {
+            "type": "String",
+            "example": "Device key community name"
+          },
+          "username": {
+            "type": "String",
+            "example": "Device key username"
+          },
+          "password": {
+            "type": "String",
+            "example": "Device key password"
+          }
+        }
+      }
+    }
+  }
+}