2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.restconf.server.api;
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;
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>.
23 public interface RestconfServer {
25 * Delete a data resource.
27 * @param identifier resource identifier
28 * @return A {@link RestconfFuture} of the operation
30 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
31 RestconfFuture<Empty> dataDELETE(ServerRequest request, ApiPath identifier);
34 * Return the content of the datastore.
36 * @param request {@link ServerRequest} for this request
37 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
39 RestconfFuture<DataGetResult> dataGET(ServerRequest request);
42 * Return the content of a data resource.
44 * @param request {@link ServerRequest} for this request
45 * @param identifier resource identifier
46 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
48 RestconfFuture<DataGetResult> dataGET(ServerRequest request, ApiPath identifier);
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>.
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
58 RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ResourceBody body);
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>.
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
69 RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, ResourceBody body);
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>.
75 * @param request {@link ServerRequest} for this request
76 * @param body YANG Patch body
77 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
79 RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, PatchBody body);
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>.
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
90 RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, PatchBody body);
92 RestconfFuture<CreateResourceResult> dataPOST(ServerRequest request, ChildBody body);
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>.
98 * @param request {@link ServerRequest} for this request
99 * @param identifier path to target
100 * @param body body of the post request
102 RestconfFuture<? extends DataPostResult> dataPOST(ServerRequest request, ApiPath identifier, DataPostBody body);
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>.
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}
112 RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ResourceBody body);
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>.
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}
123 RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ApiPath identifier, ResourceBody body);
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.
131 * @param request {@link ServerRequest} for this request
132 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
134 RestconfFuture<FormattableBody> operationsGET(ServerRequest request);
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.
142 * @param request {@link ServerRequest} for this request
143 * @param operation An operation
144 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
146 RestconfFuture<FormattableBody> operationsGET(ServerRequest request, ApiPath operation);
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>.
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}
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);
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>.
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.
171 RestconfFuture<FormattableBody> yangLibraryVersionGET(ServerRequest request);
173 RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, String fileName, @Nullable String revision);
175 RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, ApiPath mountPath, String fileName,
176 @Nullable String revision);
178 RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, String fileName, @Nullable String revision);
180 RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, ApiPath mountPath, String fileName,
181 @Nullable String revision);