Un-deprecate JSONRestconfService(Impl)
[netconf.git] / restconf / sal-rest-connector / 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.UriInfo;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yangtools.yang.common.OperationFailedException;
15
16 /**
17  * Provides restconf CRUD operations via code with input/output data in JSON format.
18  *
19  * @author Thomas Pantelis.
20  */
21 public interface JSONRestconfService {
22     /**
23      * The data tree root path.
24      */
25     String ROOT_PATH = null;
26
27     /**
28      * Issues a restconf PUT request to the configuration data store.
29      *
30      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
31      *       To specify the root, use {@link ROOT_PATH}.
32      * @param payload the payload data in JSON format.
33      * @throws OperationFailedException if the request fails.
34      */
35     void put(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
36
37     /**
38      * Issues a restconf POST request to the configuration data store.
39      *
40      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
41      *       To specify the root, use {@link ROOT_PATH}.
42      * @param payload the payload data in JSON format.
43      * @throws OperationFailedException if the request fails.
44      */
45     void post(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
46
47     /**
48      * Issues a restconf DELETE request to the configuration data store.
49      *
50      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
51      *       To specify the root, use {@link ROOT_PATH}.
52      * @throws OperationFailedException if the request fails.
53      */
54     void delete(String uriPath) throws OperationFailedException;
55
56     /**
57      * Issues a restconf GET request to the given data store.
58      *
59      * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
60      *       To specify the root, use {@link ROOT_PATH}.
61      * @param datastoreType the data store type to read from.
62      * @return an Optional containing the data in JSON format if present.
63      * @throws OperationFailedException if the request fails.
64      */
65     Optional<String> get(String uriPath, LogicalDatastoreType datastoreType, UriInfo uriInfo)
66             throws OperationFailedException;
67
68     /**
69      * Invokes a yang-defined RPC.
70      *
71      * @param uriPath the path representing the RPC to invoke, eg "toaster:make-toast".
72      * @param input the input in JSON format if the RPC takes input.
73      * @return an Optional containing the output in JSON format if the RPC returns output.
74      * @throws OperationFailedException if the request fails.
75      */
76     Optional<String> invokeRpc(@Nonnull String uriPath, Optional<String> input) throws OperationFailedException;
77 }