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.netconf.sal.restconf.api;
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;
18 * @author Thomas Pantelis.
20 public interface JSONRestconfService {
22 * The data tree root path.
24 String ROOT_PATH = null;
27 * Issues a restconf PUT request to the configuration data store.
29 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
30 * To specify the root, use {@link ROOT_PATH}.
31 * @param payload the payload data in JSON format.
32 * @throws OperationFailedException if the request fails.
34 void put(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
37 * Issues a restconf POST request to the configuration data store.
39 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
40 * To specify the root, use {@link ROOT_PATH}.
41 * @param payload the payload data in JSON format.
42 * @throws OperationFailedException if the request fails.
44 void post(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
47 * Issues a restconf DELETE request to the configuration data store.
49 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
50 * To specify the root, use {@link ROOT_PATH}.
51 * @throws OperationFailedException if the request fails.
53 void delete(String uriPath) throws OperationFailedException;
56 * Issues a restconf GET request to the given data store.
58 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
59 * To specify the root, use {@link ROOT_PATH}.
60 * @param datastoreType the data store type to read from.
61 * @return an Optional containing the data in JSON format if present.
62 * @throws OperationFailedException if the request fails.
64 Optional<String> get(String uriPath, LogicalDatastoreType datastoreType, UriInfo uriInfo)
65 throws OperationFailedException;
68 * Invokes a yang-defined RPC.
70 * @param uriPath the path representing the RPC to invoke, eg "toaster:make-toast".
71 * @param input the input in JSON format if the RPC takes input.
72 * @return an Optional containing the output in JSON format if the RPC returns output.
73 * @throws OperationFailedException if the request fails.
75 Optional<String> invokeRpc(@Nonnull String uriPath, Optional<String> input) throws OperationFailedException;