blob: b5a0c536a65ab1a715ae1683dea9a1a6d609914e [file] [log] [blame]
Henry Yuab25a712017-02-18 13:15:25 -05001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.protocol.restconf.server.api;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19import org.glassfish.jersey.server.ChunkedOutput;
20
21/**
22 * Representation of a RESTCONF service broker. The broker
23 * provides services to the RESTCONF protocol proxy.
24 */
25public interface RestconfServiceBroker {
26 /**
27 * Processes a GET request against a data resource. The
28 * target data resource is identified by its URI. If the
29 * GET operation cannot be fulfilled due to reasons such
30 * as the nonexistence of the target resource, then a
31 * RestconfException exception is raised. The proper
32 * HTTP error status code is enclosed in the exception, so
33 * that the caller may return it to the RESTCONF client to
34 * display.
35 *
36 * @param uri URI of the target data resource
37 * @return JSON representation of the data resource
38 * @throws RestconfException if the GET operation cannot be fulfilled
39 */
40 ObjectNode runGetOperationOnDataResource(String uri)
41 throws RestconfException;
42
43 /**
44 * Processes a POST request against a data resource. The location of
45 * the target resource is passed in as a URI. And the resource's
46 * content is passed in as a JSON ObjectNode. If the POST operation
47 * cannot be fulfilled due to reasons such as wrong input URIs or
48 * syntax errors in the JSON payloads, a RestconfException exception
49 * is raised. The proper HTTP error status code is enclosed in the
50 * exception.
51 *
52 * @param uri URI of the data resource to be created
53 * @param rootNode JSON representation of the data resource
54 * @throws RestconfException if the POST operation cannot be fulfilled
55 */
56 void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
57 throws RestconfException;
58
59 /**
60 * Processes a PUT request against a data resource. The location of
61 * the target resource is passed in as a URI. And the resource's
62 * content is passed in as a JSON ObjectNode. If the PUT operation
63 * cannot be fulfilled due to reasons such as wrong input URIs or
64 * syntax errors in the JSON payloads, a RestconfException exception
65 * is raised. The proper HTTP error status code is enclosed in the
66 * exception.
67 *
68 * @param uri URI of the data resource to be created or updated
69 * @param rootNode JSON representation of the data resource
70 * @throws RestconfException if the PUT operation cannot be fulfilled
71 */
72 void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
73 throws RestconfException;
74
75 /**
76 * Processes the DELETE operation against a data resource. The target
77 * data resource is identified by its URI. If the DELETE operation
78 * cannot be fulfilled due reasons such as the nonexistence of the
79 * target resource, a RestconfException exception is raised. The
80 * proper HTTP error status code is enclosed in the exception.
81 *
82 * @param uri URI of the data resource to be deleted
83 * @throws RestconfException if the DELETE operation cannot be fulfilled
84 */
85 void runDeleteOperationOnDataResource(String uri) throws RestconfException;
86
87 /**
88 * Processes a PATCH operation on a data resource. The target data
89 * resource is identified by its URI passed in by the caller.
90 * And the content of the data resource is passed in as a JSON ObjectNode.
91 * If the PATCH operation cannot be fulfilled due reasons such as
92 * the nonexistence of the target resource, a RestconfException
93 * exception is raised. The proper HTTP error status code is
94 * enclosed in the exception.
95 *
96 * @param uri URI of the data resource to be patched
97 * @param rootNode JSON representation of the data resource
98 * @throws RestconfException if the PATCH operation cannot be fulfilled
99 */
100 void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
101 throws RestconfException;
102
103 /**
104 * Retrieves the RESTCONF Root directory.
105 *
106 * @return the RESTCONF Root directory
107 */
108 String getRestconfRootPath();
109
110 /**
111 * Handles an Event Stream subscription request. This function creates
112 * a worker thread to listen to events and writes to a ChunkedOutput,
113 * which is passed in from the caller. (The worker thread blocks if
114 * no events arrive.) The ChuckedOutput is a pipe to which this
115 * function acts as the writer and the caller the reader.
116 * <p>
117 * If the Event Stream cannot be subscribed due to reasons such as
118 * the nonexistence of the target stream or failure to allocate
119 * worker thread to handle the request, a RestconfException exception
120 * is raised. The proper HTTP error status code is enclosed in the
121 * exception, so that the caller may return it to the RESTCONF client
122 * to display.
123 *
124 * @param streamId ID of the RESTCONF stream to subscribe
125 * @param output A string data stream
126 * @throws RestconfException if the Event Stream cannot be subscribed
127 */
128 void subscribeEventStream(String streamId, ChunkedOutput<String> output)
129 throws RestconfException;
130}