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