Deprecate JSONRestconfService
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / 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.restconf.nb.rfc8040.rests.services.api;
9
10 import java.util.Optional;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.yangtools.yang.common.OperationFailedException;
14
15 /**
16  * Provides restconf CRUD operations via code with input/output data in JSON format.
17  *
18  * @deprecated This interface is type-unsafe and does not document encoding sufficiently. Use proper MD-SAL interfaces
19  *             instead.
20  * @author Thomas Pantelis.
21  */
22 @Deprecated(since = "1.13.2", forRemoval = true)
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 }