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.opendaylight.restconf.api.ApiPath;
14 import org.opendaylight.restconf.common.errors.RestconfFuture;
15 import org.opendaylight.restconf.common.patch.PatchStatusContext;
16 import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
17 import org.opendaylight.restconf.nb.rfc8040.databind.ChildBody;
18 import org.opendaylight.restconf.nb.rfc8040.databind.DataPostBody;
19 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
20 import org.opendaylight.restconf.nb.rfc8040.databind.PatchBody;
21 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
22 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
23 import org.opendaylight.restconf.server.api.DataPostResult.CreateResource;
24 import org.opendaylight.restconf.server.spi.OperationOutput;
25 import org.opendaylight.yangtools.yang.common.Empty;
28 * An implementation of a RESTCONF server, implementing the
29 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
31 // FIXME: configuration datastore should maintain ETag and Last-Modified headers, so that these can be returned when
32 // GET/PATCH/POST/PUT modify the data.
33 // FIXME: NETCONF-773: as a first step in doing that we should carry those fields in our responses
35 public interface RestconfServer {
37 * Delete a data resource.
39 * @param identifier resource identifier
40 * @return A {@link RestconfFuture} of the operation
42 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
43 RestconfFuture<Empty> dataDELETE(ApiPath identifier);
46 * Return the content of the datastore.
48 * @param readParams {@link ReadDataParams} for this request
49 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
51 RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
54 * Return the content of a data resource.
56 * @param identifier resource identifier
57 * @param readParams {@link ReadDataParams} for this request
58 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
60 RestconfFuture<NormalizedNodePayload> dataGET(ApiPath identifier, ReadDataParams readParams);
63 * Partially modify the target data resource, as defined in
64 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
66 * @param body data node for put to config DS
67 * @return A {@link RestconfFuture} of the operation
69 RestconfFuture<Empty> dataPATCH(ResourceBody body);
72 * Partially modify the target data resource, as defined in
73 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
75 * @param identifier resource identifier
76 * @param body data node for put to config DS
77 * @return A {@link RestconfFuture} of the operation
79 RestconfFuture<Empty> dataPATCH(ApiPath identifier, ResourceBody 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 body YANG Patch body
86 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
88 RestconfFuture<PatchStatusContext> dataPATCH(PatchBody body);
91 * Ordered list of edits that are applied to the datastore by the server, as defined in
92 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
94 * @param identifier path to target
95 * @param body YANG Patch body
96 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
98 RestconfFuture<PatchStatusContext> dataPATCH(ApiPath identifier, PatchBody body);
100 RestconfFuture<CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
102 RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
103 Map<String, String> queryParameters);
106 * Replace the data store.
108 * @param body data node for put to config DS
109 * @param queryParameters Query parameters
110 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
112 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
115 * Create or replace a data store resource.
117 * @param identifier resource identifier
118 * @param body data node for put to config DS
119 * @param queryParameters Query parameters
120 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
122 RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
125 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
126 * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
127 * {@code container operations} statement.
129 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
131 RestconfFuture<OperationsGetResult> operationsGET();
134 * Return the details about a particular operation supported by
135 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
136 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
137 * {@code container operations} statement.
139 * @param operation An operation
140 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
142 RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
145 * Invoke an RPC operation, as defined in
146 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
148 * @param restconfURI Base URI of the request
149 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
150 * @param body RPC operation
151 * @return A {@link RestconfFuture} completing with {@link OperationOutput}
153 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
154 // and hence it is a path right now
155 // FIXME: use ApiPath instead of String
156 RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
159 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
160 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
162 * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
163 * {@code yang-library-version} leaf element.
165 // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
166 // construct for both cases -- in this case it carries a yang.common.Revision
167 RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
169 RestconfFuture<ModulesGetResult> modulesYangGET(String identifier);
171 RestconfFuture<ModulesGetResult> modulesYinGET(String identifier);