Refactor modulesGET() methods
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / RestconfServer.java
index 4b8212d9eb190d50cb25cb12f7a1138cb0ce3fe7..827c3be02b1292d20775532ee31cb6f31155aafc 100644 (file)
@@ -29,6 +29,9 @@ import org.opendaylight.yangtools.yang.common.Empty;
  * An implementation of a RESTCONF server, implementing the
  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
  */
+// FIXME: configuration datastore should maintain ETag and Last-Modified headers, so that these can be returned when
+//        GET/PATCH/POST/PUT modify the data.
+// FIXME: NETCONF-773: as a first step in doing that we should carry those fields in our responses
 @NonNullByDefault
 public interface RestconfServer {
     /**
@@ -38,7 +41,7 @@ public interface RestconfServer {
      * @return A {@link RestconfFuture} of the operation
      */
     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
-    RestconfFuture<Empty> dataDELETE(String identifier);
+    RestconfFuture<Empty> dataDELETE(ApiPath identifier);
 
     /**
      * Return the content of the datastore.
@@ -55,7 +58,7 @@ public interface RestconfServer {
      * @param readParams {@link ReadDataParams} for this request
      * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
      */
-    RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
+    RestconfFuture<NormalizedNodePayload> dataGET(ApiPath identifier, ReadDataParams readParams);
 
     /**
      * Partially modify the target data resource, as defined in
@@ -74,7 +77,7 @@ public interface RestconfServer {
      * @param body data node for put to config DS
      * @return A {@link RestconfFuture} of the operation
      */
-    RestconfFuture<Empty> dataPATCH(String identifier, ResourceBody body);
+    RestconfFuture<Empty> dataPATCH(ApiPath identifier, ResourceBody body);
 
     /**
      * Ordered list of edits that are applied to the datastore by the server, as defined in
@@ -93,11 +96,11 @@ public interface RestconfServer {
      * @param body YANG Patch body
      * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
      */
-    RestconfFuture<PatchStatusContext> dataPATCH(String identifier, PatchBody body);
+    RestconfFuture<PatchStatusContext> dataPATCH(ApiPath identifier, PatchBody body);
 
     RestconfFuture<CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
 
-    RestconfFuture<? extends DataPostResult> dataPOST(String identifier, DataPostBody body,
+    RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
         Map<String, String> queryParameters);
 
     /**
@@ -117,27 +120,27 @@ public interface RestconfServer {
      * @param queryParameters Query parameters
      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
      */
-    RestconfFuture<DataPutResult> dataPUT(String identifier, ResourceBody body, Map<String, String> queryParameters);
+    RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
 
     /**
-     * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
+     * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
+     * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
+     * {@code container operations} statement.
      *
-     * @return An {@link OperationsGetResult}
+     * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
      */
-    OperationsGetResult operationsGET();
+    RestconfFuture<OperationsGetResult> operationsGET();
 
     /*
      * Return the details about a particular operation supported by
      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
-     * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84>RFC8040<a> {@code container operations} statement.
+     * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
+     * {@code container operations} statement.
      *
      * @param operation An operation
-     * @return An {@link OperationsContent}, or {@code null} if {@code operation} does not point to an {@code rpc}
+     * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
      */
-    // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
-    //        and hence it is a path right now
-    // FIXME: use ApiPath instead of String
-    @Nullable OperationsGetResult operationsGET(String operation);
+    RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
 
     /**
      * Invoke an RPC operation, as defined in
@@ -146,21 +149,29 @@ public interface RestconfServer {
      * @param restconfURI Base URI of the request
      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
      * @param body RPC operation
-     * @return A {@link RestconfFuture} of the {@link OperationOutput operation result}
+     * @return A {@link RestconfFuture} completing with {@link OperationOutput}
      */
     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
     //        and hence it is a path right now
     // FIXME: use ApiPath instead of String
-    RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
+    RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
 
     /**
      * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
      *
-     * @return A {@code yang-library-version} element
+     * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
+     *        {@code yang-library-version} leaf element.
      */
-    // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
-    //        construct for both cases
-    // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
-    NormalizedNodePayload yangLibraryVersionGET();
+    // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
+    //        construct for both cases -- in this case it carries a yang.common.Revision
+    RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
+
+    RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
+
+    RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
+
+    RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
+
+    RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);
 }