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.common.patch.PatchStatusContext;
17 import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
18 import org.opendaylight.restconf.nb.rfc8040.databind.ChildBody;
19 import org.opendaylight.restconf.nb.rfc8040.databind.DataPostBody;
20 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
21 import org.opendaylight.restconf.nb.rfc8040.databind.PatchBody;
22 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
23 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
24 import org.opendaylight.restconf.server.api.DataPostResult.CreateResource;
25 import org.opendaylight.restconf.server.spi.OperationOutput;
26 import org.opendaylight.yangtools.yang.common.Empty;
29 * An implementation of a RESTCONF server, implementing the
30 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
32 // FIXME: configuration datastore should maintain ETag and Last-Modified headers, so that these can be returned when
33 // GET/PATCH/POST/PUT modify the data.
34 // FIXME: NETCONF-773: as a first step in doing that we should carry those fields in our responses
36 public interface RestconfServer {
38 * Delete a data resource.
40 * @param identifier resource identifier
41 * @return A {@link RestconfFuture} of the operation
43 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
44 RestconfFuture<Empty> dataDELETE(ApiPath identifier);
47 * Return the content of the datastore.
49 * @param readParams {@link ReadDataParams} for this request
50 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
52 RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
55 * Return the content of a data resource.
57 * @param identifier resource identifier
58 * @param readParams {@link ReadDataParams} for this request
59 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
61 RestconfFuture<NormalizedNodePayload> dataGET(ApiPath identifier, ReadDataParams readParams);
64 * Partially modify the target data resource, as defined in
65 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
67 * @param body data node for put to config DS
68 * @return A {@link RestconfFuture} of the operation
70 RestconfFuture<Empty> dataPATCH(ResourceBody body);
73 * Partially modify the target data resource, as defined in
74 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
76 * @param identifier resource identifier
77 * @param body data node for put to config DS
78 * @return A {@link RestconfFuture} of the operation
80 RestconfFuture<Empty> dataPATCH(ApiPath identifier, ResourceBody 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 body YANG Patch body
87 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
89 RestconfFuture<PatchStatusContext> dataPATCH(PatchBody body);
92 * Ordered list of edits that are applied to the datastore by the server, as defined in
93 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
95 * @param identifier path to target
96 * @param body YANG Patch body
97 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
99 RestconfFuture<PatchStatusContext> dataPATCH(ApiPath identifier, PatchBody body);
101 RestconfFuture<CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
103 RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
104 Map<String, String> queryParameters);
107 * Replace the data store.
109 * @param body data node for put to config DS
110 * @param queryParameters Query parameters
111 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
113 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
116 * Create or replace a data store resource.
118 * @param identifier resource identifier
119 * @param body data node for put to config DS
120 * @param queryParameters Query parameters
121 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
123 RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
126 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
127 * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
128 * {@code container operations} statement.
130 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
132 RestconfFuture<OperationsGetResult> operationsGET();
135 * Return the details about a particular operation supported by
136 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
137 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
138 * {@code container operations} statement.
140 * @param operation An operation
141 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
143 RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
146 * Invoke an RPC operation, as defined in
147 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
149 * @param restconfURI Base URI of the request
150 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
151 * @param body RPC operation
152 * @return A {@link RestconfFuture} completing with {@link OperationOutput}
154 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
155 // and hence it is a path right now
156 // FIXME: use ApiPath instead of String
157 RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
160 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
161 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
163 * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
164 * {@code yang-library-version} leaf element.
166 // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
167 // construct for both cases -- in this case it carries a yang.common.Revision
168 RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
170 RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
172 RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
174 RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
176 RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);