2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.api;
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;
16 * Provides restconf CRUD operations via code with input/output data in JSON format.
18 * @deprecated This interface is type-unsafe and does not document encoding sufficiently. Use proper MD-SAL interfaces
20 * @author Thomas Pantelis.
22 @Deprecated(since = "1.13.2", forRemoval = true)
23 public interface JSONRestconfService {
25 * The data tree root path.
27 String ROOT_PATH = null;
30 * Issues a restconf PUT request to the configuration data store.
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.
37 void put(String uriPath, @NonNull String payload) throws OperationFailedException;
40 * Issues a restconf POST request to the configuration data store.
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.
47 void post(String uriPath, @NonNull String payload) throws OperationFailedException;
50 * Issues a restconf DELETE request to the configuration data store.
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.
56 void delete(String uriPath) throws OperationFailedException;
59 * Issues a restconf GET request to the given data store.
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.
67 Optional<String> get(String uriPath, LogicalDatastoreType datastoreType)
68 throws OperationFailedException;
71 * Invokes a yang-defined RPC.
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.
78 Optional<String> invokeRpc(@NonNull String uriPath, Optional<String> input) throws OperationFailedException;
81 * Issues a restconf PATCH request to the configuration data store.
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.
89 Optional<String> patch(@NonNull String uriPath, @NonNull String payload) throws OperationFailedException;