Eliminate NormalizedNodePayload
[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 org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.restconf.api.ApiPath;
14 import org.opendaylight.restconf.api.FormattableBody;
15 import org.opendaylight.restconf.common.errors.RestconfFuture;
16 import org.opendaylight.yangtools.yang.common.Empty;
17
18 /**
19  * An implementation of a RESTCONF server, implementing the
20  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
21  */
22 @NonNullByDefault
23 public interface RestconfServer {
24     /**
25      * Delete a data resource.
26      *
27      * @param identifier resource identifier
28      * @return A {@link RestconfFuture} of the operation
29      */
30     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
31     RestconfFuture<Empty> dataDELETE(ServerRequest request, ApiPath identifier);
32
33     /**
34      * Return the content of the datastore.
35      *
36      * @param request {@link ServerRequest} for this request
37      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
38      */
39     RestconfFuture<DataGetResult> dataGET(ServerRequest request);
40
41     /**
42      * Return the content of a data resource.
43      *
44      * @param request {@link ServerRequest} for this request
45      * @param identifier resource identifier
46      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
47      */
48     RestconfFuture<DataGetResult> dataGET(ServerRequest request, ApiPath identifier);
49
50     /**
51      * Partially modify the target data resource, as defined in
52      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
53      *
54      * @param request {@link ServerRequest} for this request
55      * @param body data node for put to config DS
56      * @return A {@link RestconfFuture} of the operation
57      */
58     RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ResourceBody body);
59
60     /**
61      * Partially modify the target data resource, as defined in
62      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
63      *
64      * @param request {@link ServerRequest} for this request
65      * @param identifier resource identifier
66      * @param body data node for put to config DS
67      * @return A {@link RestconfFuture} of the operation
68      */
69     RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, ResourceBody body);
70
71     /**
72      * Ordered list of edits that are applied to the datastore by the server, as defined in
73      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
74      *
75      * @param request {@link ServerRequest} for this request
76      * @param body YANG Patch body
77      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
78      */
79     RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, PatchBody body);
80
81     /**
82      * Ordered list of edits that are applied to the datastore by the server, as defined in
83      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
84      *
85      * @param request {@link ServerRequest} for this request
86      * @param identifier path to target
87      * @param body YANG Patch body
88      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
89      */
90     RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, PatchBody body);
91
92     RestconfFuture<CreateResourceResult> dataPOST(ServerRequest request, ChildBody body);
93
94     /**
95      * Create or invoke a operation, as described in
96      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.4">RFC8040 section 4.4</a>.
97      *
98      * @param request {@link ServerRequest} for this request
99      * @param identifier path to target
100      * @param body body of the post request
101      */
102     RestconfFuture<? extends DataPostResult> dataPOST(ServerRequest request, ApiPath identifier, DataPostBody body);
103
104     /**
105      * Replace the data store, as described in
106      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
107      *
108      * @param request {@link ServerRequest} for this request
109      * @param body data node for put to config DS
110      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
111      */
112     RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ResourceBody body);
113
114     /**
115      * Create or replace a data store resource, as described in
116      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
117      *
118      * @param request {@link ServerRequest} for this request
119      * @param identifier resource identifier
120      * @param body data node for put to config DS
121      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
122      */
123     RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ApiPath identifier, ResourceBody body);
124
125     /**
126      * Return the set of supported RPCs supported by
127      * {@link #operationsPOST(ServerRequest, URI, ApiPath, OperationInputBody)},
128      * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
129      * {@code container operations} statement.
130      *
131      * @param request {@link ServerRequest} for this request
132      * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
133      */
134     RestconfFuture<FormattableBody> operationsGET(ServerRequest request);
135
136     /*
137      * Return the details about a particular operation supported by
138      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
139      * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
140      * {@code container operations} statement.
141      *
142      * @param request {@link ServerRequest} for this request
143      * @param operation An operation
144      * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
145      */
146     RestconfFuture<FormattableBody> operationsGET(ServerRequest request, ApiPath operation);
147
148     /**
149      * Invoke an RPC operation, as defined in
150      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
151      *
152      * @param request {@link ServerRequest} for this request
153      * @param restconfURI Base URI of the request
154      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
155      * @param body RPC operation
156      * @return A {@link RestconfFuture} completing with {@link InvokeResult}
157      */
158     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support yang-ext:mount,
159     //        and hence it is a path right now
160     RestconfFuture<InvokeResult> operationsPOST(ServerRequest request, URI restconfURI, ApiPath operation,
161         OperationInputBody body);
162
163     /**
164      * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
165      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
166      *
167      * @param request {@link ServerRequest} for this request
168      * @return A {@link RestconfFuture} completing with {@link FormattableBody} containing a single
169      *        {@code yang-library-version} leaf element.
170      */
171     RestconfFuture<FormattableBody> yangLibraryVersionGET(ServerRequest request);
172
173     RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, String fileName, @Nullable String revision);
174
175     RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, ApiPath mountPath, String fileName,
176         @Nullable String revision);
177
178     RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, String fileName, @Nullable String revision);
179
180     RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, ApiPath mountPath, String fileName,
181         @Nullable String revision);
182 }