NBI v3 Method Stubs 41/9441/1
authorDave Tucker <djt@redhat.com>
Tue, 29 Jul 2014 15:46:04 +0000 (16:46 +0100)
committerDave Tucker <djt@redhat.com>
Tue, 29 Jul 2014 15:46:04 +0000 (16:46 +0100)
This commit adds the methods stubs for the v3 NBI.
OVSDB can now meet the API freeze milestone while we work on the
implementation

Change-Id: Icdc78a64f31d4e62926284c4669ecec65877421a
Signed-off-by: Dave Tucker <djt@redhat.com>
northbound/src/main/java/org/opendaylight/ovsdb/northbound/DatabaseResource.java [new file with mode: 0644]
northbound/src/main/java/org/opendaylight/ovsdb/northbound/NodeResource.java [new file with mode: 0644]
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbNorthboundV2.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbNorthboundV3.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRows.java
northbound/src/main/java/org/opendaylight/ovsdb/northbound/RowResource.java [new file with mode: 0644]
northbound/src/main/java/org/opendaylight/ovsdb/northbound/TableResource.java [new file with mode: 0644]

diff --git a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/DatabaseResource.java b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/DatabaseResource.java
new file mode 100644 (file)
index 0000000..d49d882
--- /dev/null
@@ -0,0 +1,39 @@
+package org.opendaylight.ovsdb.northbound;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Northbound interface for OVSDB Databases
+ */
+public class DatabaseResource {
+
+    String nodeId;
+
+    DatabaseResource(String id) {
+        this.nodeId = id;
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getDatabases(){
+        return Response.noContent().build();
+    }
+
+    @GET
+    @Path("{name}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getDatabases(@PathParam("name") String name){
+        return Response.noContent().build();
+    }
+
+    @Path("{name}/table")
+    public TableResource getDatabaseTables(@PathParam("name") String name){
+        return new TableResource(nodeId, name);
+    }
+
+}
diff --git a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/NodeResource.java b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/NodeResource.java
new file mode 100644 (file)
index 0000000..c6491d8
--- /dev/null
@@ -0,0 +1,60 @@
+package org.opendaylight.ovsdb.northbound;
+
+import java.io.InputStream;
+
+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;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Northbound Interface for OVSDB Nodes
+ */
+public class NodeResource {
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNodes(){
+        return Response.noContent().build();
+    }
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response createNode(InputStream is){
+        return Response.noContent().build();
+    }
+
+    @GET
+    @Path("{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNode(@PathParam("id") String id){
+        return Response.noContent().build();
+    }
+
+    @PUT
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response updateNode(@PathParam("id") String id, InputStream is){
+        return Response.noContent().build();
+    }
+
+    @DELETE
+    @Path("{id}")
+    public Response deleteNode(@PathParam("id") String id){
+        return Response.noContent().build();
+    }
+
+    @Path("{id}/database")
+    public DatabaseResource getNodeDatabase(@PathParam("id") String nodeId){
+        return new DatabaseResource(nodeId);
+    }
+
+}
index 0cc60695e52efde604cb539a7a3ecc061db76373..2e2eca8276b6df79001308f55abc9b9b928e98a0 100644 (file)
@@ -70,6 +70,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 */
 
 @Path("/v2/")
+@Deprecated
 public class OvsdbNorthboundV2 {
     protected static final Logger logger = LoggerFactory.getLogger(OvsdbNorthboundV2.class);
 
index 4a9e70ffd48034a380d0ee070c7fbd59e33d70cf..a7dabda14744b0be9c1a69ec400fc5bbd9ff0581 100644 (file)
@@ -9,16 +9,47 @@
  */
 package org.opendaylight.ovsdb.northbound;
 
-import javax.ws.rs.Path;
+import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
+import org.opendaylight.controller.sal.authorization.Privilege;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
 /**
-* OVSDB Northbound V3 REST API.<br>
+* OVSDB Northbound V3 REST API
 */
 
 @Path("/v3/")
 public class OvsdbNorthboundV3 {
     protected static final Logger logger = LoggerFactory.getLogger(OvsdbNorthboundV3.class);
+
+    @Context
+    private UriInfo _uriInfo;
+    private String username;
+
+    @Context
+    public void setSecurityContext(SecurityContext context) {
+        if (context != null && context.getUserPrincipal() != null) {
+            username = context.getUserPrincipal().getName();
+        }
+    }
+
+    protected String getUserName() {
+        return username;
+    }
+
+    @Path("node")
+    public NodeResource getNode(){
+        if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
+            throw new UnauthorizedException("User is not authorized to perform this operation");
+        }
+        return new NodeResource();
+    }
+
 }
index 91562e7bbb56b536f2580104bf7a1b52d551ad86..2b955945ad2dc7ea7c65da45996193e3ad980a34 100644 (file)
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
+@Deprecated
 public class OvsdbRow {
     private static final String PARENTUUID = "parent_uuid";
     private static final String ROW = "row";
index 8862a7ca6ed7f879548f2f73bc942e02bec087ea..745f464323ff17a31c379a067afb667fbcdf34f5 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Map;
 
 import org.opendaylight.ovsdb.lib.notation.Row;
 
+@Deprecated
 public class OvsdbRows {
     Map<String, Row> rows;
 
diff --git a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/RowResource.java b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/RowResource.java
new file mode 100644 (file)
index 0000000..f61b06c
--- /dev/null
@@ -0,0 +1,67 @@
+package org.opendaylight.ovsdb.northbound;
+
+import java.io.InputStream;
+
+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;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Northbound interface for OVSDB Rows
+ */
+public class RowResource {
+
+    String nodeId;
+    String databaseName;
+    String rowName;
+
+    public RowResource(String nodeId, String databaseName, String rowName) {
+        this.nodeId = nodeId;
+        this.databaseName = databaseName;
+        this.rowName = rowName;
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getRows(){
+        return Response.noContent().build();
+    }
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response createRow(InputStream stream) {
+        return Response.noContent().build();
+    }
+
+    @GET
+    @Path("{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getRowDetails(@PathParam("id") String id){
+        return Response.noContent().build();
+    }
+
+    @PUT
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response updateRow(@PathParam("id") String id){
+        return Response.noContent().build();
+    }
+
+    @DELETE
+    @Path("{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response deleteRow(@PathParam("id") String id){
+        return Response.noContent().build();
+    }
+
+
+}
diff --git a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/TableResource.java b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/TableResource.java
new file mode 100644 (file)
index 0000000..8620516
--- /dev/null
@@ -0,0 +1,41 @@
+package org.opendaylight.ovsdb.northbound;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * Northbound interface for OVSDB tables
+ */
+public class TableResource {
+
+    String databaseName;
+    String nodeId;
+
+    TableResource(String nodeId, String databaseName){
+        this.nodeId = nodeId;
+        this.databaseName = databaseName;
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getTables(){
+        return Response.noContent().build();
+    }
+
+    @GET
+    @Path("{name}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getTableDetails(@PathParam("name") String name){
+        return Response.noContent().build();
+    }
+
+    @Path("{name}/row")
+    public RowResource getDatabaseTables(@PathParam("name") String name){
+        return new RowResource(nodeId, databaseName, name);
+    }
+
+}