Exception for URI /restconf/operations/module_name:rpc ended with slash
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / rest / api / RestconfService.java
index b8cb2292542b8da4ecf7f8573d6b578a47ff3810..0683c45ebc82b7997a02cdbbceb90658a391fe5b 100644 (file)
@@ -7,42 +7,45 @@
  */
 package org.opendaylight.controller.sal.rest.api;
 
-import static org.opendaylight.controller.sal.restconf.impl.MediaTypes.API;
-
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
 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.Encoded;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.opendaylight.controller.sal.restconf.impl.StructuredData;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
 /**
  *   The URI hierarchy for the RESTCONF resources consists of an entry
- *   point container, 3 top-level resources, and 1 field.  Refer to
- *  Section 5 for details on each URI.
- *    <ul>
+ *   point container, 4 top-level resources, and 1 field.
+ *   <ul>
  *    <li><b>/restconf</b> - {@link #getRoot()}
- *     <ul><li><b>/datastore</b> - {@link #readAllData()}
- *         <ul>
- *            <li>/(top-level-data-nodes) (config=true or false)
- *         </ul>
- *         <li>/modules
- *          <ul><li>/module
- *              <li>/name
- *              <li>/revision
- *              <li>/namespace
- *              <li>/feature
- *             <li>/deviation
- *          </ul>
- *          <li>/operations
- *          <ul>
- *             <li>/(custom protocol operations)
- *          </ul>
- *         <li>/version (field)
+ *     <ul>
+ *      <li><b>/config</b> - {@link #readConfigurationData(String)} 
+ *                              {@link #updateConfigurationData(String, CompositeNode)}
+ *                              {@link #createConfigurationData(CompositeNode)}
+ *                              {@link #createConfigurationData(String, CompositeNode)}
+ *                              {@link #deleteConfigurationData(String)}
+ *      <li><b>/operational</b> - {@link #readOperationalData(String)} 
+ *      <li>/modules - {@link #getModules()}
+ *       <ul>
+ *        <li>/module
+ *       </ul>
+ *      <li><b>/operations</b> - {@link #invokeRpc(String, CompositeNode)}
+ *                               {@link #invokeRpc(String, CompositeNode)}
+ *      <li>/version (field)
  *     </ul>
+ *   </ul>
  */
 @Path("/")
 public interface RestconfService {
@@ -54,32 +57,88 @@ public interface RestconfService {
     public Object getRoot();
 
     @GET
-    @Path("/datastore")
-    @Produces({API+JSON,API+XML})
-    public Object readAllData();
+    @Path("/modules")
+    @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData getModules();
 
     @GET
-    @Path("/datastore/{identifier:.+}")
-    @Produces({API+JSON,API+XML})
-    public StructuredData readData(@PathParam("identifier") String identifier);
+    @Path("/modules/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData getModules(@PathParam("identifier") String identifier);
 
-    @PUT
-    @Path("/datastore/{identifier:.+}")
-    @Produces({API+JSON,API+XML})
-    public Object createConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
+    @GET
+    @Path("/modules/module/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData getModule(@PathParam("identifier") String identifier);
+
+    @GET
+    @Path("/operations")
+    @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData getOperations();
+
+    @GET
+    @Path("/operations/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.API+XML, Draft02.MediaTypes.API+JSON,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData getOperations(@PathParam("identifier") String identifier);
 
     @POST
-    @Path("/datastore/{identifier:.+}")
-    @Produces({API+JSON,API+XML})
-    public Object updateConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
+    @Path("/operations/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
+               Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    @Consumes({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
+               Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
+    
+    @POST
+    @Path("/operations/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+XML,
+               Draft02.MediaTypes.DATA+JSON, Draft02.MediaTypes.DATA+XML,
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData invokeRpc(@Encoded @PathParam("identifier") String identifier, @DefaultValue("") String noPayload);
+    
+    @GET
+    @Path("/config/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier);
 
     @GET
-    @Path("/modules")
-    @Produces({API+JSON,API+XML})
-    public Object getModules();
+    @Path("/operational/{identifier:.+}")
+    @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier);
+
+    @PUT
+    @Path("/config/{identifier:.+}")
+    @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
+
+    @POST
+    @Path("/config/{identifier:.+}")
+    @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
 
     @POST
-    @Path("/operations/{identifier}")
-    @Produces({API+JSON,API+XML})
-    public StructuredData invokeRpc(@PathParam("identifier") String identifier, CompositeNode payload);
+    @Path("/config")
+    @Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML, 
+               MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
+    public Response createConfigurationData(CompositeNode payload);
+
+    @DELETE
+    @Path("/config/{identifier:.+}")
+    public Response deleteConfigurationData(@Encoded @PathParam("identifier") String identifier);
+
+    @GET
+    @Path("/streams/stream/{identifier:.+}")
+    public Response subscribeToStream(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
+
 }