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.MultivaluedMap;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.yangtools.yang.common.OperationFailedException;
19 * Provides restconf CRUD operations via code with input/output data in JSON format.
21 * @author Thomas Pantelis.
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;
92 * Subscribe to a stream.
93 * @param identifier the identifier of the stream, e.g., "data-change-event-subscription/neutron:neutron/...
94 * ...neutron:ports/datastore=OPERATIONAL/scope=SUBTREE".
95 * @param params HTTP query parameters or null.
96 * @return On optional containing the JSON response.
97 * @throws OperationFailedException if the requests fails.
99 Optional<String> subscribeToStream(@Nonnull String identifier, MultivaluedMap<String, String> params)
100 throws OperationFailedException;