Eliminate DataPutPath
[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.nb.rfc8040.legacy.NormalizedNodePayload;
17 import org.opendaylight.yangtools.yang.common.Empty;
18
19 /**
20  * An implementation of a RESTCONF server, implementing the
21  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
22  */
23 @NonNullByDefault
24 public interface RestconfServer {
25     /**
26      * Delete a data resource.
27      *
28      * @param identifier resource identifier
29      * @return A {@link RestconfFuture} of the operation
30      */
31     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
32     RestconfFuture<Empty> dataDELETE(ApiPath identifier);
33
34     /**
35      * Return the content of the datastore.
36      *
37      * @param params {@link DataGetParams} for this request
38      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
39      */
40     RestconfFuture<DataGetResult> dataGET(DataGetParams params);
41
42     /**
43      * Return the content of a data resource.
44      *
45      * @param identifier resource identifier
46      * @param params {@link DataGetParams} for this request
47      * @return A {@link RestconfFuture} of the {@link DataGetResult} content
48      */
49     RestconfFuture<DataGetResult> dataGET(ApiPath identifier, DataGetParams params);
50
51     /**
52      * Partially modify the target data resource, as defined in
53      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
54      *
55      * @param body data node for put to config DS
56      * @return A {@link RestconfFuture} of the operation
57      */
58     RestconfFuture<DataPatchResult> dataPATCH(ResourceBody body);
59
60     /**
61      * Partially modify the target data resource, as defined in
62      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
63      *
64      * @param identifier resource identifier
65      * @param body data node for put to config DS
66      * @return A {@link RestconfFuture} of the operation
67      */
68     RestconfFuture<DataPatchResult> dataPATCH(ApiPath identifier, ResourceBody body);
69
70     /**
71      * Ordered list of edits that are applied to the datastore by the server, as defined in
72      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
73      *
74      * @param body YANG Patch body
75      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
76      */
77     RestconfFuture<DataYangPatchResult> dataPATCH(PatchBody body);
78
79     /**
80      * Ordered list of edits that are applied to the datastore by the server, as defined in
81      * <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
82      *
83      * @param identifier path to target
84      * @param body YANG Patch body
85      * @return A {@link RestconfFuture} of the {@link DataYangPatchResult} content
86      */
87     RestconfFuture<DataYangPatchResult> dataPATCH(ApiPath identifier, PatchBody body);
88
89     RestconfFuture<DataPostResult.CreateResource> dataPOST(ChildBody body, Map<String, String> queryParameters);
90
91     RestconfFuture<? extends DataPostResult> dataPOST(ApiPath identifier, DataPostBody body,
92         Map<String, String> queryParameters);
93
94     /**
95      * Replace the data store, as described in
96      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
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, as described in
106      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.5">RFC8040 section 4.5</a>.
107      *
108      * @param identifier resource identifier
109      * @param body data node for put to config DS
110      * @param queryParameters Query parameters
111      * @return A {@link RestconfFuture} completing with {@link DataPutResult}
112      */
113     RestconfFuture<DataPutResult> dataPUT(ApiPath identifier, ResourceBody body, Map<String, String> queryParameters);
114
115     /**
116      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, ApiPath, OperationInputBody)},
117      * as expressed in the <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconf.yang</a>
118      * {@code container operations} statement.
119      *
120      * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
121      */
122     RestconfFuture<OperationsGetResult> operationsGET();
123
124     /*
125      * Return the details about a particular operation supported by
126      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
127      * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84">ietf-restconfig.yang</a>
128      * {@code container operations} statement.
129      *
130      * @param operation An operation
131      * @return A {@link RestconfFuture} completing with an {@link OperationsGetResult}
132      */
133     RestconfFuture<OperationsGetResult> operationsGET(ApiPath operation);
134
135     /**
136      * Invoke an RPC operation, as defined in
137      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
138      *
139      * @param restconfURI Base URI of the request
140      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
141      * @param body RPC operation
142      * @return A {@link RestconfFuture} completing with {@link OperationsPostResult}
143      */
144     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support yang-ext:mount,
145     //        and hence it is a path right now
146     RestconfFuture<OperationsPostResult> operationsPOST(URI restconfURI, ApiPath 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 {@link RestconfFuture} completing with {@link NormalizedNodePayload} containing a single
153      *        {@code yang-library-version} leaf element.
154      */
155     // FIXME: this is a simple encoding-variadic return, similar to how OperationsContent is handled use a common
156     //        construct for both cases -- in this case it carries a yang.common.Revision
157     RestconfFuture<NormalizedNodePayload> yangLibraryVersionGET();
158
159     RestconfFuture<ModulesGetResult> modulesYangGET(String fileName, @Nullable String revision);
160
161     RestconfFuture<ModulesGetResult> modulesYangGET(ApiPath mountPath, String fileName, @Nullable String revision);
162
163     RestconfFuture<ModulesGetResult> modulesYinGET(String fileName, @Nullable String revision);
164
165     RestconfFuture<ModulesGetResult> modulesYinGET(ApiPath mountPath, String fileName, @Nullable String revision);
166 }