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;
17 * Provides restconf CRUD operations via code with input/output data in JSON format.
19 * @author Thomas Pantelis.
21 public interface JSONRestconfService {
23 * The data tree root path.
25 String ROOT_PATH = null;
28 * Issues a restconf PUT request to the configuration data store.
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.
35 void put(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
38 * Issues a restconf POST request to the configuration data store.
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.
45 void post(String uriPath, @Nonnull String payload, UriInfo uriInfo) throws OperationFailedException;
48 * Issues a restconf DELETE request to the configuration data store.
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.
54 void delete(String uriPath) throws OperationFailedException;
57 * Issues a restconf GET request to the given data store.
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.
65 Optional<String> get(String uriPath, LogicalDatastoreType datastoreType, UriInfo uriInfo)
66 throws OperationFailedException;
69 * Invokes a yang-defined RPC.
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.
76 Optional<String> invokeRpc(@Nonnull String uriPath, Optional<String> input) throws OperationFailedException;