Bump upstreams
[netconf.git] / plugins / netconf-client-mdsal / src / main / java / org / opendaylight / netconf / client / mdsal / api / NetconfRpcService.java
1 /*
2  * Copyright (c) 2022 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.netconf.client.mdsal.api;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.dom.api.DOMRpcException;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
14 import org.opendaylight.mdsal.dom.api.DOMService;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CancelCommit;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CloseSession;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Commit;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.CopyConfig;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.DeleteConfig;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.DiscardChanges;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditConfig;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Get;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.GetConfig;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.KillSession;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Lock;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Unlock;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.Validate;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscription;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.GetSchema;
30 import org.opendaylight.yangtools.yang.common.QName;
31 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
32
33 /**
34  * A {@link DOMService} capturing the ability to invoke NETCONF RPCs through
35  * {@link #invokeNetconf(QName, ContainerNode)}.
36  */
37 public interface NetconfRpcService extends DOMService<NetconfRpcService, NetconfRpcService.Extension> {
38     /**
39      * Invoke a well-known RPC. This method is guaranteed to support the following RPCs:
40      * <ul>
41      *   <li>{@link CloseSession}</li>
42      *   <li>{@link CopyConfig}</li>
43      *   <li>{@link DeleteConfig}</li>
44      *   <li>{@link EditConfig}</li>
45      *   <li>{@link Get}</li>
46      *   <li>{@link GetConfig}</li>
47      *   <li>{@link KillSession}</li>
48      *   <li>{@link Lock}</li>
49      *   <li>{@link Unlock}</li>
50      * </ul>
51      *
52      * <p>
53      * The support for other RPCs is advertized through {@link #supportedExtensions()}.
54      *
55      * @param type QName of the RPC to be invoked
56      * @param input Input arguments, null if the RPC does not take any.
57      * @return A {@link ListenableFuture} which will return either a result structure, or report a subclass
58      *         of {@link DOMRpcException} reporting a transport error.
59      */
60     @NonNull ListenableFuture<? extends DOMRpcResult> invokeNetconf(@NonNull QName type, @NonNull ContainerNode input);
61
62     /**
63      * Extensions to {@link NetconfRpcService} defining additional RPC availability.
64      */
65     // Note: This is not an interface on purpose, to make the set of extensions well-known
66     enum Extension implements DOMService.Extension<NetconfRpcService, Extension> {
67         /**
68          * This device supports
69          * <a href="https://www.rfc-editor.org/rfc/rfc4741#section-8.3">Candidate Configuration Capability</a>.
70          * The following RPCs are supported:
71          * <ul>
72          *   <li>{@link Commit}</li>
73          *   <li>{@link DiscardChanges}</li>
74          * </ul>
75          */
76         CANDIDATE,
77         /**
78          * This device supports
79          * <a href="https://www.rfc-editor.org/rfc/rfc4741#section-8.4">Confirmed Commit Capability 1.0</a>.
80          * The following RPCs are supported:
81          * <ul>
82          *   <li>{@link Commit}</li>
83          *   <li>{@link DiscardChanges}</li>
84          * </ul>
85          */
86         CONFIRMED_COMMIT_1_0,
87         /**
88          * This device supports
89          * <a href="https://www.rfc-editor.org/rfc/rfc6241#section-8.4">Confirmed Commit Capability 1.1</a>.
90          * The following RPCs are supported:
91          * <ul>
92          *   <li>{@link CancelCommit}</li>
93          *   <li>{@link Commit}</li>
94          *   <li>{@link DiscardChanges}</li>
95          * </ul>
96          */
97         CONFIRMED_COMMIT_1_1,
98         /**
99          * This device supports <a href="https://www.rfc-editor.org/rfc/rfc6022">NETCONF Monitoring</a>. The following
100          * RPCs are supported:
101          * <ul>
102          *   <li>{@link GetSchema}</li>
103          * </ul>
104          */
105         MONITORING,
106         /**
107          * This device supports <a href="https://www.rfc-editor.org/rfc/rfc5277">Event Notifications</a>. The following
108          * RPCs are supported:
109          * <ul>
110          *   <li>{@link CreateSubscription}</li>
111          * </ul>
112          * {@link CreateSubscription} is supported.
113          */
114         NOTIFICATIONS,
115         /**
116          * This device supports <a href="https://www.rfc-editor.org/rfc/rfc4741#section-8.6">Validate Capability</a>.
117          * The following RPCs are supported:
118          * <ul>
119          *   <li>{@link Validate}</li>
120          * </ul>
121          */
122         VALIDATE_1_0,
123         /**
124          * This device supports <a href="https://www.rfc-editor.org/rfc/rfc6241#section-8.6">Validate Capability</a>.
125          * The following RPCs are supported:
126          * <ul>
127          *   <li>{@link Validate}</li>
128          * </ul>
129          */
130         VALIDATE_1_1;
131     }
132 }