Add RestconfServer.dataPATCH()
[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 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.nb.rfc8040.ReadDataParams;
16 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
17 import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
18 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
19 import org.opendaylight.restconf.server.spi.OperationOutput;
20 import org.opendaylight.yangtools.yang.common.Empty;
21
22 /**
23  * An implementation of a RESTCONF server, implementing the
24  * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3">RESTCONF API Resource</a>.
25  */
26 @NonNullByDefault
27 public interface RestconfServer {
28     /**
29      * Delete a data resource.
30      *
31      * @param identifier resource identifier
32      * @return A {@link RestconfFuture} of the operation
33      */
34     @SuppressWarnings("checkstyle:abbreviationAsWordInName")
35     RestconfFuture<Empty> dataDELETE(String identifier);
36
37     /**
38      * Return the content of the datastore.
39      *
40      * @param readParams {@link ReadDataParams} for this request
41      * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
42      */
43     RestconfFuture<NormalizedNodePayload> dataGET(ReadDataParams readParams);
44
45     /**
46      * Return the content of a data resource.
47      *
48      * @param identifier resource identifier
49      * @param readParams {@link ReadDataParams} for this request
50      * @return A {@link RestconfFuture} of the {@link NormalizedNodePayload} content
51      */
52     RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
53
54     /**
55      * Partially modify the target data resource, as defined in
56      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
57      *
58      * @param body data node for put to config DS
59      * @return A {@link RestconfFuture} of the operation
60      */
61     RestconfFuture<Empty> dataPATCH(ResourceBody body);
62
63     /**
64      * Partially modify the target data resource, as defined in
65      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
66      *
67      * @param identifier resource identifier
68      * @param body data node for put to config DS
69      * @return A {@link RestconfFuture} of the operation
70      */
71     RestconfFuture<Empty> dataPATCH(String identifier, ResourceBody body);
72
73     /**
74      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
75      *
76      * @return An {@link OperationsContent}
77      */
78     OperationsContent operationsGET();
79
80     /*
81      * Return the details about a particular operation supported by
82      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
83      * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84>RFC8040<a> {@code container operations} statement.
84      *
85      * @param operation An operation
86      * @return An {@link OperationsContent}, or {@code null} if {@code operation} does not point to an {@code rpc}
87      */
88     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
89     //        and hence it is a path right now
90     // FIXME: use ApiPath instead of String
91     @Nullable OperationsContent operationsGET(String operation);
92
93     /**
94      * Invoke an RPC operation, as defined in
95      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
96      *
97      * @param restconfURI Base URI of the request
98      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
99      * @param body RPC operation
100      * @return A {@link RestconfFuture} of the {@link OperationOutput operation result}
101      */
102     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
103     //        and hence it is a path right now
104     // FIXME: use ApiPath instead of String
105     RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
106
107     /**
108      * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
109      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
110      *
111      * @return A {@code yang-library-version} element
112      */
113     // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
114     //        construct for both cases
115     // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
116     NormalizedNodePayload yangLibraryVersionGET();
117 }