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.common.errors.RestconfFuture;
16 import org.opendaylight.restconf.nb.rfc8040.databind.ChildBody;
17 import org.opendaylight.restconf.nb.rfc8040.databind.DataPostBody;
18 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
19 import org.opendaylight.restconf.nb.rfc8040.databind.PatchBody;
20 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
21 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
22 import org.opendaylight.yangtools.yang.common.Empty;
25 * An implementation of a RESTCONF server, implementing the
26 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
29 public interface RestconfServer {
31 * Delete a data resource.
33 * @param identifier resource identifier
34 * @return A {@link RestconfFuture} of the operation
36 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
37 RestconfFuture<Empty> dataDELETE(ApiPath identifier);
40 * Return the content of the datastore.
42 * @param params {@link DataGetParams} for this request
43 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
45 RestconfFuture<DataGetResult> dataGET(DataGetParams params);
48 * Return the content of a data resource.
50 * @param identifier resource identifier
51 * @param params {@link DataGetParams} for this request
52 * @return A {@link RestconfFuture} of the {@link DataGetResult} content
54 RestconfFuture<DataGetResult> dataGET(ApiPath identifier, DataGetParams params);
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>.
60 * @param body data node for put to config DS
61 * @return A {@link RestconfFuture} of the operation
63 RestconfFuture<DataPatchResult> dataPATCH(ResourceBody body);
66 * Partially modify the target data resource, as defined in
67 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
69 * @param identifier resource identifier
70 * @param body data node for put to config DS
71 * @return A {@link RestconfFuture} of the operation
73 RestconfFuture<DataPatchResult> dataPATCH(ApiPath identifier, ResourceBody body);
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>.
79 * @param body YANG Patch body
80 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
82 RestconfFuture<DataYangPatchResult> dataPATCH(PatchBody body);
85 * Ordered list of edits that are applied to the datastore by the server, as defined in
86 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
88 * @param identifier path to target
89 * @param body YANG Patch body
90 * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
92 RestconfFuture<DataYangPatchResult> dataPATCH(ApiPath identifier, PatchBody body);
94 RestconfFuture<DataPostResult.CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
96 RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
97 Map<String, String> queryParameters);
100 * Replace the data store.
102 * @param body data node for put to config DS
103 * @param queryParameters Query parameters
104 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
106 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
109 * Create or replace a data store resource.
111 * @param identifier resource identifier
112 * @param body data node for put to config DS
113 * @param queryParameters Query parameters
114 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
116 RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
119 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
120 * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
121 * {@code container operations} statement.
123 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
125 RestconfFuture<OperationsGetResult> operationsGET();
128 * Return the details about a particular operation supported by
129 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
130 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
131 * {@code container operations} statement.
133 * @param operation An operation
134 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
136 RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
139 * Invoke an RPC operation, as defined in
140 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
142 * @param restconfURI Base URI of the request
143 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
144 * @param body RPC operation
145 * @return A {@link RestconfFuture} completing with {@link OperationsPostResult}
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 RestconfFuture<OperationsPostResult> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
152 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
153 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
155 * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
156 * {@code yang-library-version} leaf element.
158 // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
159 // construct for both cases -- in this case it carries a yang.common.Revision
160 RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
162 RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
164 RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
166 RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
168 RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);