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