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>
--- /dev/null
+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);
+ }
+
+}
--- /dev/null
+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);
+ }
+
+}
*/
@Path("/v2/")
+@Deprecated
public class OvsdbNorthboundV2 {
protected static final Logger logger = LoggerFactory.getLogger(OvsdbNorthboundV2.class);
*/
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();
+ }
+
}
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";
import org.opendaylight.ovsdb.lib.notation.Row;
+@Deprecated
public class OvsdbRows {
Map<String, Row> rows;
--- /dev/null
+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();
+ }
+
+
+}
--- /dev/null
+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);
+ }
+
+}