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.controller.restconf.api;
10 import com.google.common.base.Optional;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.yangtools.yang.common.OperationFailedException;
16 * @author Thomas Pantelis
18 public interface JSONRestconfService {
20 * The data tree root path.
22 String ROOT_PATH = null;
25 * Issues a restconf PUT request to the configuration data store.
27 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
28 * To specify the root, use {@link ROOT_PATH}.
29 * @param payload the payload data in JSON format.
30 * @throws OperationFailedException if the request fails.
32 void put(String uriPath, @Nonnull String payload) throws OperationFailedException;
35 * Issues a restconf POST request to the configuration data store.
37 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
38 * To specify the root, use {@link ROOT_PATH}.
39 * @param payload the payload data in JSON format.
40 * @throws OperationFailedException if the request fails.
42 void post(String uriPath, @Nonnull String payload) throws OperationFailedException;
45 * Issues a restconf DELETE request to the configuration data store.
47 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
48 * To specify the root, use {@link ROOT_PATH}.
49 * @throws OperationFailedException if the request fails.
51 void delete(String uriPath) throws OperationFailedException;
54 * Issues a restconf GET request to the given data store.
56 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
57 * To specify the root, use {@link ROOT_PATH}.
58 * @param datastoreType the data store type to read from.
59 * @return an Optional containing the data in JSON format if present.
60 * @throws OperationFailedException if the request fails.
62 Optional<String> get(String uriPath, LogicalDatastoreType datastoreType) throws OperationFailedException;
65 * Invokes a yang-defined RPC.
67 * @param uriPath the path representing the RPC to invoke, eg "toaster:make-toast".
68 * @param input the input in JSON format if the RPC takes input.
69 * @return an Optional containing the output in JSON format if the RPC returns output.
70 * @throws OperationFailedException if the request fails.
72 Optional<String> invokeRpc(@Nonnull String uriPath, Optional<String> input) throws OperationFailedException;