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;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.restconf.api.ApiPath;
15 import org.opendaylight.restconf.api.FormattableBody;
16 import org.opendaylight.restconf.common.errors.RestconfFuture;
17 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
18 import org.opendaylight.yangtools.yang.common.Empty;
21 * An implementation of a RESTCONF server, implementing the
22 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
25 public interface RestconfServer {
27 * Delete a data resource.
29 * @param identifier resource identifier
30 * @return A {@link RestconfFuture} of the operation
32 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
33 RestconfFuture<Empty> dataDELETE(ApiPath identifier);
36 * Return the content of the datastore.
38 * @param params {@link DataGetParams} for this request
39 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
41 RestconfFuture<DataGetResult> dataGET(DataGetParams params);
44 * Return the content of a data resource.
46 * @param identifier resource identifier
47 * @param params {@link DataGetParams} for this request
48 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
50 RestconfFuture<DataGetResult> dataGET(ApiPath identifier, DataGetParams params);
53 * Partially modify the target data resource, as defined in
54 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
56 * @param body data node for put to config DS
57 * @return A {@link RestconfFuture} of the operation
59 RestconfFuture<DataPatchResult> dataPATCH(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 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(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 queryParameters query parameters
76 * @param body YANG Patch body
77 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
79 RestconfFuture<DataYangPatchResult> dataPATCH(Map<String, String> queryParameters, 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 identifier path to target
86 * @param queryParameters query parameters
87 * @param body YANG Patch body
88 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
90 RestconfFuture<DataYangPatchResult> dataPATCH(ApiPath identifier, Map<String, String> queryParameters,
93 RestconfFuture<CreateResourceResult> dataPOST(ChildBody body, Map<String, String> queryParameters);
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 identifier path to target
100 * @param body body of the post request
101 * @param queryParameters query parameters
103 RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
104 Map<String, String> queryParameters);
107 * Replace the data store, as described in
108 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
110 * @param body data node for put to config DS
111 * @param queryParameters Query parameters
112 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
114 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
117 * Create or replace a data store resource, as described in
118 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
120 * @param identifier resource identifier
121 * @param body data node for put to config DS
122 * @param queryParameters Query parameters
123 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
125 RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
128 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, Map, 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 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
134 RestconfFuture<FormattableBody> operationsGET();
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 operation An operation
143 * @return A {@link RestconfFuture} completing with an {@link FormattableBody}
145 RestconfFuture<FormattableBody> operationsGET(ApiPath operation);
148 * Invoke an RPC operation, as defined in
149 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
151 * @param restconfURI Base URI of the request
152 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
153 * @param queryParameters query parameters
154 * @param body RPC operation
155 * @return A {@link RestconfFuture} completing with {@link InvokeResult}
157 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support yang-ext:mount,
158 // and hence it is a path right now
159 RestconfFuture<InvokeResult> operationsPOST(URI restconfURI, ApiPath operation, Map<String, String> queryParameters,
160 OperationInputBody body);
163 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
164 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
166 * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
167 * {@code yang-library-version} leaf element.
169 // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
170 // construct for both cases -- in this case it carries a yang.common.Revision
171 RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
173 RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
175 RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
177 RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
179 RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);