Rename OperationsContent
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / RestconfServer.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.server.api;
9
10 import java.net.URI;
11 import java.util.Map;
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;
24
25 /**
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>.
28  */
29 @NonNullByDefault
30 public interface RestconfServer {
31     /**
32      * Delete a data resource.
33      *
34      * @param identifier resource identifier
35      * @return A {@link RestconfFuture} of the operation
36      */
37     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
38     RestconfFuture<Empty> dataDELETE(String identifier);
39
40     /**
41      * Return the content of the datastore.
42      *
43      * @param readParams {@link ReadDataParams} for this request
44      * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
45      */
46     RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
47
48     /**
49      * Return the content of a data resource.
50      *
51      * @param identifier resource identifier
52      * @param readParams {@link ReadDataParams} for this request
53      * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
54      */
55     RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
56
57     /**
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>.
60      *
61      * @param body data node for put to config DS
62      * @return A {@link RestconfFuture} of the operation
63      */
64     RestconfFuture<Empty> dataPATCH(ResourceBody body);
65
66     /**
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>.
69      *
70      * @param identifier resource identifier
71      * @param body data node for put to config DS
72      * @return A {@link RestconfFuture} of the operation
73      */
74     RestconfFuture<Empty> dataPATCH(String identifier, ResourceBody body);
75
76     /**
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>.
79      *
80      * @param body YANG Patch body
81      * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
82      */
83     RestconfFuture<PatchStatusContext> dataPATCH(PatchBody body);
84
85     /**
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>.
88      *
89      * @param identifier path to target
90      * @param body YANG Patch body
91      * @return A {@link RestconfFuture} of the {@link PatchStatusContext} content
92      */
93     RestconfFuture<PatchStatusContext> dataPATCH(String identifier, PatchBody body);
94
95     /**
96      * Replace the data store.
97      *
98      * @param body data node for put to config DS
99      * @param queryParameters Query parameters
100      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
101      */
102     RestconfFuture<DataPutResult> dataPUT(ResourceBody body, Map<String, String> queryParameters);
103
104     /**
105      * Create or replace a data store resource.
106      *
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}
111      */
112     RestconfFuture<DataPutResult> dataPUT(String identifier, ResourceBody body, Map<String, String> queryParameters);
113
114     /**
115      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
116      *
117      * @return An {@link OperationsGetResult}
118      */
119     OperationsGetResult operationsGET();
120
121     /*
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.
125      *
126      * @param operation An operation
127      * @return An {@link OperationsContent}, or {@code null} if {@code operation} does not point to an {@code rpc}
128      */
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);
133
134     /**
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>.
137      *
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}
142      */
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);
147
148     /**
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>.
151      *
152      * @return A {@code yang-library-version} element
153      */
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();
158 }