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 java.util.Optional;
11 import javax.ws.rs.core.MultivaluedMap;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.common.api.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) 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) 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)
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;
79 * Issues a restconf PATCH request to the configuration data store.
81 * @param uriPath the yang instance identifier path, eg "opendaylight-inventory:nodes/node/device-id".
82 * To specify the root, use {@link ROOT_PATH}.
83 * @param payload the payload data in JSON format.
84 * @return an Optional containing the patch response data in JSON format.
85 * @throws OperationFailedException if the request fails.
87 Optional<String> patch(@NonNull String uriPath, @NonNull String payload) throws OperationFailedException;
90 * Subscribe to a stream.
91 * @param identifier the identifier of the stream, e.g., "data-change-event-subscription/neutron:neutron/...
92 * ...neutron:ports/datastore=OPERATIONAL/scope=SUBTREE".
93 * @param params HTTP query parameters or null.
94 * @return On optional containing the JSON response.
95 * @throws OperationFailedException if the requests fails.
97 Optional<String> subscribeToStream(@NonNull String identifier, MultivaluedMap<String, String> params)
98 throws OperationFailedException;