Additions to the L2 monitoring for CFM and SOAM

Change-Id: I2d39dd9e1c4841c87cb0a27d82bb303ffd9c08fc
diff --git a/apps/cfm/BUCK b/apps/cfm/BUCK
index 7c8cb71..b1c299d 100644
--- a/apps/cfm/BUCK
+++ b/apps/cfm/BUCK
@@ -18,6 +18,10 @@
     deps = COMPILE_DEPS,
     test_deps = TEST_DEPS,
     web_context = '/onos/cfm',
+    api_title = 'L2 Monitoring CFM',
+    api_version = '1.0',
+    api_description = 'REST API for L2 Monitoring CFM',
+    api_package = 'org.onosproject.soam.rest',
 )
 
 onos_app (
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/impl/CfmWebApplication.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
similarity index 88%
rename from apps/cfm/src/main/java/org/onosproject/cfm/impl/CfmWebApplication.java
rename to apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
index f21b66d..13157f2 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/impl/CfmWebApplication.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package org.onosproject.cfm.impl;
+package org.onosproject.cfm.rest;
 
 import java.util.Set;
 
 import org.onlab.rest.AbstractWebApplication;
-import org.onosproject.soam.impl.DmWebResource;
-import org.onosproject.soam.impl.LmWebResource;
+import org.onosproject.soam.rest.DmWebResource;
+import org.onosproject.soam.rest.LmWebResource;
 
 /**
  * CFM REST API web application.
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MaWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MaWebResource.java
similarity index 98%
rename from apps/cfm/src/main/java/org/onosproject/cfm/impl/MaWebResource.java
rename to apps/cfm/src/main/java/org/onosproject/cfm/rest/MaWebResource.java
index c861314..85b7ac4 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MaWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MaWebResource.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cfm.impl;
+package org.onosproject.cfm.rest;
 
 import java.io.InputStream;
 import java.net.URI;
@@ -121,6 +121,7 @@
     /**
      * Create Maintenance Association by MD and MA name.
      *
+     * @onos.rsModel MaCreate
      * @param mdName The name of a Maintenance Domain
      * @param input A JSON formatted input stream specifying the MA parameters
      * @return 200 OK or 500 on error
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MdWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
similarity index 98%
rename from apps/cfm/src/main/java/org/onosproject/cfm/impl/MdWebResource.java
rename to apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
index ecf1fe9..c642f4a 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MdWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cfm.impl;
+package org.onosproject.cfm.rest;
 
 import java.io.InputStream;
 import java.net.URI;
@@ -125,6 +125,7 @@
     /**
      * Create Maintenance Domain.
      *
+     * @onos.rsModel MdCreate
      * @param input A JSON formatted input stream specifying the MA parameters
      * @return 200 OK, 304 if MD already exists or 500 on error
      */
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MepWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
similarity index 98%
rename from apps/cfm/src/main/java/org/onosproject/cfm/impl/MepWebResource.java
rename to apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
index 2486df0..fa8c728 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/impl/MepWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.cfm.impl;
+package org.onosproject.cfm.rest;
 
 import java.io.InputStream;
 import java.net.URI;
@@ -164,6 +164,7 @@
     /**
      * Create MEP with MD name, MA name and Mep Json.
      *
+     * @onos.rsModel MepCreate
      * @param mdName The name of a Maintenance Domain
      * @param maName The name of a Maintenance Association belonging to the MD
      * @param input A JSON formatted input stream specifying the Mep parameters
@@ -207,6 +208,7 @@
     /**
      * Transmit Loopback on MEP with MD name, MA name and Mep Id.
      *
+     * @onos.rsModel MepLbTransmit
      * @param mdName The name of a Maintenance Domain
      * @param maName The name of a Maintenance Association belonging to the MD
      * @param mepIdShort The id of a MEP belonging to the MA
@@ -296,6 +298,7 @@
     /**
      * Transmit Linktrace on MEP with MD name, MA name and Mep Id.
      *
+     * @onos.rsModel MepLtTransmit
      * @param mdName The name of a Maintenance Domain
      * @param maName The name of a Maintenance Association belonging to the MD
      * @param mepIdShort The id of a MEP belonging to the MA
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/impl/package-info.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/package-info.java
similarity index 94%
rename from apps/cfm/src/main/java/org/onosproject/cfm/impl/package-info.java
rename to apps/cfm/src/main/java/org/onosproject/cfm/rest/package-info.java
index 798317d..18fef69 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/impl/package-info.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/package-info.java
@@ -16,4 +16,4 @@
 /**
  * REST Web Application for CFM.
  */
-package org.onosproject.cfm.impl;
\ No newline at end of file
+package org.onosproject.cfm.rest;
\ No newline at end of file
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/web/RMepCodec.java b/apps/cfm/src/main/java/org/onosproject/cfm/web/RMepCodec.java
index 7edb204..ff4f775 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/web/RMepCodec.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/web/RMepCodec.java
@@ -53,10 +53,10 @@
             return null;
         }
 
-        JsonNode vidNode = json.get("rmep");
+        JsonNode rmepNode = json.get("rmep");
 
-        return MepId.valueOf(
-                    nullIsIllegal((short) vidNode.asInt(), "rmep is required"));
+        return MepId.valueOf((short)
+                    nullIsIllegal(rmepNode, "rmep is required").asInt());
 
     }
 
diff --git a/apps/cfm/src/main/java/org/onosproject/soam/impl/DmWebResource.java b/apps/cfm/src/main/java/org/onosproject/soam/rest/DmWebResource.java
similarity index 99%
rename from apps/cfm/src/main/java/org/onosproject/soam/impl/DmWebResource.java
rename to apps/cfm/src/main/java/org/onosproject/soam/rest/DmWebResource.java
index b732450..386ed8c 100644
--- a/apps/cfm/src/main/java/org/onosproject/soam/impl/DmWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/soam/rest/DmWebResource.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.soam.impl;
+package org.onosproject.soam.rest;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -173,6 +173,7 @@
     /**
      * Create DM with MD name, MA name, Mep id and DM Json.
      *
+     * @onos.rsModel DmCreate
      * @param mdName The name of a Maintenance Domain
      * @param maName The name of a Maintenance Association belonging to the MD
      * @param mepId The Id of the MEP belonging to the MEP
diff --git a/apps/cfm/src/main/java/org/onosproject/soam/impl/LmWebResource.java b/apps/cfm/src/main/java/org/onosproject/soam/rest/LmWebResource.java
similarity index 99%
rename from apps/cfm/src/main/java/org/onosproject/soam/impl/LmWebResource.java
rename to apps/cfm/src/main/java/org/onosproject/soam/rest/LmWebResource.java
index d889668..245396c 100644
--- a/apps/cfm/src/main/java/org/onosproject/soam/impl/LmWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/soam/rest/LmWebResource.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.soam.impl;
+package org.onosproject.soam.rest;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -171,6 +171,7 @@
     /**
      * Create LM with MD name, MA name, Mep id and LM Json.
      *
+     * @onos.rsModel LmCreate
      * @param mdName The name of a Maintenance Domain
      * @param maName The name of a Maintenance Association belonging to the MD
      * @param mepId The Id of the MEP belonging to the MEP
diff --git a/apps/cfm/src/main/java/org/onosproject/soam/impl/package-info.java b/apps/cfm/src/main/java/org/onosproject/soam/rest/package-info.java
similarity index 94%
rename from apps/cfm/src/main/java/org/onosproject/soam/impl/package-info.java
rename to apps/cfm/src/main/java/org/onosproject/soam/rest/package-info.java
index 370030f..6f53a35 100644
--- a/apps/cfm/src/main/java/org/onosproject/soam/impl/package-info.java
+++ b/apps/cfm/src/main/java/org/onosproject/soam/rest/package-info.java
@@ -16,4 +16,4 @@
 /**
  * REST Web Application for SOAM.
  */
-package org.onosproject.soam.impl;
\ No newline at end of file
+package org.onosproject.soam.rest;
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/DmCreate.json b/apps/cfm/src/main/resources/definitions/DmCreate.json
new file mode 100644
index 0000000..cab1af5
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/DmCreate.json
@@ -0,0 +1,219 @@
+{
+  "type": "object",
+  "title": "dm",
+  "required": [
+    "dm"
+  ],
+  "properties": {
+    "dm": {
+      "type": "object",
+      "title": "dmprops",
+      "required": [
+        "remoteMepId",
+        "dmCfgType",
+        "version",
+        "priority"
+      ],
+      "properties": {
+        "remoteMepId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 8191,
+          "description": "Remote MEP identifier",
+          "example": 20
+        },
+        "dmCfgType": {
+          "type": "string",
+          "enum": ["DMDMM","DM1DMTX", "DM1DMRX"],
+          "description": "The type of Delay Measurement to be performed",
+          "example": "DMDMM"
+        },
+        "version": {
+          "type": "string",
+          "enum": ["Y17312008","Y17312011"],
+          "description": "The version of Delay Measurement to be performed",
+          "example": "Y17312011"
+        },
+        "messagePeriodMs": {
+          "type": "uint32",
+          "description": "Message period in milliseconds",
+          "example": 100
+        },
+        "priority": {
+          "type": "string",
+          "enum": ["PRIO0","PRIO1","PRIO2","PRIO3","PRIO4","PRIO5","PRIO6","PRIO7"],
+          "description": "The Priority for the Delay Measurement",
+          "example": "PRIO3"
+        },
+        "frameSize": {
+          "type": "uint16",
+          "minimum": 64,
+          "maximum": 9600,
+          "description": "Frame size",
+          "example": 64
+        },
+        "measurementIntervalMins": {
+          "type": "uint16",
+          "description": "Measurement Interval in minutes",
+          "example": 15
+        },
+        "alignMeasurementIntervals": {
+          "type": "boolean",
+          "description": "Defines if measurement intervals are aligned with a zero offset to real time"
+        },
+        "alignMeasurementOffsetMins": {
+          "type": "uint16",
+          "description": "The offset in minutes from the time of day value",
+          "example": 0
+        },
+        "measurementsEnabled": {
+          "type": "array" ,
+          "xml": {
+            "name": "measurementsEnabled",
+            "wrapped": true
+          },
+          "items": {
+            "type": "string",
+            "enum": [
+              "SOAM_PDUS_SENT",
+              "SOAM_PDUS_RECEIVED",
+              "FRAME_DELAY_TWO_WAY_BINS",
+              "FRAME_DELAY_TWO_WAY_MIN",
+              "FRAME_DELAY_TWO_WAY_MAX",
+              "FRAME_DELAY_TWO_WAY_AVERAGE",
+              "FRAME_DELAY_FORWARD_BINS",
+              "FRAME_DELAY_FORWARD_MIN",
+              "FRAME_DELAY_FORWARD_MAX",
+              "FRAME_DELAY_FORWARD_AVERAGE",
+              "FRAME_DELAY_BACKWARD_BINS",
+              "FRAME_DELAY_BACKWARD_MIN",
+              "FRAME_DELAY_BACKWARD_MAX",
+              "FRAME_DELAY_BACKWARD_AVERAGE",
+              "INTER_FRAME_DELAY_VARIATION_FORWARD_BINS",
+              "INTER_FRAME_DELAY_VARIATION_FORWARD_MIN",
+              "INTER_FRAME_DELAY_VARIATION_FORWARD_MAX",
+              "INTER_FRAME_DELAY_VARIATION_FORWARD_AVERAGE",
+              "INTER_FRAME_DELAY_VARIATION_BACKWARD_BINS",
+              "INTER_FRAME_DELAY_VARIATION_BACKWARD_MIN",
+              "INTER_FRAME_DELAY_VARIATION_BACKWARD_MAX",
+              "INTER_FRAME_DELAY_VARIATION_BACKWARD_AVERAGE",
+              "INTER_FRAME_DELAY_VARIATION_TWO_WAY_BINS",
+              "INTER_FRAME_DELAY_VARIATION_TWO_WAY_MIN",
+              "INTER_FRAME_DELAY_VARIATION_TWO_WAY_MAX",
+              "INTER_FRAME_DELAY_VARIATION_TWO_WAY_AVERAGE",
+              "FRAME_DELAY_RANGE_FORWARD_BINS",
+              "FRAME_DELAY_RANGE_FORWARD_MAX",
+              "FRAME_DELAY_RANGE_FORWARD_AVERAGE",
+              "FRAME_DELAY_RANGE_BACKWARD_BINS",
+              "FRAME_DELAY_RANGE_BACKWARD_MAX",
+              "FRAME_DELAY_RANGE_BACKWARD_AVERAGE",
+              "FRAME_DELAY_RANGE_TWO_WAY_BINS",
+              "FRAME_DELAY_RANGE_TWO_WAY_MAX",
+              "FRAME_DELAY_RANGE_TWO_WAY_AVERAGE",
+              "MEASURED_STATS_FRAME_DELAY_TWO_WAY",
+              "MEASURED_STATS_FRAME_DELAY_FORWARD",
+              "MEASURED_STATS_FRAME_DELAY_BACKWARD",
+              "MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_TWO_WAY",
+              "MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_FORWARD",
+              "MEASURED_STATS_INTER_FRAME_DELAY_VARIATION_BACKWARD"
+            ],
+            "description": "A vector of bits that indicates the type of SOAM DM counters that are enabled"
+          },
+          "example": ["FRAME_DELAY_TWO_WAY_BINS","FRAME_DELAY_TWO_WAY_AVERAGE"]
+        },
+        "binsPerFdInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for Frame Delay measurements",
+          "example": 4
+        },
+        "binsPerIfdvInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for IFDV measurements",
+          "example": 4
+        },
+        "ifdvSelectionOffset": {
+          "type": "uint8",
+          "minimum": 2,
+          "description": "selection offset for Inter-Frame Delay Variation measurements",
+          "example": 2
+        },
+        "binsPerFdrInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for Frame Delay Range measurements",
+          "example": 4
+        },
+        "startTime": {
+          "type": "object",
+          "title": "startTime",
+          "description": "only one needs to be specified",
+          "properties": {
+            "immediate": {
+              "type": "boolean",
+              "description": "Should always be true if specified",
+              "example": true
+            },
+            "absolute": {
+              "type": "object",
+              "description": "Will be ignored if immediate is specified",
+              "properties": {
+                "start-time": {
+                  "type": "date-time",
+                  "example": "2017-11-11T12:00:00"
+                }
+              }
+            },
+            "relative": {
+              "type": "object",
+              "description": "Will be ignored if immediate or absolute is specified",
+              "properties": {
+                "start-time": {
+                  "type": "string",
+                  "description": "A period of time written as a Java Duration",
+                  "example": "PT10M"
+                }
+              }
+            }
+          },
+          "example": {"immediate": true}
+        },
+        "stopTime": {
+          "type": "object",
+          "title": "stopTime",
+          "description": "only one needs to be specified",
+          "properties": {
+            "none": {
+              "type": "boolean",
+              "description": "Should always be true if specified",
+              "example": true
+            },
+            "absolute": {
+              "type": "object",
+              "description": "Will be ignored if none is specified",
+              "properties": {
+                "start-time": {
+                  "type": "date-time",
+                  "example": "2017-11-11T12:00:00"
+                }
+              }
+            },
+            "relative": {
+              "type": "object",
+              "description": "Will be ignored if none or absolute is specified",
+              "properties": {
+                "start-time": {
+                  "type": "string",
+                  "description": "A period of time written as a Java Duration",
+                  "example": "PT10M"
+                }
+              }
+            }
+          },
+          "example": {"none": true}
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/LmCreate.json b/apps/cfm/src/main/resources/definitions/LmCreate.json
new file mode 100644
index 0000000..7afeaed
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/LmCreate.json
@@ -0,0 +1,296 @@
+{
+  "type": "object",
+  "title": "lm",
+  "required": [
+    "lm"
+  ],
+  "properties": {
+    "lm": {
+      "type": "object",
+      "title": "lmprops",
+      "required": [
+        "remoteMepId",
+        "lmCfgType",
+        "version",
+        "priority"
+      ],
+      "properties": {
+        "remoteMepId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 8191,
+          "description": "Remote MEP identifier",
+          "example": 20
+        },
+        "lmCfgType": {
+          "type": "string",
+          "enum": ["LMLMM","LMSLM", "LMCCM"],
+          "description": "The type of Loss Measurement to be performed",
+          "example": "LMLMM"
+        },
+        "version": {
+          "type": "string",
+          "enum": ["Y17312008","Y17312011"],
+          "description": "The version of Loss Measurement to be performed",
+          "example": "Y17312011"
+        },
+        "priority": {
+          "type": "string",
+          "enum": ["PRIO0","PRIO1","PRIO2","PRIO3","PRIO4","PRIO5","PRIO6","PRIO7"],
+          "description": "The Priority for the Delay Measurement",
+          "example": "PRIO3"
+        },
+        "countersEnabled": {
+          "type": "array" ,
+          "xml": {
+            "name": "countersEnabled",
+            "wrapped": true
+          },
+          "items": {
+            "type": "string",
+            "enum": [ "FORWARD_TRANSMITTED_FRAMES",
+              "FORWARD_RECEIVED_FRAMES","FORWARD_MIN_FLR","FORWARD_MAX_FLR","FORWARD_AVERAGE_FLR","BACKWARD_TRANSMITTED_FRAMES","BACKWARD_RECEIVED_FRAMES","BACKWARD_MIN_FLR","BACKWARD_MAX_FLR","BACKWARD_AVERAGE_FLR","SOAM_PDUS_SENT","SOAM_PDUS_RECEIVED","AVAILABILITY_FORWARD_HIGH_LOSS","AVAILABILITY_FORWARD_CONSECUTIVE_HIGH_LOSS","AVAILABILITY_FORWARD_AVAILABLE","AVAILABILITY_FORWARD_UNAVAILABLE","AVAILABILILITY_FORWARD_MIN_FLR","AVAILABILITY_FORWARD_MAX_FLR","AVAILABILITY_FORWARD_AVERAGE_FLR","AVAILABILITY_BACKWARD_HIGH_LOSS","AVAILABILITY_BACKWARD_CONSECUTIVE_HIGH_LOSS","AVAILABILITY_BACKWARD_AVAILABLE","AVAILABLE_BACKWARD_UNAVAILABLE","AVAILABLE_BACKWARD_MIN_FLR","AVAILABLE_BACKWARD_MAX_FLR","AVAILABLE_BACKWARD_AVERAGE_FLR","MEASURED_STATS_FORWARD_MEASURED_FLR","MEASURED_STATS_BACKWARD_MEASURED_FLR","MEASURED_STATS_AVAILABILITY_FORWARD_STATUS","MEASURED_STATS_AVAILABILITY_BACKWARD_STATUS"],
+            "description": "A vector of bits that indicates the type of SOAM LM counters that are enabled"
+          },
+          "example": ["FORWARD_RECEIVED_FRAMES","BACKWARD_RECEIVED_FRAMES","SOAM_PDUS_SENT","SOAM_PDUS_RECEIVED"]
+        },
+        "availabilityMeasurementIntervalMins": {
+          "type": "uint16",
+          "description": "The availability measurement interval in minutes",
+          "example": 15
+        },
+        "availabilityNumberConsecutiveFlrMeasurements": {
+          "type": "uint32",
+          "minimum": 10,
+          "maximum": 1000000,
+          "description": "configurable number of consecutive loss measurement PDUs",
+          "example": 100
+        },
+        "availabilityFlrThresholdPct": {
+          "type": "float",
+          "minimum": 0.0,
+          "maximum": 100.0,
+          "description": "configurable availability threshold to be used in evaluating the availability/unavailability status in percent",
+          "example": 50.0
+        },
+        "availabilityNumberConsecutiveIntervals": {
+          "type": "uint16",
+          "minimum": 0,
+          "maximum": 1000,
+          "description": "configurable number of consecutive availability indicators to be used to determine a change in the availability status",
+          "example": 10
+        },
+        "availabilityNumberConsecutiveHighFlr": {
+          "type": "uint16",
+          "minimum": 0,
+          "maximum": 1000,
+          "description": "configurable number of consecutive availability indicators to be used for assessing CHLI.",
+          "example": 10
+        },
+        "frameSize": {
+          "type": "uint16",
+          "minimum": 64,
+          "maximum": 9600,
+          "description": "Frame size",
+          "example": 64
+        },
+        "measurementIntervalMins": {
+          "type": "uint16",
+          "description": "Measurement Interval in minutes",
+          "example": 15
+        },
+        "alignMeasurementIntervals": {
+          "type": "boolean",
+          "description": "Defines if measurement intervals are aligned with a zero offset to real time"
+        },
+        "alignMeasurementOffsetMins": {
+          "type": "uint16",
+          "description": "The offset in minutes from the time of day value",
+          "example": 0
+        },
+        "messagePeriodMs": {
+          "type": "uint32",
+          "description": "Message period in milliseconds",
+          "example": 100
+        },
+        "thresholds": {
+          "type": "array" ,
+          "xml": {
+            "name": "thresholds",
+            "wrapped": true
+          },
+          "items": {
+            "type": "object",
+            "title": "thresholdProps",
+            "properties": {
+              "threshold": {
+                "type": "object",
+                "properties": {
+                  "id": {
+                    "type": "uint8",
+                    "description": "The id of the threshold",
+                    "example": 1
+                  },
+                  "thresholds": {
+                    "type": "array",
+                    "xml": {
+                      "name": "thresholds",
+                      "wrapped": true
+                    },
+                    "items": {
+                      "type": "string",
+                      "enum": [
+                        "MEASURED_FLR_FORWARD",
+                        "MAX_FLR_FORWARD",
+                        "AVERAGE_FLR_FORWARD",
+                        "MEASURED_FLR_BACKWARD",
+                        "MAX_FLR_BACKWARD",
+                        "AVERAGE_FLR_BACKWARD",
+                        "FORWARD_HIGH_LOSS",
+                        "FORWARD_CONSECUTIVE_HIGH_LOSS",
+                        "BACKWARD_HIGH_LOSS",
+                        "BACKWARD_CONSECUTIVE_HIGH_LOSS",
+                        "FORWARD_UNAVAILABLE_COUNT",
+                        "FORWARD_AVAILABLE_RATIO",
+                        "BACKWARD_UNAVAILABLE_COUNT",
+                        "BACKWARD_AVAILABLE_RATIO"
+                      ],
+                      "description": "A vector of bits that indicates the type of SOAM LM thresholds notifications that are enabled."
+                    },
+                    "example": [
+                      "MEASURED_FLR_FORWARD",
+                      "MAX_FLR_FORWARD",
+                      "AVERAGE_FLR_FORWARD"
+                    ]
+                  },
+                  "measuredFlrForward": {
+                    "type": "uint32",
+                    "description": "The measured forward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  },
+                  "maxFlrForward": {
+                    "type": "uint32",
+                    "description": "The maximum forward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  },
+                  "averageFlrForward": {
+                    "type": "uint32",
+                    "description": "The average forward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  },
+                  "measuredFlrBackward": {
+                    "type": "uint32",
+                    "description": "The measured backward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  },
+                  "maxFlrBackward": {
+                    "type": "uint32",
+                    "description": "The maximum backward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  },
+                  "averageFlrBackward": {
+                    "type": "uint32",
+                    "description": "The average backward frame loss ratio threshold value in milli Percent 1/100000",
+                    "example": 15
+                  }
+                }
+              }
+            }
+          }
+        },
+        "binsPerFdInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for Frame Delay measurements",
+          "example": 4
+        },
+        "binsPerIfdvInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for IFDV measurements",
+          "example": 4
+        },
+        "ifdvSelectionOffset": {
+          "type": "uint8",
+          "minimum": 2,
+          "description": "selection offset for Inter-Frame Delay Variation measurements",
+          "example": 2
+        },
+        "binsPerFdrInterval": {
+          "type": "uint8",
+          "minimum": 3,
+          "description": "The number of measurement bins per Measurement Interval for Frame Delay Range measurements",
+          "example": 4
+        },
+        "startTime": {
+          "type": "object",
+          "title": "startTime",
+          "description": "only one needs to be specified",
+          "properties": {
+            "immediate": {
+              "type": "boolean",
+              "description": "Should always be true if specified",
+              "example": true
+            },
+            "absolute": {
+              "type": "object",
+              "description": "Will be ignored if immediate is specified",
+              "properties": {
+                "start-time": {
+                  "type": "date-time",
+                  "example": "2017-11-11T12:00:00"
+                }
+              }
+            },
+            "relative": {
+              "type": "object",
+              "description": "Will be ignored if immediate or absolute is specified",
+              "properties": {
+                "start-time": {
+                  "type": "string",
+                  "description": "A period of time written as a Java Duration",
+                  "example": "PT10M"
+                }
+              }
+            }
+          },
+          "example": {"immediate": true}
+        },
+        "stopTime": {
+          "type": "object",
+          "title": "stopTime",
+          "description": "only one needs to be specified",
+          "properties": {
+            "none": {
+              "type": "boolean",
+              "description": "Should always be true if specified",
+              "example": true
+            },
+            "absolute": {
+              "type": "object",
+              "description": "Will be ignored if none is specified",
+              "properties": {
+                "start-time": {
+                  "type": "date-time",
+                  "example": "2017-11-11T12:00:00"
+                }
+              }
+            },
+            "relative": {
+              "type": "object",
+              "description": "Will be ignored if none or absolute is specified",
+              "properties": {
+                "start-time": {
+                  "type": "string",
+                  "description": "A period of time written as a Java Duration",
+                  "example": "PT10M"
+                }
+              }
+            }
+          },
+          "example": {"none": true}
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/MaCreate.json b/apps/cfm/src/main/resources/definitions/MaCreate.json
new file mode 100644
index 0000000..fea36db
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/MaCreate.json
@@ -0,0 +1,141 @@
+{
+  "type": "object",
+  "title": "ma",
+  "required": [
+    "ma"
+  ],
+  "properties": {
+    "ma": {
+      "type": "object",
+      "title": "maprops",
+      "required": [
+        "maName",
+        "maNameType"
+      ],
+      "properties": {
+        "maName": {
+          "type": "string",
+          "maxLength": 45,
+          "description": "MA identifier [a-zA-Z0-9-:.]",
+          "example": "ma-vlan-101"
+        },
+        "maNameType": {
+          "type": "string",
+          "enum": ["CHARACTERSTRING", "TWOOCTET", "ICCY1731", "PRIMARYVID", "RFC2685VPNID"],
+          "description": "MA identifier type",
+          "example": "CHARACTERSTRING"
+        },
+        "maNumericId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 32767,
+          "description": "Optional numeric id",
+          "example": 1
+        },
+        "ccm-interval": {
+          "type": "string",
+          "enum": ["INVALID", "INTERVAL_3MS", "INTERVAL_10MS", "INTERVAL_100MS", "INTERVAL_1S", "INTERVAL_10S", "INTERVAL_1MIN", "INTERVAL_10MIN"],
+          "description": "CCM interval for the Maintenance Association",
+          "example": "INTERVAL_1S"
+        },
+        "component-list": {
+          "type": "array" ,
+          "xml": {
+            "name": "components",
+            "wrapped": true
+          },
+          "items": {
+            "type": "object",
+            "title": "component",
+            "required": [
+              "component-id"
+            ],
+            "properties": {
+              "component": {
+                "type": "object",
+                "properties": {
+                  "component-id": {
+                    "type": "uint8",
+                    "minimum": 1,
+                    "maximum": 8,
+                    "description": "An id for the component",
+                    "example": 1
+                  },
+                  "vid-list": {
+                    "type": "array",
+                    "xml": {
+                      "name": "vid",
+                      "wrapped": true
+                    },
+                    "items": {
+                      "type": "object",
+                      "properties": {
+                        "vid": {
+                          "type": "uint16",
+                          "minimum": 1,
+                          "maximum": 4094,
+                          "description": "VID of component",
+                          "example": 101
+                        }
+                      }
+                    }
+                  },
+                  "mhf-creation-type": {
+                    "type": "string",
+                    "enum": [
+                      "NONE",
+                      "DEFAULT",
+                      "EXPLICIT",
+                      "DEFER"
+                    ],
+                    "description": "Defines how the MA can create MHFs (MIP Half Function) for this VID at this MA"
+                  },
+                  "id-permission": {
+                    "type": "string",
+                    "enum": [
+                      "NONE",
+                      "CHASSIS",
+                      "MANAGE",
+                      "CHASSIS_MANAGE",
+                      "DEFER"
+                    ],
+                    "description": "indicates what, if anything, is to be included in the Sender ID TLV"
+                  },
+                  "tag-type": {
+                    "type": "string",
+                    "enum": [
+                      "VLAN_NONE",
+                      "VLAN_CTAG",
+                      "VLAN_STAG"
+                    ],
+                    "description": "Indicates the tag type for this component",
+                    "example": "VLAN_STAG"
+                  }
+                }
+              }
+            }
+          }
+        },
+        "rmep-list": {
+          "type": "array",
+          "xml": {
+            "name": "rmep",
+            "wrapped": true
+          },
+          "items": {
+            "type": "object",
+            "properties": {
+              "rmep": {
+                "type": "uint16",
+                "minimum": 1,
+                "maximum": 8191,
+                "description": "Remote MEP ID"
+              }
+            }
+          },
+          "example": [{"rmep": 10}, {"rmep": 20}]
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/MdCreate.json b/apps/cfm/src/main/resources/definitions/MdCreate.json
new file mode 100644
index 0000000..5f3ebd3
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/MdCreate.json
@@ -0,0 +1,44 @@
+{
+  "type": "object",
+  "title": "md",
+  "required": [
+    "md"
+  ],
+  "properties": {
+    "md": {
+      "type": "object",
+      "title": "mdprops",
+      "required": [
+        "mdName",
+        "mdNameType"
+      ],
+      "properties": {
+        "mdName": {
+          "type": "string",
+          "maxLength": 45,
+          "description": "Domain identifier [a-zA-Z0-9-:.]",
+          "example": "TestDomain"
+        },
+        "mdNameType": {
+          "type": "string",
+          "enum": ["CHARACTERSTRING", "DOMAINNAME", "MACANDUINT", "NONE"],
+          "description": "Domain identifier type",
+          "example": "CHARACTERSTRING"
+        },
+        "mdLevel": {
+          "type": "string",
+          "enum": ["LEVEL0","LEVEL1","LEVEL2","LEVEL3","LEVEL4","LEVEL5","LEVEL6","LEVEL7"],
+          "description": "Domain level",
+          "example": "LEVEL3"
+        },
+        "mdNumericId": {
+          "type": "uint8",
+          "minimum": 1,
+          "maximum": 32767,
+          "description": "Optional numeric id",
+          "example": 1
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/MepCreate.json b/apps/cfm/src/main/resources/definitions/MepCreate.json
new file mode 100644
index 0000000..8c2cf4b
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/MepCreate.json
@@ -0,0 +1,115 @@
+{
+  "type": "object",
+  "title": "mep",
+  "required": [
+    "mep"
+  ],
+  "properties": {
+    "mep": {
+      "type": "object",
+      "title": "mepprops",
+      "required": [
+        "mepId",
+        "deviceId",
+        "port",
+        "direction"
+      ],
+      "properties": {
+        "mepId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 8191,
+          "description": "Identifier of the MEP",
+          "example": 10
+        },
+        "deviceId": {
+          "type": "string",
+          "description": "The ID of a device in ONOS",
+          "example": "netconf:192.168.56.10:830"
+        },
+        "port": {
+          "type": "uint8",
+          "description": "A valid port identifier for the device",
+          "example": 0
+        },
+        "direction": {
+          "type": "string",
+          "enum": [
+            "UP_MEP",
+            "DOWN_MEP"
+          ],
+          "description": "the direction in which the MEP faces on the interface",
+          "example": "DOWN_MEP"
+        },
+        "primary-vid": {
+          "type": "uint16",
+          "minimum": 0,
+          "maximum": 4094,
+          "description": "Primary VID of the MEP",
+          "example": 101
+        },
+        "administrative-state": {
+          "type": "boolean",
+          "description": "The administrative state of the MEP",
+          "example": true
+        },
+        "cci-enabled": {
+          "type": "boolean",
+          "description": "whether the MEP is or is not to generate CCMs",
+          "example": true
+        },
+        "ccm-ltm-priority": {
+          "type": "uint8",
+          "minimum": 0,
+          "maximum": 7,
+          "description": "the priority parameter for CCMs and LTMs transmitted by the MEP",
+          "example": 3
+        },
+        "fng-address": {
+          "type": "object",
+          "description": "Configuration of the fault notification generator",
+          "properties": {
+            "address-type": {
+              "type": "string",
+              "enum": [
+                "IPV4",
+                "IPV6",
+                "NOT_TRANSMITTED",
+                "NOT_SPECIFIED"
+              ],
+              "description": "An address type for the FNG",
+              "example": "NOT_SPECIFIED"
+            },
+            "ip-address": {
+              "type": "string",
+              "description": "An address for the FNG",
+              "example": "192.168.56.100"
+            }
+          }
+        },
+        "lowest-fault-priority-defect": {
+          "type": "string",
+          "enum": [
+            "ALL_DEFECTS",
+            "MAC_FD_PLUS",
+            "REMOTE_FD_PLUS",
+            "ERROR_FD_PLUS",
+            "XCON_FD_ONLY"
+          ],
+          "description": "the lowest priority defect that is allowed to generate a Fault Alarm",
+          "example": "ALL_DEFECTS"
+        },
+        "defect-present-time": {
+          "type": "string",
+          "description": "the time that the Fault must be present before it is issued. Given as a Java duration literal",
+          "example": "PT10S"
+        },
+        "defect-absent-time": {
+          "type": "string",
+          "description": "the time that the Fault must be absent before it is reset. Given as a Java duration literal",
+          "example": "PT10S"
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/MepLbTransmit.json b/apps/cfm/src/main/resources/definitions/MepLbTransmit.json
new file mode 100644
index 0000000..c9a5a2d
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/MepLbTransmit.json
@@ -0,0 +1,58 @@
+{
+  "type": "object",
+  "title": "loopback",
+  "required": [
+    "loopback"
+  ],
+  "properties": {
+    "loopback": {
+      "type": "object",
+      "title": "lbprops",
+      "required": [
+        "remoteMepId"
+      ],
+      "properties": {
+        "numberMessages": {
+          "type": "uint16",
+          "minimum": 0,
+          "maximum": 32767,
+          "description": "The number of LBM transmissions in a session",
+          "example": 1
+        },
+        "remoteMepId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 8191,
+          "description": "remote Mep will be identified by either a MacAddress or a MEPId. This is for Mep Id",
+          "example": 20
+        },
+        "dataTlvHex": {
+          "type": "string",
+          "maxLength": 64,
+          "description": "TLV data that will be sent encoded as hexadecimal (lower case, colon separated bytes)",
+          "example": "61:62:63:64:63:62:61"
+        },
+        "priority": {
+          "type": "string",
+          "enum": [
+            "PRIO0",
+            "PRIO1",
+            "PRIO2",
+            "PRIO3",
+            "PRIO4",
+            "PRIO5",
+            "PRIO6",
+            "PRIO7"
+          ],
+          "description": "The priority parameter to be used in the transmitted LBMs",
+          "example": "PRIO0"
+        },
+        "vlanDropEligible": {
+          "type": "boolean",
+          "description": "Whether the drop eligible parameter to be used in the transmitted LBMs",
+          "example": true
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/resources/definitions/MepLtTransmit.json b/apps/cfm/src/main/resources/definitions/MepLtTransmit.json
new file mode 100644
index 0000000..1360c00
--- /dev/null
+++ b/apps/cfm/src/main/resources/definitions/MepLtTransmit.json
@@ -0,0 +1,38 @@
+{
+  "type": "object",
+  "title": "linktrace",
+  "required": [
+    "linktrace"
+  ],
+  "properties": {
+    "linktrace": {
+      "type": "object",
+      "title": "ltprops",
+      "required": [
+        "remoteMepId"
+      ],
+      "properties": {
+        "remoteMepId": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 8191,
+          "description": "remote Mep will be identified by either a MacAddress or a MEPId. This is for Mep Id",
+          "example": 20
+        },
+        "transmitLtmFlags": {
+          "type": "string",
+          "maxLength": 64,
+          "description": "Ltm flags to transmit. The only flag supported is 'use-fdb-only'",
+          "example": "use-fdb-only"
+        },
+        "defaultTtl": {
+          "type": "uint16",
+          "minimum": 1,
+          "maximum": 32767,
+          "description": "The time to live of the Ltm packet",
+          "example": 64
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/apps/cfm/src/main/webapp/WEB-INF/web.xml b/apps/cfm/src/main/webapp/WEB-INF/web.xml
index 71c89e9..b4fb8f0 100644
--- a/apps/cfm/src/main/webapp/WEB-INF/web.xml
+++ b/apps/cfm/src/main/webapp/WEB-INF/web.xml
@@ -45,7 +45,7 @@
         <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
         <init-param>
             <param-name>javax.ws.rs.Application</param-name>
-            <param-value>org.onosproject.cfm.impl.CfmWebApplication</param-value>
+            <param-value>org.onosproject.cfm.rest.CfmWebApplication</param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
diff --git a/apps/cfm/src/test/java/org/onosproject/cfm/impl/CfmResourceTest.java b/apps/cfm/src/test/java/org/onosproject/cfm/impl/CfmResourceTest.java
index bcbaa9a..e82cdbb 100644
--- a/apps/cfm/src/test/java/org/onosproject/cfm/impl/CfmResourceTest.java
+++ b/apps/cfm/src/test/java/org/onosproject/cfm/impl/CfmResourceTest.java
@@ -16,6 +16,7 @@
 package org.onosproject.cfm.impl;
 
 import org.glassfish.jersey.server.ResourceConfig;
+import org.onosproject.cfm.rest.CfmWebApplication;
 import org.onosproject.rest.resources.ResourceTest;
 
 /**