Allow YANG PATCH to communicate ETag/Last-Modified
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / RestconfServer.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.server.api;
9
10 import java.net.URI;
11 import java.util.Map;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.restconf.api.ApiPath;
15 import org.opendaylight.restconf.common.errors.RestconfFuture;
16 import org.opendaylight.restconf.nb.rfc8040.databind.ChildBody;
17 import org.opendaylight.restconf.nb.rfc8040.databind.DataPostBody;
18 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
19 import org.opendaylight.restconf.nb.rfc8040.databind.PatchBody;
20 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
21 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
22 import org.opendaylight.yangtools.yang.common.Empty;
23
24 /**
25  * An implementation of a RESTCONF server, implementing the
26  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
27  */
28 @NonNullByDefault
29 public interface RestconfServer {
30     /**
31      * Delete a data resource.
32      *
33      * @param identifier resource identifier
34      * @return A {@link RestconfFuture} of the operation
35      */
36     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
37     RestconfFuture<Empty> dataDELETE(ApiPath identifier);
38
39     /**
40      * Return the content of the datastore.
41      *
42      * @param params {@link DataGetParams} for this request
43      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
44      */
45     RestconfFuture<DataGetResult> dataGET(DataGetParams params);
46
47     /**
48      * Return the content of a data resource.
49      *
50      * @param identifier resource identifier
51      * @param params {@link DataGetParams} for this request
52      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
53      */
54     RestconfFuture<DataGetResult> dataGET(ApiPath identifier, DataGetParams params);
55
56     /**
57      * Partially modify the target data resource, as defined in
58      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
59      *
60      * @param body data node for put to config DS
61      * @return A {@link RestconfFuture} of the operation
62      */
63     RestconfFuture<DataPatchResult> dataPATCH(ResourceBody body);
64
65     /**
66      * Partially modify the target data resource, as defined in
67      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
68      *
69      * @param identifier resource identifier
70      * @param body data node for put to config DS
71      * @return A {@link RestconfFuture} of the operation
72      */
73     RestconfFuture<DataPatchResult> dataPATCH(ApiPath identifier, ResourceBody body);
74
75     /**
76      * Ordered list of edits that are applied to the datastore by the server, as defined in
77      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
78      *
79      * @param body YANG Patch body
80      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
81      */
82     RestconfFuture<DataYangPatchResult> dataPATCH(PatchBody body);
83
84     /**
85      * Ordered list of edits that are applied to the datastore by the server, as defined in
86      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
87      *
88      * @param identifier path to target
89      * @param body YANG Patch body
90      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
91      */
92     RestconfFuture<DataYangPatchResult> dataPATCH(ApiPath identifier, PatchBody body);
93
94     RestconfFuture<DataPostResult.CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
95
96     RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
97         Map<String, String> queryParameters);
98
99     /**
100      * Replace the data store.
101      *
102      * @param body data node for put to config DS
103      * @param queryParameters Query parameters
104      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
105      */
106     RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
107
108     /**
109      * Create or replace a data store resource.
110      *
111      * @param identifier resource identifier
112      * @param body data node for put to config DS
113      * @param queryParameters Query parameters
114      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
115      */
116     RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
117
118     /**
119      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
120      * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
121      * {@code container operations} statement.
122      *
123      * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
124      */
125     RestconfFuture<OperationsGetResult> operationsGET();
126
127     /*
128      * Return the details about a particular operation supported by
129      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
130      * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
131      * {@code container operations} statement.
132      *
133      * @param operation An operation
134      * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
135      */
136     RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
137
138     /**
139      * Invoke an RPC operation, as defined in
140      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
141      *
142      * @param restconfURI Base URI of the request
143      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
144      * @param body RPC operation
145      * @return A {@link RestconfFuture} completing with {@link OperationsPostResult}
146      */
147     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support yang-ext:mount,
148     //        and hence it is a path right now
149     RestconfFuture<OperationsPostResult> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
150
151     /**
152      * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
153      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
154      *
155      * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
156      *        {@code yang-library-version} leaf element.
157      */
158     // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
159     //        construct for both cases -- in this case it carries a yang.common.Revision
160     RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
161
162     RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
163
164     RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
165
166     RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
167
168     RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);
169 }