aac6813f7b4316e7fab81945e263246ffe80816b
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
19
20 import com.google.common.util.concurrent.ListenableFuture;
21 import java.time.Instant;
22 import java.util.Collection;
23 import java.util.Map;
24 import java.util.Optional;
25 import org.eclipse.jdt.annotation.NonNull;
26 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
27 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
28 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
29 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
30 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
31 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.create.subscription.input.Filter;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey;
36 import org.opendaylight.yangtools.concepts.ListenerRegistration;
37 import org.opendaylight.yangtools.yang.binding.DataObject;
38 import org.opendaylight.yangtools.yang.common.QName;
39 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
40 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
41 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
42
43 /**
44  * Interface handling netconf connection.
45  */
46 public interface NetconfDomAccessor extends NetconfAccessor {
47
48     /**
49      * @return the dataBroker
50      */
51     DOMDataBroker getDataBroker();
52
53     /**
54      * @return the MDSAL Mountpoint service
55      **/
56     DOMMountPoint getMountpoint();
57
58     /**
59      * Deliver the data into a class
60      *
61      * @param <T> DataObject type
62      * @param dataStoreType config or operational database
63      * @param path data path
64      * @return Optional<T> with object
65      */
66     <T extends DataObject> Optional<T> readData(LogicalDatastoreType dataStoreType, YangInstanceIdentifier path,
67             Class<T> clazz);
68
69     /**
70      * Read data from device
71      *
72      * @param dataStoreType
73      * @param path
74      * @return NormalizedNode<?, ?> with data
75      */
76     Optional<NormalizedNode<?, ?>> readDataNode(LogicalDatastoreType dataStoreType, YangInstanceIdentifier path);
77
78     /**
79      * Register netconf notification listener for related mountpoint
80      *
81      * @param <T> specific child class of DOMNotificationListener
82      * @param listener listener to be called
83      * @param types as list of Absolute
84      * @return handler to manager registration
85      */
86     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
87             @NonNull T listener, Collection<Absolute> types);
88
89     /**
90      * Register netconf notification listener for related mountpoint
91      *
92      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
93      * @param <T>
94      * @param listener to be registers
95      * @param types as array of Absolute
96      * @return Object to close and access
97      */
98     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
99             @NonNull T listener, Absolute[] types);
100
101     /**
102      * Register netconf notification listener for related mountpoint
103      *
104      * @param <T>
105      * @param listener to be registers
106      * @param types as array of QName
107      * @return Object to close and access
108      */
109     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
110             @NonNull T listener, QName[] types);
111
112     /**
113      * Request notification streams from device.
114      *
115      * @return provided streams.
116      */
117     @NonNull
118     Map<StreamKey, Stream> getNotificationStreamsAsMap();
119
120     /**
121      * Send out a NETCONF create-subscription for one notification stream.
122      *
123      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
124      * @param input with CreateSubscriptionInput
125      * @return RpcMessage for the RPC call.
126      */
127     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(CreateSubscriptionInput input);
128
129     /**
130      * Send out a NETCONF create-subscription for one notification stream, using parameters.
131      *
132      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
133      * @param oStream Optional Stream
134      * @param filter Optional Filter
135      * @param startTime startTime according the RFC
136      * @param stopTime stopTime according the RFC
137      * @return
138      */
139     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(Optional<Stream> oStream, Optional<Filter> filter,
140             Optional<Instant> startTime, Optional<Instant> stopTime);
141
142     /**
143      * Send out a NETCONF create-subscription for a list of streams, not offering replay options.
144      *
145      * @param streams is a list of stream with 0..n elements.
146      * @return if ok last rpc call result, if notok the result provided by rpc call providing error response.
147      */
148     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(Stream... streams);
149
150     /**
151      * Get NETCONF object to serialize between GenericNodes and Java classes
152      *
153      * @return serialization object.
154      */
155     BindingNormalizedNodeSerializer getBindingNormalizedNodeSerializer();
156 }