Merge "Bug #65 - Fix inconsistencies in the NB REST APIs"
authorAlessandro Boch <aboch@cisco.com>
Wed, 11 Sep 2013 16:58:31 +0000 (16:58 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 11 Sep 2013 16:58:31 +0000 (16:58 +0000)
18 files changed:
opendaylight/northbound/commons/pom.xml
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java [new file with mode: 0644]
opendaylight/northbound/flowprogrammer/enunciate.xml
opendaylight/northbound/flowprogrammer/pom.xml
opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java
opendaylight/northbound/hosttracker/pom.xml
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java
opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/northbound/subnets/enunciate.xml
opendaylight/northbound/subnets/pom.xml
opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java
opendaylight/northbound/switchmanager/enunciate.xml
opendaylight/northbound/switchmanager/pom.xml
opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java
opendaylight/northbound/topology/enunciate.xml
opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java

index 6031ddea35837765eb0897c7e031c996db905802..b88375ffdc9390c8dba9801f65fd69076f68a588 100644 (file)
           <instructions>
             <Export-Package>
               org.opendaylight.controller.northbound.commons.exception,
+              org.opendaylight.controller.northbound.commons.types,
               org.opendaylight.controller.northbound.commons.utils,
               org.opendaylight.controller.northbound.commons
             </Export-Package>
             <Import-Package>
               javax.ws.rs,
               javax.ws.rs.core,
+              javax.xml.bind.annotation,
               org.opendaylight.controller.sal.utils,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.containermanager,
diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java
new file mode 100644 (file)
index 0000000..62d1608
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.northbound.commons.types;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Represents a list of string values
+ */
+@XmlRootElement(name = "list")
+@XmlAccessorType(XmlAccessType.NONE)
+public class StringList {
+    @XmlElement(name = "item")
+    private List<String> list;
+
+    public StringList() {
+    }
+
+    public StringList(List<String> list) {
+        this.list = list;
+    }
+
+    public List<String> getList() {
+        return list;
+    }
+
+}
index 90bf6de1d67e13b542fb4d6a2e1a6896995d0e8e..3ac676907bae795ff14404db66cc77dbe5bf5c09 100644 (file)
@@ -3,7 +3,7 @@
     xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
 
   <services>
-    <rest defaultRestSubcontext="/controller/nb/v2/flow"/>
+    <rest defaultRestSubcontext="/controller/nb/v2/flowprogrammer"/>
   </services>
 
   <modules>
index 7aef0652fe2411637fb69c777a35ba37c835fa23..960c835dc89306b55d3fd7b87bfc061ca49ec074 100644 (file)
@@ -60,7 +60,7 @@
             </Import-Package>
             <Export-Package>
             </Export-Package>
-            <Web-ContextPath>/controller/nb/v2/flow</Web-ContextPath>
+            <Web-ContextPath>/controller/nb/v2/flowprogrammer</Web-ContextPath>
           </instructions>
           <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
         </configuration>
index 257fbbda670486582949bdb3eab5dd4297ba7d88..ea3f748dcc02e820c6b88aab5f2a10a73fef0cdf 100644 (file)
@@ -48,7 +48,7 @@ import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
 
 /**
- * Flow Configuration Northbound API
+ * Flow Configuration Northbound API provides capabilities to program flows.
  *
  * <br>
  * <br>
@@ -56,11 +56,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
  * Authentication realm : <b>opendaylight</b><br>
  * Transport : <b>HTTP and HTTPS</b><br>
  * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
  *
  */
 @Path("/")
@@ -158,7 +154,7 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -223,7 +219,7 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -296,7 +292,7 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -320,7 +316,7 @@ public class FlowProgrammerNorthbound {
      *
      * </pre>
      */
-    @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+    @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(FlowConfig.class)
@@ -357,7 +353,8 @@ public class FlowProgrammerNorthbound {
     }
 
     /**
-     * Add a flow configuration
+     * Add a flow configuration. If a flow by the given name already
+     * exists, this method will respond with a non-successful status response.
      *
      * @param containerName
      *            Name of the Container (Eg. 'default')
@@ -376,7 +373,7 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1
      *
      * Request in XML:
      * &lt;flowConfig&gt;
@@ -400,7 +397,7 @@ public class FlowProgrammerNorthbound {
      * </pre>
      */
 
-    @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+    @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
     @PUT
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
@@ -476,16 +473,16 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1
      *
      * </pre>
      */
 
-    @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+    @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Flow Config deleted successfully"),
+            @ResponseCode(code = 204, condition = "Flow Config deleted successfully"),
             @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
             @ResponseCode(code = 404, condition = "The Container Name or Node-id or Flow Name passed is not found"),
             @ResponseCode(code = 406, condition = "Failed to delete Flow config due to invalid operation. Failure details included in HTTP Error response"),
@@ -523,6 +520,7 @@ public class FlowProgrammerNorthbound {
         Status status = frm.removeStaticFlow(name, node);
         if (status.isSuccess()) {
             NorthboundUtils.auditlog("Flow", username, "removed", name, containerName);
+            return Response.noContent().build();
         }
         return NorthboundUtils.getResponse(status);
     }
@@ -545,11 +543,11 @@ public class FlowProgrammerNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1
+     * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1
      *
      * </pre>
      */
-    @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+    @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
     @POST
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
index 3757ea1f36c770304e3d3f6806f5a1a8a713dc6e..d39ae17c900a2329fe63101a840b46f3d8265730 100644 (file)
@@ -61,7 +61,7 @@
               org.codehaus.jackson.jaxrs,
               !org.codehaus.enunciate.jaxrs
             </Import-Package>
-            <Web-ContextPath>/controller/nb/v2/host</Web-ContextPath>
+            <Web-ContextPath>/controller/nb/v2/hosttracker</Web-ContextPath>
           </instructions>
           <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
         </configuration>
index f0bdf5d891153fff7271c5853526ae7fd3211a25..836bfa2d60fdd59b62e14d8d8a2c2d9fd247e898 100644 (file)
@@ -62,11 +62,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
  * Authentication realm : <b>opendaylight</b><br>
  * Transport : <b>HTTP and HTTPS</b><br>
  * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
  *
  */
 
@@ -137,7 +133,7 @@ public class HostTrackerNorthbound {
      *
      * RequestURL:
      *
-     * http://localhost:8080/controller/nb/v2/host/default
+     * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/active
      *
      * Response in XML
      *
@@ -192,7 +188,7 @@ public class HostTrackerNorthbound {
      * }
      * </pre>
      */
-    @Path("/{containerName}")
+    @Path("/{containerName}/hosts/active")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(Hosts.class)
@@ -224,7 +220,7 @@ public class HostTrackerNorthbound {
      *
      * RequestURL:
      *
-     * http://localhost:8080/controller/nb/v2/host/default/inactive
+     * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/inactive
      *
      * Response in XML
      *
@@ -279,7 +275,7 @@ public class HostTrackerNorthbound {
      * }
      * </pre>
      */
-    @Path("/{containerName}/inactive")
+    @Path("/{containerName}/hosts/inactive")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(Hosts.class)
@@ -312,7 +308,7 @@ public class HostTrackerNorthbound {
      *
      * RequestURL:
      *
-     * http://localhost:8080/controller/nb/v2/host/default/1.1.1.1
+     * http://localhost:8080/controller/nb/v2/hosttracker/default/address/1.1.1.1
      *
      * Response in XML
      *
@@ -341,7 +337,7 @@ public class HostTrackerNorthbound {
      * }
      * </pre>
      */
-    @Path("/{containerName}/{networkAddress}")
+    @Path("/{containerName}/address/{networkAddress}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(HostConfig.class)
@@ -374,7 +370,8 @@ public class HostTrackerNorthbound {
     }
 
     /**
-     * Add a Static Host configuration
+     * Add a Static Host configuration. If a host by the given address already
+     * exists, this method will respond with a non-successful status response.
      *
      * @param containerName
      *            Name of the Container. The Container name for the base
@@ -391,7 +388,7 @@ public class HostTrackerNorthbound {
      *
      * RequestURL:
      *
-     * http://localhost:8080/controller/nb/v2/host/default/1.1.1.1
+     * http://localhost:8080/controller/nb/v2/hosttracker/default/address/1.1.1.1
      *
      * Request in XML
      *
@@ -421,7 +418,7 @@ public class HostTrackerNorthbound {
      * </pre>
      */
 
-    @Path("/{containerName}/{networkAddress}")
+    @Path("/{containerName}/address/{networkAddress}")
     @PUT
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
@@ -477,7 +474,7 @@ public class HostTrackerNorthbound {
      * @return Response as dictated by the HTTP Response code.
      */
 
-    @Path("/{containerName}/{networkAddress}")
+    @Path("/{containerName}/address/{networkAddress}")
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
index 27a50c015dfce73040afd8453f54bb02b26139d9..38336c1dd8ce91ed3c3418b68d5964335a0505aa 100644 (file)
@@ -293,7 +293,7 @@ public class NorthboundIT {
     @Test
     public void testSubnetsNorthbound() throws JSONException {
         System.out.println("Starting Subnets JAXB client.");
-        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnet/";
+        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnetservice/";
 
         String name1 = "testSubnet1";
         String subnet1 = "1.1.1.1/24";
@@ -313,7 +313,7 @@ public class NorthboundIT {
         nodePortsJson3_1.append(nodePortsJson3).append(",").append(nodePortsJson2);
 
         // Test GET subnets in default container
-        String result = getJsonResult(baseURL + "default/subnet/all");
+        String result = getJsonResult(baseURL + "default/subnets");
         JSONTokener jt = new JSONTokener(result);
         JSONObject json = new JSONObject(jt);
         JSONArray subnetConfigs = json.getJSONArray("subnetConfig");
@@ -326,7 +326,7 @@ public class NorthboundIT {
         // Test POST subnet1
         JSONObject jo = new JSONObject().put("name", name1).put("subnet", subnet1);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "default/subnet/" + name1, "POST", jo.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name1, "PUT", jo.toString());
         Assert.assertTrue(httpResponseCode == 201);
 
         // Test GET subnet1
@@ -340,31 +340,31 @@ public class NorthboundIT {
         // Test POST subnet2
         JSONObject jo2 = new JSONObject().put("name", name2).put("subnet", subnet2);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "default/subnet/" + name2, "POST", jo2.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name2, "PUT", jo2.toString());
         Assert.assertEquals(201, httpResponseCode.intValue());
         // Test POST nodePorts
         jo2.append("nodePorts", nodePortsJson2);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "default/subnet/" + name2 + "/node-ports", "POST", jo2.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name2 + "/nodePorts", "PUT", jo2.toString());
         Assert.assertEquals(200, httpResponseCode.intValue());
         // Test POST subnet3
         JSONObject jo3 = new JSONObject().put("name", name3).put("subnet", subnet3);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "default/subnet/" + name3, "POST", jo3.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name3, "PUT", jo3.toString());
         Assert.assertEquals(201, httpResponseCode.intValue());
         // Test POST nodePorts
         jo3.append("nodePorts", nodePortsJson3);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "POST", jo3.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "PUT", jo3.toString());
         Assert.assertEquals(200, httpResponseCode.intValue());
         // Test PUT nodePorts
         jo3.remove("nodePorts");
         jo3.append("nodePorts", nodePortsJson3_1);
-        result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "PUT", jo3.toString());
+        result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "POST", jo3.toString());
         Assert.assertEquals(200, httpResponseCode.intValue());
 
         // Test GET all subnets in default container
-        result = getJsonResult(baseURL + "default/subnet/all");
+        result = getJsonResult(baseURL + "default/subnets");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
         JSONArray subnetConfigArray = json.getJSONArray("subnetConfig");
@@ -419,7 +419,7 @@ public class NorthboundIT {
         String nextHop2 = "1.1.1.1";
 
         // Test GET static routes in default container, expecting no results
-        String result = getJsonResult(baseURL + "default");
+        String result = getJsonResult(baseURL + "default/routes");
         JSONTokener jt = new JSONTokener(result);
         JSONObject json = new JSONObject(jt);
         JSONArray staticRoutes = json.getJSONArray("staticRoute");
@@ -428,15 +428,15 @@ public class NorthboundIT {
         // Test insert static route
         String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\"" + prefix1 + "\", \"nextHop\":\"" + nextHop1
                 + "\"}";
-        result = getJsonResult(baseURL + "default/route/" + name1, "POST", requestBody);
+        result = getJsonResult(baseURL + "default/route/" + name1, "PUT", requestBody);
         Assert.assertEquals(201, httpResponseCode.intValue());
 
         requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2 + "\", \"nextHop\":\"" + nextHop2 + "\"}";
-        result = getJsonResult(baseURL + "default/route/" + name2, "POST", requestBody);
+        result = getJsonResult(baseURL + "default/route/" + name2, "PUT", requestBody);
         Assert.assertEquals(201, httpResponseCode.intValue());
 
         // Test Get all static routes
-        result = getJsonResult(baseURL + "default");
+        result = getJsonResult(baseURL + "default/routes");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
         JSONArray staticRouteArray = json.getJSONArray("staticRoute");
@@ -475,9 +475,9 @@ public class NorthboundIT {
 
         // Test delete static route
         result = getJsonResult(baseURL + "default/route/" + name1, "DELETE");
-        Assert.assertEquals(200, httpResponseCode.intValue());
+        Assert.assertEquals(204, httpResponseCode.intValue());
 
-        result = getJsonResult(baseURL + "default");
+        result = getJsonResult(baseURL + "default/routes");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
 
@@ -490,7 +490,7 @@ public class NorthboundIT {
     @Test
     public void testSwitchManager() throws JSONException {
         System.out.println("Starting SwitchManager JAXB client.");
-        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/";
+        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switchmanager/default/";
 
         // define Node/NodeConnector attributes for test
         int nodeId_1 = 51966;
@@ -599,7 +599,7 @@ public class NorthboundIT {
         // Delete state property of nodeconnector1
         result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1 + "/STUB/" + nodeConnectorId_1
                 + "/property/state", "DELETE");
-        Assert.assertEquals(200, httpResponseCode.intValue());
+        Assert.assertEquals(204, httpResponseCode.intValue());
 
         result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
         jt = new JSONTokener(result);
@@ -613,7 +613,7 @@ public class NorthboundIT {
         // Delete capabilities property of nodeconnector2
         result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2 + "/STUB/" + nodeConnectorId_2
                 + "/property/capabilities", "DELETE");
-        Assert.assertEquals(200, httpResponseCode.intValue());
+        Assert.assertEquals(204, httpResponseCode.intValue());
 
         result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
         jt = new JSONTokener(result);
@@ -834,19 +834,19 @@ public class NorthboundIT {
     @Test
     public void testFlowProgrammer() throws JSONException {
         System.out.println("Starting FlowProgrammer JAXB client.");
-        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
+        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flowprogrammer/default/";
         // Attempt to get a flow that doesn't exit. Should return 404
         // status.
-        String result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET");
+        String result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "GET");
         Assert.assertTrue(result.equals("404"));
 
         // test add flow1
         String fc = "{\"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc);
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc);
         Assert.assertTrue(httpResponseCode == 201);
 
         // test get returns flow that was added.
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET");
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "GET");
         // check that result came out fine.
         Assert.assertTrue(httpResponseCode == 200);
         JSONTokener jt = new JSONTokener(result);
@@ -860,17 +860,17 @@ public class NorthboundIT {
         Assert.assertEquals(node.getString("id"), "51966");
         // test adding same flow again fails due to repeat name..return 409
         // code
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc);
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc);
         Assert.assertTrue(result.equals("409"));
 
         fc = "{\"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc);
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "PUT", fc);
         // test should return 409 for error due to same flow being added.
         Assert.assertTrue(result.equals("409"));
 
         // add second flow that's different
         fc = "{\"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc);
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "PUT", fc);
         Assert.assertTrue(httpResponseCode == 201);
 
         // check that request returns both flows given node.
@@ -892,10 +892,10 @@ public class NorthboundIT {
         Assert.assertTrue(count == 2);
 
         // delete a flow, check that it's no longer in list.
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "DELETE");
-        Assert.assertTrue(httpResponseCode == 200);
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "DELETE");
+        Assert.assertTrue(httpResponseCode == 204);
 
-        result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "GET");
+        result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "GET");
         Assert.assertTrue(result.equals("404"));
     }
 
@@ -970,7 +970,7 @@ public class NorthboundIT {
         Integer nodeConnectorId_2 = 34;
         String vlan_2 = "123";
 
-        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
+        String baseURL = "http://127.0.0.1:8080/controller/nb/v2/hosttracker/default";
 
         // test PUT method: addHost()
         JSONObject fc_json = new JSONObject();
@@ -983,7 +983,7 @@ public class NorthboundIT {
         fc_json.put("staticHost", "true");
         fc_json.put("networkAddress", networkAddress_1);
 
-        String result = getJsonResult(baseURL + "/" + networkAddress_1, "PUT", fc_json.toString());
+        String result = getJsonResult(baseURL + "/address/" + networkAddress_1, "PUT", fc_json.toString());
         Assert.assertTrue(httpResponseCode == 201);
 
         fc_json = new JSONObject();
@@ -996,7 +996,7 @@ public class NorthboundIT {
         fc_json.put("staticHost", "true");
         fc_json.put("networkAddress", networkAddress_2);
 
-        result = getJsonResult(baseURL + "/" + networkAddress_2 , "PUT", fc_json.toString());
+        result = getJsonResult(baseURL + "/address/" + networkAddress_2 , "PUT", fc_json.toString());
         Assert.assertTrue(httpResponseCode == 201);
 
         // define variables for decoding returned strings
@@ -1005,7 +1005,7 @@ public class NorthboundIT {
 
         // the two hosts should be in inactive host DB
         // test GET method: getInactiveHosts()
-        result = getJsonResult(baseURL + "/inactive", "GET");
+        result = getJsonResult(baseURL + "/hosts/inactive", "GET");
         Assert.assertTrue(httpResponseCode == 200);
 
         JSONTokener jt = new JSONTokener(result);
@@ -1041,7 +1041,7 @@ public class NorthboundIT {
         }
 
         // test GET method: getActiveHosts() - no host expected
-        result = getJsonResult(baseURL, "GET");
+        result = getJsonResult(baseURL + "/hosts/active", "GET");
         Assert.assertTrue(httpResponseCode == 200);
 
         jt = new JSONTokener(result);
@@ -1063,7 +1063,7 @@ public class NorthboundIT {
 
         // verify the host shows up in active host DB
 
-        result = getJsonResult(baseURL, "GET");
+        result = getJsonResult(baseURL + "/hosts/active", "GET");
         Assert.assertTrue(httpResponseCode == 200);
 
         jt = new JSONTokener(result);
@@ -1073,7 +1073,7 @@ public class NorthboundIT {
 
         // test GET method for getHostDetails()
 
-        result = getJsonResult(baseURL + "/" + networkAddress_1, "GET");
+        result = getJsonResult(baseURL + "/address/" + networkAddress_1, "GET");
         Assert.assertTrue(httpResponseCode == 200);
 
         jt = new JSONTokener(result);
@@ -1091,13 +1091,13 @@ public class NorthboundIT {
 
         // test DELETE method for deleteFlow()
 
-        result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE");
+        result = getJsonResult(baseURL + "/address/" + networkAddress_1, "DELETE");
         Assert.assertTrue(httpResponseCode == 204);
 
         // verify host_1 removed from active host DB
         // test GET method: getActiveHosts() - no host expected
 
-        result = getJsonResult(baseURL, "GET");
+        result = getJsonResult(baseURL + "/hosts/active", "GET");
         Assert.assertTrue(httpResponseCode == 200);
 
         jt = new JSONTokener(result);
@@ -1246,11 +1246,11 @@ public class NorthboundIT {
                 .put("dstNodeConnector",
                         nodeConnectorType_2 + "|" + nodeConnectorId_2 + "@" + nodeType_2 + "|" + nodeId_2);
         // execute HTTP request and verify response code
-        result = getJsonResult(baseURL + "/user-link", "PUT", jo.toString());
+        result = getJsonResult(baseURL + "/userLink/userLink_1", "PUT", jo.toString());
         Assert.assertTrue(httpResponseCode == 201);
 
         // === test GET method for getUserLinks()
-        result = getJsonResult(baseURL + "/user-link", "GET");
+        result = getJsonResult(baseURL + "/userLinks", "GET");
         Assert.assertTrue(httpResponseCode == 200);
         if (debugMsg) {
             System.out.println("result:" + result);
@@ -1295,12 +1295,12 @@ public class NorthboundIT {
 
         // === test DELETE method for deleteUserLink()
         String userName = "userLink_1";
-        result = getJsonResult(baseURL + "/user-link/" + userName, "DELETE");
-        Assert.assertTrue(httpResponseCode == 200);
+        result = getJsonResult(baseURL + "/userLink/" + userName, "DELETE");
+        Assert.assertTrue(httpResponseCode == 204);
 
         // execute another getUserLinks() request to verify that userLink_1 is
         // removed
-        result = getJsonResult(baseURL + "/user-link", "GET");
+        result = getJsonResult(baseURL + "/userLinks", "GET");
         Assert.assertTrue(httpResponseCode == 200);
         if (debugMsg) {
             System.out.println("result:" + result);
index 65e68aab7d9be627154aebf61856b1b07fe5d68d..07f125dae3f79a8428d7609a18c1f4194b2553a1 100644 (file)
@@ -16,6 +16,7 @@ import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -113,7 +114,7 @@ public class StaticRoutingNorthbound {
      * Example:
      *
      * Request URL:
-     * GET http://localhost:8080/controller/nb/v2/staticroute/default
+     * GET http://localhost:8080/controller/nb/v2/staticroute/default/routes
      *
      * Response in XML:
      *  &lt;list&gt;
@@ -129,7 +130,7 @@ public class StaticRoutingNorthbound {
      *
      * </pre>
      */
-    @Path("/{containerName}")
+    @Path("/{containerName}/routes")
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(StaticRoutes.class)
@@ -204,7 +205,8 @@ public class StaticRoutingNorthbound {
 
     /**
      *
-     * Add a new Static Route
+     * Add a new Static Route. If a route by the given name already exists, this
+     * method will return a non-successful status response.
      *
      * @param containerName Name of the Container. The Container name for the base controller is "default".
      * @param route Name of the Static Route configuration
@@ -214,7 +216,7 @@ public class StaticRoutingNorthbound {
      * Example:
      *
      * Request URL:
-     * POST http://localhost:8080/controller/nb/v2/staticroute/default/route/route-1
+     * PUT http://localhost:8080/controller/nb/v2/staticroute/default/route/route-1
      *
      * Request payload in JSON:
      * {"name":"route-1","prefix":"10.10.1.0/24","nextHop":"1.1.1.1"}
@@ -222,7 +224,7 @@ public class StaticRoutingNorthbound {
      * </pre>
      */
     @Path("/{containerName}/route/{route}")
-    @POST
+    @PUT
     @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes( {
             @ResponseCode(code = 201, condition = "Created Static Route successfully"),
@@ -284,7 +286,7 @@ public class StaticRoutingNorthbound {
     @Path("/{containerName}/route/{route}")
     @DELETE
     @StatusCodes( {
-            @ResponseCode(code = 200, condition = "Operation successful"),
+            @ResponseCode(code = 204, condition = "Static route removed successfully"),
             @ResponseCode(code = 404, condition = "Container Name or Configuration Name not found"),
             @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active") })
     public Response removeStaticRoute(
@@ -311,9 +313,9 @@ public class StaticRoutingNorthbound {
         Status status = staticRouting.removeStaticRoute(route);
         if (status.isSuccess()) {
             NorthboundUtils.auditlog("Static Route", username, "removed", route, containerName);
-            return Response.ok().build();
+            return Response.noContent().build();
         }
-        throw new ResourceNotFoundException(status.getDescription());
+        return NorthboundUtils.getResponse(status);
     }
 
     private void handleDefaultDisabled(String containerName) {
index a07f6435fe0e92e96d53eea61dd5abdffab921a3..a47bfa70b77e9fa2d0657529df2e676f8ab98f2a 100644 (file)
@@ -50,11 +50,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
  * Authentication realm : <b>opendaylight</b><br>
  * Transport : <b>HTTP and HTTPS</b><br>
  * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
  *
  */
 @Path("/")
index 5ff13ffe805381e9abc83a08a71e67ae0eaaf6c5..abdc40a174225cef3073fb45b5c19a7cfb462f43 100644 (file)
@@ -3,10 +3,10 @@
     xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
 
   <services>
-    <rest defaultRestSubcontext="/controller/nb/v2/subnet"/>
+    <rest defaultRestSubcontext="/controller/nb/v2/subnetservice"/>
   </services>
 
   <modules>
-    <docs docsDir="rest" title="REST API" includeExampleXml="true" includeExampleJson="true"/>
+    <docs docsDir="rest" title="Subnet Service REST API" includeExampleXml="true" includeExampleJson="true"/>
   </modules>
 </enunciate>
index 9feb95fce08d2fead13ecec697ad03b406c7a746..471566413271ec2242f800661c0ea3742991925d 100644 (file)
@@ -76,7 +76,7 @@
             </Import-Package>
             <Export-Package>
             </Export-Package>
-            <Web-ContextPath>/controller/nb/v2/subnet</Web-ContextPath>
+            <Web-ContextPath>/controller/nb/v2/subnetservice</Web-ContextPath>
           </instructions>
           <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
         </configuration>
index 50024fd7392706bcf2f935685dfa97ec68a11100..b16c8f9ea67d0b58f169a02733915005147ad261 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.subnets.northbound;
 
 import java.util.HashSet;
+
 import java.util.List;
 import java.util.Set;
 
@@ -45,6 +46,19 @@ import org.opendaylight.controller.switchmanager.SubnetConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * This class provides REST APIs to manage subnets.
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default.
+ *
+ */
+
 @Path("/")
 public class SubnetsNorthbound {
     protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class);
@@ -100,7 +114,7 @@ public class SubnetsNorthbound {
      *         <pre>
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/all
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnets
      *
      * Response in XML:
      * &lt;subnetConfig&gt;
@@ -131,7 +145,7 @@ public class SubnetsNorthbound {
      * }
      * </pre>
      */
-    @Path("/{containerName}/subnet/all")
+    @Path("/{containerName}/subnets")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
@@ -165,7 +179,7 @@ public class SubnetsNorthbound {
      *         <pre>
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * Response in XML:
      * &lt;subnetConfig&gt;
@@ -213,7 +227,8 @@ public class SubnetsNorthbound {
     }
 
     /**
-     * Add a subnet to a container
+     * Add a subnet to a container. If a subnet by the given name already exists
+     * this method will return a non-successful response.
      *
      * @param containerName
      *            name of the container to which subnet needs to be added
@@ -227,7 +242,7 @@ public class SubnetsNorthbound {
      *         <pre>
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * Request XML:
      *  &lt;subnetConfig&gt;
@@ -244,7 +259,7 @@ public class SubnetsNorthbound {
      */
 
     @Path("/{containerName}/subnet/{subnetName}")
-    @POST
+    @PUT
     @StatusCodes({ @ResponseCode(code = 201, condition = "Subnet created successfully"),
             @ResponseCode(code = 400, condition = "Invalid data passed"),
             @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
@@ -297,7 +312,7 @@ public class SubnetsNorthbound {
      *
      *         <pre>
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * </pre>
      */
@@ -345,7 +360,7 @@ public class SubnetsNorthbound {
      *         <pre>
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      *  Request in XML:
      *  &lt;subnetConfig&gt;
@@ -364,8 +379,8 @@ public class SubnetsNorthbound {
      * }
      * </pre>
      */
-    @Path("/{containerName}/subnet/{subnetName}/node-ports")
-    @PUT
+    @Path("/{containerName}/subnet/{subnetName}/nodePorts")
+    @POST
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
             @ResponseCode(code = 200, condition = "Ports replaced successfully"),
@@ -442,7 +457,7 @@ public class SubnetsNorthbound {
     }
 
     /**
-     * Add ports to a subnet in the container
+     * Add ports to a subnet in the container.
      *
      * @param containerName
      *            name of the container that has the subnet to which node ports
@@ -455,7 +470,7 @@ public class SubnetsNorthbound {
      *
      *         <pre>
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      * Request XML:
      *  &lt;subnetConfig&gt;
@@ -475,8 +490,8 @@ public class SubnetsNorthbound {
      *
      * </pre>
      */
-    @Path("/{containerName}/subnet/{subnetName}/node-ports")
-    @POST
+    @Path("/{containerName}/subnet/{subnetName}/nodePorts")
+    @PUT
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
             @ResponseCode(code = 200, condition = "Added node ports to subnet successfully"),
@@ -557,7 +572,7 @@ public class SubnetsNorthbound {
      *
      *         <pre>
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      * Request XML:
      *  &lt;subnetConfig&gt;
@@ -573,7 +588,7 @@ public class SubnetsNorthbound {
      *
      * </pre>
      */
-    @Path("/{containerName}/subnet/{subnetName}/node-ports")
+    @Path("/{containerName}/subnet/{subnetName}/nodePorts")
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
@@ -635,7 +650,7 @@ public class SubnetsNorthbound {
             }
         }
         if (successful) {
-            return Response.status(Response.Status.NO_CONTENT).build();
+            return Response.noContent().build();
         }
         throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString());
     }
index 8a8bfdb02999941afa232187ea4c02a37bf030d7..6f2dd4d0e76892dc566a55411ee6aea1ebcc47e5 100644 (file)
@@ -3,7 +3,7 @@
     xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
 
   <services>
-    <rest defaultRestSubcontext="/controller/nb/v2/switch"/>
+    <rest defaultRestSubcontext="/controller/nb/v2/switchmanager"/>
   </services>
 
   <modules>
index 965075a271aa2f5357fdab6933872f1e68dfa654..6b320b1992b786be723bdbc97a209cba7d7b40b6 100644 (file)
@@ -60,7 +60,7 @@
               org.codehaus.jackson.jaxrs,
               !org.codehaus.enunciate.jaxrs
             </Import-Package>
-            <Web-ContextPath>/controller/nb/v2/switch</Web-ContextPath>
+            <Web-ContextPath>/controller/nb/v2/switchmanager</Web-ContextPath>
           </instructions>
           <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
         </configuration>
index 1edd945dfa708f7d68f5f6a081c3795f3bcefff8..f4d302b2d1b9cab1f96ea7501367ef532d7ff309 100644 (file)
@@ -119,7 +119,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/nodes
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/nodes
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -194,7 +194,7 @@ public class SwitchNorthbound {
         List<NodeProperties> res = new ArrayList<NodeProperties>();
         Set<Node> nodes = switchManager.getNodes();
         if (nodes == null) {
-            return null;
+            return new Nodes(res);
         }
 
         for (Node node : nodes) {
@@ -212,7 +212,9 @@ public class SwitchNorthbound {
     }
 
     /**
-     * Add a Description, Tier and Forwarding mode property to a node.
+     * Add a Description, Tier and Forwarding mode property to a node. This
+     * method returns a non-successful response if a node by that name already
+     * exists.
      *
      * @param containerName
      *            Name of the Container (Eg. 'default')
@@ -237,7 +239,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:03/property/description/Switch3
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:03/property/description/Switch3
      *
      * </pre>
      */
@@ -316,7 +318,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:03/property/forwarding
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:03/property/forwarding
      *
      * </pre>
      */
@@ -325,7 +327,7 @@ public class SwitchNorthbound {
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
+            @ResponseCode(code = 204, condition = "Property removed successfully"),
             @ResponseCode(code = 400, condition = "The nodeId or configuration is invalid"),
             @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
             @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
@@ -369,7 +371,8 @@ public class SwitchNorthbound {
                 SwitchConfig newSwitchConfig = new SwitchConfig(node.toString(), nodeProperties);
                 status = switchManager.updateNodeConfig(newSwitchConfig);
                 if(status.isSuccess()){
-                    NorthboundUtils.auditlog("Static Route", username, "updated", nodeId, containerName);
+                    NorthboundUtils.auditlog("Node Property", username, "removed", propertyName  + " from " + nodeId, containerName);
+                    return Response.noContent().build();
                 }
             }
         }
@@ -401,7 +404,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:01
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:01
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -489,7 +492,9 @@ public class SwitchNorthbound {
     }
 
     /**
-     * Add Bandwidth property to a node connector
+     * Add node-connector property to a node connector. This method returns a
+     * non-successful response if a node connector by the given name already
+     * exists.
      *
      * @param containerName
      *            Name of the Container (Eg. 'default')
@@ -521,7 +526,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth/1
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth/1
      *
      * </pre>
      */
@@ -610,7 +615,7 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth
      *
      * </pre>
      */
@@ -619,7 +624,7 @@ public class SwitchNorthbound {
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
+            @ResponseCode(code = 204, condition = "Property removed successfully"),
             @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
             @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
@@ -657,7 +662,7 @@ public class SwitchNorthbound {
         Status ret = switchManager.removeNodeConnectorProp(nc, propertyName);
         if (ret.isSuccess()) {
             NorthboundUtils.auditlog("Node Connector Property", username, "removed", nc + " from " + nodeConnectorId, containerName);
-            return Response.ok().build();
+            return Response.noContent().build();
         }
         throw new ResourceNotFoundException(ret.getDescription());
     }
@@ -674,11 +679,11 @@ public class SwitchNorthbound {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/switch/default/switch-config
+     * http://localhost:8080/controller/nb/v2/switchmanager/default/save
      *
      * </pre>
      */
-    @Path("/{containerName}/switch-config")
+    @Path("/{containerName}/save")
     @POST
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
index b7c451c8e6855e09c772b42e4f7f0e52948eec6d..fed0f68e3086b735d3ff66d284a6c7af5039aa33 100644 (file)
@@ -7,6 +7,6 @@
   </services>
 
   <modules>
-    <docs docsDir="rest" title="REST API" includeExampleXml="true" includeExampleJson="true"/>
+    <docs docsDir="rest" title="Topology REST API" includeExampleXml="true" includeExampleJson="true"/>
   </modules>
 </enunciate>
index 508ffafe6fdf8f1a1a5fff4466ee54e0f0862da9..ff26bfd21f30a6b67f683607924b366ef32a1011 100644 (file)
@@ -52,11 +52,7 @@ import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig;
  * Authentication realm : <b>opendaylight</b><br>
  * Transport : <b>HTTP and HTTPS</b><br>
  * <br>
- * HTTPS Authentication is disabled by default. Administrator can enable it in
- * tomcat-server.xml after adding a proper keystore / SSL certificate from a
- * trusted authority.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
  */
 
 @Path("/")
@@ -81,7 +77,7 @@ public class TopologyNorthboundJAXRS {
      *            The container for which we want to retrieve the topology (Eg.
      *            'default')
      *
-     * @return A List of EdgeProps each EdgeProp represent an Edge of the grap
+     * @return A List of EdgeProps each EdgeProp represent an Edge of the graph
      *         with the corresponding properties attached to it.
      *
      *         <pre>
@@ -222,7 +218,7 @@ public class TopologyNorthboundJAXRS {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/topology/default/user-link
+     * http://localhost:8080/controller/nb/v2/topology/default/userLinks
      *
      * Response in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -241,7 +237,7 @@ public class TopologyNorthboundJAXRS {
      *
      * </pre>
      */
-    @Path("/{containerName}/user-link")
+    @Path("/{containerName}/userLinks")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(TopologyUserLinks.class)
@@ -278,6 +274,8 @@ public class TopologyNorthboundJAXRS {
      *
      * @param containerName
      *            Name of the Container (Eg. 'default')
+     * @param name
+     *            Name of the user link
      * @param TopologyUserLinkConfig
      *            in JSON or XML format
      * @return Response as dictated by the HTTP Response Status code
@@ -287,7 +285,7 @@ public class TopologyNorthboundJAXRS {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/topology/default/user-link
+     * http://localhost:8080/controller/nb/v2/topology/default/userLink/link1
      *
      * Request in XML:
      * &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
@@ -303,7 +301,7 @@ public class TopologyNorthboundJAXRS {
      *
      * </pre>
      */
-    @Path("/{containerName}/user-link")
+    @Path("/{containerName}/userLink/{name}")
     @PUT
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@@ -315,6 +313,7 @@ public class TopologyNorthboundJAXRS {
             @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
     public Response addUserLink(
             @PathParam(value = "containerName") String containerName,
+            @PathParam(value = "name") String name,
             @TypeHint(TopologyUserLinkConfig.class) TopologyUserLinkConfig userLinkConfig) {
 
         if (!NorthboundUtils.isAuthorized(
@@ -352,16 +351,16 @@ public class TopologyNorthboundJAXRS {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/topology/default/user-link/config1
+     * http://localhost:8080/controller/nb/v2/topology/default/userLink/config1
      *
      * </pre>
      */
-    @Path("/{containerName}/user-link/{name}")
+    @Path("/{containerName}/userLink/{name}")
     @DELETE
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
+            @ResponseCode(code = 204, condition = "User link removed successfully"),
             @ResponseCode(code = 404, condition = "The Container Name or Link Configuration Name was not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
     public Response deleteUserLink(
@@ -384,8 +383,8 @@ public class TopologyNorthboundJAXRS {
         Status ret = topologyManager.deleteUserLink(name);
         if (ret.isSuccess()) {
             NorthboundUtils.auditlog("User Link", username, "removed", name, containerName);
-            return Response.ok().build();
+            return Response.noContent().build();
         }
-        throw new ResourceNotFoundException(ret.getDescription());
+        return NorthboundUtils.getResponse(ret);
     }
 }