Codify operationsGET
[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.opendaylight.restconf.api.ApiPath;
13 import org.opendaylight.restconf.common.errors.RestconfFuture;
14 import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
15 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
16 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.OperationsContent;
17 import org.opendaylight.restconf.server.spi.OperationOutput;
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      * Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
27      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.3.3">RFC8040 {+restconf}/yang-library-version</a>.
28      *
29      * @return A {@code yang-library-version} element
30      */
31     // FIXME: this is a simple coning-variadic return, similar to how OperationsContent is handled use a common
32     //        construct for both cases
33     // FIXME: RestconfFuture if we transition to being used by restconf-client implementation
34     NormalizedNodePayload yangLibraryVersionGET();
35
36     /**
37      * Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
38      *
39      * @param contentType Formatting type
40      * @return A formatted string
41      */
42     String operationsGET(OperationsContent contentType);
43
44     /*
45      * Return the details about a particular operation supported by
46      * {@link #operationsPOST(URI, String, OperationInputBody)}, as expressed in the
47      * <a href="https://www.rfc-editor.org/rfc/rfc8040#page-84>RFC8040<a> {@code container operations} statement.
48      *
49      * @param contentType Formatting type
50      * @param operation An operation
51      * @return A formatted string
52      */
53     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
54     //        and hence it is a path right now
55     // FIXME: use ApiPath instead of String
56     String operationsGET(OperationsContent contentType, String operation);
57
58     /**
59      * Invoke an RPC operation, as defined in
60      * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
61      *
62      * @param restconfURI Base URI of the request
63      * @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
64      * @param body RPC operation
65      * @return A {@link RestconfFuture} of the {@link OperationOutput operation result}
66      */
67     // FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
68     //        and hence it is a path right now
69     // FIXME: use ApiPath instead of String
70     RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, String operation, OperationInputBody body);
71 }