Add subscribeToStream to JSONRestConfService
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / restconf / api / JSONRestconfService.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. 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.sal.restconf.api;
9
10 import com.google.common.base.Optional;
11 import javax.annotation.Nonnull;
12 import javax.ws.rs.core.MultivaluedMap;
13
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.yangtools.yang.common.OperationFailedException;
16
17
18 /**
19  * Provides restconf CRUD operations via code with input/output data in JSON format.
20  *
21  * @author Thomas Pantelis.
22  */
23 public interface JSONRestconfService {
24     /**
25      * The data tree root path.
26      */
27     String ROOT_PATH = null;
28
29     /**
30      * Issues a restconf PUT request to the configuration data store.
31      *
32      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
33      *       To specify the root, use {@link ROOT_PATH}.
34      * @param payload the payload data in JSON format.
35      * @throws OperationFailedException if the request fails.
36      */
37     void put(String uriPath, @Nonnull String payload) throws OperationFailedException;
38
39     /**
40      * Issues a restconf POST request to the configuration data store.
41      *
42      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
43      *       To specify the root, use {@link ROOT_PATH}.
44      * @param payload the payload data in JSON format.
45      * @throws OperationFailedException if the request fails.
46      */
47     void post(String uriPath, @Nonnull String payload) throws OperationFailedException;
48
49     /**
50      * Issues a restconf DELETE request to the configuration data store.
51      *
52      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
53      *       To specify the root, use {@link ROOT_PATH}.
54      * @throws OperationFailedException if the request fails.
55      */
56     void delete(String uriPath) throws OperationFailedException;
57
58     /**
59      * Issues a restconf GET request to the given data store.
60      *
61      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
62      *       To specify the root, use {@link ROOT_PATH}.
63      * @param datastoreType the data store type to read from.
64      * @return an Optional containing the data in JSON format if present.
65      * @throws OperationFailedException if the request fails.
66      */
67     Optional<String> get(String uriPath, LogicalDatastoreType datastoreType)
68             throws OperationFailedException;
69
70     /**
71      * Invokes a yang-defined RPC.
72      *
73      * @param uriPath the path representing the RPC to invoke, eg "toaster:make-toast".
74      * @param input the input in JSON format if the RPC takes input.
75      * @return an Optional containing the output in JSON format if the RPC returns output.
76      * @throws OperationFailedException if the request fails.
77      */
78     Optional<String> invokeRpc(@Nonnull String uriPath, Optional<String> input) throws OperationFailedException;
79
80     /**
81      * Issues a restconf PATCH request to the configuration data store.
82      *
83      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
84      *       To specify the root, use {@link ROOT_PATH}.
85      * @param payload the payload data in JSON format.
86      * @return an Optional containing the patch response data in JSON format.
87      * @throws OperationFailedException if the request fails.
88      */
89     Optional<String> patch(@Nonnull String uriPath, @Nonnull String payload) throws OperationFailedException;
90
91     /**
92      * Subscribe to a stream.
93      * @param identifier the identifier of the stream, e.g., "data-change-event-subscription/neutron:neutron/...
94      *                   ...neutron:ports/datastore=OPERATIONAL/scope=SUBTREE".
95      * @param params HTTP query parameters or null.
96      * @return On optional containing the JSON response.
97      * @throws OperationFailedException if the requests fails.
98      */
99     Optional<String> subscribeToStream(@Nonnull String identifier, MultivaluedMap<String, String> params)
100                                                                                     throws OperationFailedException;
101 }