Create NetconfDataTreeService with base and additional operations for netconf
[netconf.git] / netconf / netconf-dom-api / src / main / java / org / opendaylight / netconf / dom / api / NetconfDataTreeService.java
1 /*
2  * Copyright (c) 2020 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.dom.api;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.List;
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.common.api.CommitInfo;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
17 import org.opendaylight.mdsal.dom.api.DOMService;
18 import org.opendaylight.netconf.api.ModifyAction;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21
22 /**
23  * Interface for base and additional operations for netconf (e.g. get, get-config, edit-config, (un)lock, commit etc).
24  * <edit-config> operation is extended according it's attributes (merge, replace, create, delete, remove).
25  * According to RFC-6241.
26  */
27 public interface NetconfDataTreeService extends DOMService {
28
29     /**
30      * The <lock> operation.
31      * Allows the client to lock the entire configuration datastore system of a device.
32      *
33      * @return result of <lock> operation
34      */
35     List<ListenableFuture<? extends DOMRpcResult>> lock();
36
37     /**
38      * The &lt;unlock&gt; operation.
39      * Used to release a configuration lock, previously obtained with the &lt;lock&gt; operation.
40      */
41     void unlock();
42
43     /**
44      * The &lt;discard-changes&gt; operation.
45      * If device supports :candidate capability, discards any uncommitted changes by resetting
46      * the candidate configuration with the content of the running configuration.
47      */
48     void discardChanges();
49
50     /**
51      * The &lt;get&gt; operation.
52      * Retrieve running configuration and device state information.
53      *
54      * @return result of &lt;get&gt; operation
55      */
56     ListenableFuture<Optional<NormalizedNode<?, ?>>> get(YangInstanceIdentifier path);
57
58     /**
59      * The &lt;get-config&gt; operation.
60      * Retrieve all or part of a specified configuration datastore.
61      *
62      * @return result of &lt;get-config&gt; operation
63      */
64     ListenableFuture<Optional<NormalizedNode<?, ?>>> getConfig(YangInstanceIdentifier path);
65
66     /**
67      * The &lt;edit-config&gt; operation with "merge" attribute.
68      * The configuration data identified by the element containing this attribute is merged with the configuration
69      * at the corresponding level in the configuration datastore.
70      *
71      * @return result of &lt;edit-config&gt; operation
72      */
73     ListenableFuture<? extends DOMRpcResult> merge(LogicalDatastoreType store, YangInstanceIdentifier path,
74                                                    NormalizedNode<?, ?> data,
75                                                    Optional<ModifyAction> defaultOperation);
76
77     /**
78      * The &lt;edit-config&gt; operation with "replace" attribute.
79      * The configuration data identified by the element containing this attribute replaces any related configuration
80      * in the configuration datastore.
81      *
82      * @return result of &lt;edit-config&gt; operation
83      */
84     ListenableFuture<? extends DOMRpcResult> replace(LogicalDatastoreType store, YangInstanceIdentifier path,
85                                                      NormalizedNode<?, ?> data,
86                                                      Optional<ModifyAction> defaultOperation);
87
88     /**
89      * The &lt;edit-config&gt; operation with "create" attribute.
90      * The configuration data identified by the element containing this attribute is added to the configuration if
91      * and only if the configuration data does not already exist in the configuration datastore.
92      *
93      * @return result of &lt;edit-config&gt; operation
94      */
95     ListenableFuture<? extends DOMRpcResult> create(LogicalDatastoreType store, YangInstanceIdentifier path,
96                                                     NormalizedNode<?, ?> data,
97                                                     Optional<ModifyAction> defaultOperation);
98
99     /**
100      * The &lt;edit-config&gt; operation with "create" attribute.
101      * The configuration data identified by the element containing this attribute is deleted from the configuration
102      * if and only if the configuration data currently exists in the configuration datastore.
103      *
104      * @return result of &lt;edit-config&gt; operation
105      */
106     ListenableFuture<? extends DOMRpcResult> delete(LogicalDatastoreType store, YangInstanceIdentifier path);
107
108     /**
109      * The &lt;edit-config&gt; operation with "create" attribute.
110      * The configuration data identified by the element containing this attribute is deleted from the configuration
111      * if the configuration data currently exists in the configuration datastore.
112      *
113      * @return result of &lt;edit-config&gt; operation
114      */
115     ListenableFuture<? extends DOMRpcResult> remove(LogicalDatastoreType store, YangInstanceIdentifier path);
116
117     /**
118      * The &lt;commit&gt; operation.
119      * If device supports :candidate capability, commit the candidate configuration as the device's
120      * new current configuration.
121      *
122      * @return result of &lt;commit&gt; operation
123      */
124     ListenableFuture<? extends CommitInfo> commit(List<ListenableFuture<? extends DOMRpcResult>> resultsFutures);
125
126     /**
127      * Return device identifier.
128      *
129      * @return Device's identifier, must not be null.
130      */
131     @NonNull Object getDeviceId();
132 }