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.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.restconf.server.spi.OperationOutput;
23 import org.opendaylight.yangtools.yang.common.Empty;
26 * An implementation of a RESTCONF server, implementing the
27 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
30 public interface RestconfServer {
32 * Delete a data resource.
34 * @param identifier resource identifier
35 * @return A {@link RestconfFuture} of the operation
37 @SuppressWarnings("checkstyle:abbreviationAsWordInName")
38 RestconfFuture<Empty> dataDELETE(String identifier);
41 * Return the content of the datastore.
43 * @param readParams {@link ReadDataParams} for this request
44 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
46 RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
49 * Return the content of a data resource.
51 * @param identifier resource identifier
52 * @param readParams {@link ReadDataParams} for this request
53 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
55 RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
58 * Partially modify the target data resource, as defined in
59 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
61 * @param body data node for put to config DS
62 * @return A {@link RestconfFuture} of the operation
64 RestconfFuture<Empty> dataPATCH(ResourceBody body);
67 * Partially modify the target data resource, as defined in
68 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
70 * @param identifier resource identifier
71 * @param body data node for put to config DS
72 * @return A {@link RestconfFuture} of the operation
74 RestconfFuture<Empty> dataPATCH(String identifier, ResourceBody body);
77 * Ordered list of edits that are applied to the datastore by the server, as defined in
78 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
80 * @param body YANG Patch body
81 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
83 RestconfFuture<PatchStatusContext> dataPATCH(PatchBody body);
86 * Ordered list of edits that are applied to the datastore by the server, as defined in
87 * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
89 * @param identifier path to target
90 * @param body YANG Patch body
91 * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
93 RestconfFuture<PatchStatusContext> dataPATCH(String identifier, PatchBody body);
96 * Replace the data store.
98 * @param body data node for put to config DS
99 * @param queryParameters Query parameters
100 * @return A {@link RestconfFuture} completing with {@link DataPutResult}
102 RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
105 * Create or replace a data store resource.
107 * @param identifier resource identifier
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(String identifier, ResourceBody body, Map<String, String> queryParameters);
115 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
117 * @return An {@link OperationsGetResult}
119 OperationsGetResult operationsGET();
122 * Return the details about a particular operation supported by
123 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
124 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84>RFC8040<a> {@code container operations} statement.
126 * @param operation An operation
127 * @return An {@link OperationsContent}, or {@code null} if {@code operation} does not point to an {@code rpc}
129 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
130 // and hence it is a path right now
131 // FIXME: use ApiPath instead of String
132 @Nullable OperationsGetResult operationsGET(String operation);
135 * Invoke an RPC operation, as defined in
136 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
138 * @param restconfURI Base URI of the request
139 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
140 * @param body RPC operation
141 * @return A {@link RestconfFuture} of the {@link OperationOutput operation result}
143 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
144 // and hence it is a path right now
145 // FIXME: use ApiPath instead of String
146 RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
149 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
150 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
152 * @return A {@code yang-library-version} element
154 // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
155 // construct for both cases
156 // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
157 NormalizedNodePayload yangLibraryVersionGET();