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;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
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.OperationInputBody;
18 import org.opendaylight.restconf.nb.rfc8040.databind.PatchBody;
19 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
20 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
21 import org.opendaylight.restconf.server.spi.OperationOutput;
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(String identifier);
40 * Return the content of the datastore.
42 * @param readParams {@link ReadDataParams} for this request
43 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
45 RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
48 * Return the content of a data resource.
50 * @param identifier resource identifier
51 * @param readParams {@link ReadDataParams} for this request
52 * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
54 RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
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<Empty> 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<Empty> dataPATCH(String 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 PatchStatusContext} content
82 RestconfFuture<PatchStatusContext> 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 PatchStatusContext} content
92 RestconfFuture<PatchStatusContext> dataPATCH(String identifier, PatchBody body);
95 * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
97 * @return An {@link OperationsContent}
99 OperationsContent operationsGET();
102 * Return the details about a particular operation supported by
103 * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
104 * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84>RFC8040<a> {@code container operations} statement.
106 * @param operation An operation
107 * @return An {@link OperationsContent}, or {@code null} if {@code operation} does not point to an {@code rpc}
109 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
110 // and hence it is a path right now
111 // FIXME: use ApiPath instead of String
112 @Nullable OperationsContent operationsGET(String operation);
115 * Invoke an RPC operation, as defined in
116 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
118 * @param restconfURI Base URI of the request
119 * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
120 * @param body RPC operation
121 * @return A {@link RestconfFuture} of the {@link OperationOutput operation result}
123 // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
124 // and hence it is a path right now
125 // FIXME: use ApiPath instead of String
126 RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
129 * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
130 * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
132 * @return A {@code yang-library-version} element
134 // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
135 // construct for both cases
136 // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
137 NormalizedNodePayload yangLibraryVersionGET();