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.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
17 import org.opendaylight.yangtools.yang.common.Empty;
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>.
24 public interface RestconfServer {
26 * Delete a data resource.
28 * @param identifier resource identifier
29 * @return A {@link RestconfFuture} of the operation
31 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
32 RestconfFuture<Empty> dataDELETE(ServerRequest request, ApiPath identifier);
35 * Return the content of the datastore.
37 * @param request {@link ServerRequest} for this request
38 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
40 RestconfFuture<DataGetResult> dataGET(ServerRequest request);
43 * Return the content of a data resource.
45 * @param request {@link ServerRequest} for this request
46 * @param identifier resource identifier
47 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
49 RestconfFuture<DataGetResult> dataGET(ServerRequest request, ApiPath identifier);
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>.
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
59 RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ResourceBody body);
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>.
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
70 RestconfFuture<DataPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, ResourceBody body);
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>.
76 * @param request {@link ServerRequest} for this request
77 * @param body YANG Patch body
78 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
80 RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, PatchBody body);
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>.
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
91 RestconfFuture<DataYangPatchResult> dataPATCH(ServerRequest request, ApiPath identifier, PatchBody body);
93 RestconfFuture<CreateResourceResult> dataPOST(ServerRequest request, ChildBody body);
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>.
99 * @param request {@link ServerRequest} for this request
100 * @param identifier path to target
101 * @param body body of the post request
103 RestconfFuture<? extends DataPostResult> dataPOST(ServerRequest request, ApiPath identifier, DataPostBody body);
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>.
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}
113 RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ResourceBody body);
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>.
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}
124 RestconfFuture<DataPutResult> dataPUT(ServerRequest request, ApiPath identifier, ResourceBody body);
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.
132 * @param request {@link ServerRequest} for this request
133 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
135 RestconfFuture<FormattableBody> operationsGET(ServerRequest request);
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.
143 * @param request {@link ServerRequest} for this request
144 * @param operation An operation
145 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
147 RestconfFuture<FormattableBody> operationsGET(ServerRequest request, ApiPath operation);
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>.
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}
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);
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>.
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.
172 RestconfFuture<FormattableBody> yangLibraryVersionGET(ServerRequest request);
174 RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, String fileName, @Nullable String revision);
176 RestconfFuture<ModulesGetResult> modulesYangGET(ServerRequest request, ApiPath mountPath, String fileName,
177 @Nullable String revision);
179 RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, String fileName, @Nullable String revision);
181 RestconfFuture<ModulesGetResult> modulesYinGET(ServerRequest request, ApiPath mountPath, String fileName,
182 @Nullable String revision);