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>.
32 public interface RestconfServer {
34 * Delete a data resource.
36 * @param identifier resource identifier
37 * @return A {@link RestconfFuture} of the operation
39 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
40 RestconfFuture<Empty> dataDELETE(ApiPath identifier);
43 * Return the content of the datastore.
45 * @param readParams {@link ReadDataParams} for this request
46 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
48 RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
51 * Return the content of a data resource.
53 * @param identifier resource identifier
54 * @param readParams {@link ReadDataParams} for this request
55 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
57 RestconfFuture<NormalizedNodePayload> dataGET(ApiPath identifier, ReadDataParams readParams);
60 * Partially modify the target data resource, as defined in
61 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
63 * @param body data node for put to config DS
64 * @return A {@link RestconfFuture} of the operation
66 RestconfFuture<Empty> dataPATCH(ResourceBody body);
69 * Partially modify the target data resource, as defined in
70 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
72 * @param identifier resource identifier
73 * @param body data node for put to config DS
74 * @return A {@link RestconfFuture} of the operation
76 RestconfFuture<Empty> dataPATCH(ApiPath identifier, ResourceBody body);
79 * Ordered list of edits that are applied to the datastore by the server, as defined in
80 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
82 * @param body YANG Patch body
83 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
85 RestconfFuture<PatchStatusContext> dataPATCH(PatchBody body);
88 * Ordered list of edits that are applied to the datastore by the server, as defined in
89 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
91 * @param identifier path to target
92 * @param body YANG Patch body
93 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
95 RestconfFuture<PatchStatusContext> dataPATCH(ApiPath identifier, PatchBody body);
97 RestconfFuture<CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
99 RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
100 Map<String, String> queryParameters);
103 * Replace the data store.
105 * @param body data node for put to config DS
106 * @param queryParameters Query parameters
107 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
109 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
112 * Create or replace a data store resource.
114 * @param identifier resource identifier
115 * @param body data node for put to config DS
116 * @param queryParameters Query parameters
117 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
119 RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
122 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
123 * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
124 * {@code container operations} statement.
126 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
128 RestconfFuture<OperationsGetResult> operationsGET();
131 * Return the details about a particular operation supported by
132 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
133 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
134 * {@code container operations} statement.
136 * @param operation An operation
137 * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
139 RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
142 * Invoke an RPC operation, as defined in
143 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
145 * @param restconfURI Base URI of the request
146 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
147 * @param body RPC operation
148 * @return A {@link RestconfFuture} completing with {@link OperationOutput}
150 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
151 // and hence it is a path right now
152 // FIXME: use ApiPath instead of String
153 RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
156 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
157 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
159 * @return A {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
160 * {@code yang-library-version} leaf element.
162 // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
163 // construct for both cases -- in this case it carries a yang.common.Revision
164 RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();