blob: fb8a975ab487716726b86ba737c96e21382b7c06 [file] [log] [blame]
Henry Yue20926e2016-08-25 22:58:02 -04001/*
2 * Copyright 2016-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 * Abstraction of RESTCONF Server functionality according to the
23 * RESTCONF RFC (no official RFC number yet).
Henry Yuab25a712017-02-18 13:15:25 -050024 * <p>
25 * NOTE: This interface will be obsolete and will be replaced by the one
26 * in the RESTCONF application.
Henry Yue20926e2016-08-25 22:58:02 -040027 */
Henry Yuab25a712017-02-18 13:15:25 -050028@Deprecated
Henry Yue20926e2016-08-25 22:58:02 -040029public interface RestconfService {
30 /**
31 * Processes a GET request against a data resource. The
chengfanc58d4be2016-09-20 10:33:12 +080032 * target data resource is identified by its URI. If the
33 * GET operation cannot be fulfilled due to reasons such
34 * as the nonexistence of the target resource, then a
35 * RestconfException exception is raised. The proper
36 * HTTP error status code is enclosed in the exception, so
37 * that the caller may return it to the RESTCONF client to
38 * display.
Henry Yue20926e2016-08-25 22:58:02 -040039 *
40 * @param uri URI of the target data resource
41 * @return JSON representation of the data resource
chengfanc58d4be2016-09-20 10:33:12 +080042 * @throws RestconfException if the GET operation cannot be fulfilled
Henry Yue20926e2016-08-25 22:58:02 -040043 */
chengfanc58d4be2016-09-20 10:33:12 +080044 ObjectNode runGetOperationOnDataResource(String uri)
45 throws RestconfException;
Henry Yue20926e2016-08-25 22:58:02 -040046
47 /**
48 * Processes a POST request against a data resource. The location of
49 * the target resource is passed in as a URI. And the resource's
chengfanc58d4be2016-09-20 10:33:12 +080050 * content is passed in as a JSON ObjectNode. If the POST operation
51 * cannot be fulfilled due to reasons such as wrong input URIs or
52 * syntax errors in the JSON payloads, a RestconfException exception
53 * is raised. The proper HTTP error status code is enclosed in the
54 * exception.
Henry Yue20926e2016-08-25 22:58:02 -040055 *
56 * @param uri URI of the data resource to be created
57 * @param rootNode JSON representation of the data resource
chengfanc58d4be2016-09-20 10:33:12 +080058 * @throws RestconfException if the POST operation cannot be fulfilled
Henry Yue20926e2016-08-25 22:58:02 -040059 */
chengfanc58d4be2016-09-20 10:33:12 +080060 void runPostOperationOnDataResource(String uri, ObjectNode rootNode)
61 throws RestconfException;
Henry Yue20926e2016-08-25 22:58:02 -040062
63 /**
64 * Processes a PUT request against a data resource. The location of
65 * the target resource is passed in as a URI. And the resource's
chengfanc58d4be2016-09-20 10:33:12 +080066 * content is passed in as a JSON ObjectNode. If the PUT operation
67 * cannot be fulfilled due to reasons such as wrong input URIs or
68 * syntax errors in the JSON payloads, a RestconfException exception
69 * is raised. The proper HTTP error status code is enclosed in the
70 * exception.
Henry Yue20926e2016-08-25 22:58:02 -040071 *
72 * @param uri URI of the data resource to be created or updated
73 * @param rootNode JSON representation of the data resource
chengfanc58d4be2016-09-20 10:33:12 +080074 * @throws RestconfException if the PUT operation cannot be fulfilled
Henry Yue20926e2016-08-25 22:58:02 -040075 */
chengfanc58d4be2016-09-20 10:33:12 +080076 void runPutOperationOnDataResource(String uri, ObjectNode rootNode)
77 throws RestconfException;
Henry Yue20926e2016-08-25 22:58:02 -040078
79 /**
80 * Processes the DELETE operation against a data resource. The target
chengfanc58d4be2016-09-20 10:33:12 +080081 * data resource is identified by its URI. If the DELETE operation
82 * cannot be fulfilled due reasons such as the nonexistence of the
83 * target resource, a RestconfException exception is raised. The
84 * proper HTTP error status code is enclosed in the exception.
Henry Yue20926e2016-08-25 22:58:02 -040085 *
86 * @param uri URI of the data resource to be deleted
chengfanc58d4be2016-09-20 10:33:12 +080087 * @throws RestconfException if the DELETE operation cannot be fulfilled
Henry Yue20926e2016-08-25 22:58:02 -040088 */
89 void runDeleteOperationOnDataResource(String uri) throws RestconfException;
90
91 /**
chengfanc58d4be2016-09-20 10:33:12 +080092 * Processes a PATCH operation on a data resource. The target data
93 * resource is identified by its URI passed in by the caller.
94 * And the content of the data resource is passed in as a JSON ObjectNode.
95 * If the PATCH operation cannot be fulfilled due reasons such as
96 * the nonexistence of the target resource, a RestconfException
97 * exception is raised. The proper HTTP error status code is
98 * enclosed in the exception.
99 *
100 * @param uri URI of the data resource to be patched
101 * @param rootNode JSON representation of the data resource
102 * @throws RestconfException if the PATCH operation cannot be fulfilled
103 */
104 void runPatchOperationOnDataResource(String uri, ObjectNode rootNode)
105 throws RestconfException;
106
107 /**
Henry Yue20926e2016-08-25 22:58:02 -0400108 * Retrieves the RESTCONF Root directory.
109 *
110 * @return the RESTCONF Root directory
111 */
112 String getRestconfRootPath();
113
114 /**
115 * Handles an Event Stream subscription request. This function creates
116 * a worker thread to listen to events and writes to a ChunkedOutput,
117 * which is passed in from the caller. (The worker thread blocks if
118 * no events arrive.) The ChuckedOutput is a pipe to which this
119 * function acts as the writer and the caller the reader.
chengfanc58d4be2016-09-20 10:33:12 +0800120 * <p>
121 * If the Event Stream cannot be subscribed due to reasons such as
122 * the nonexistence of the target stream or failure to allocate
123 * worker thread to handle the request, a RestconfException exception
124 * is raised. The proper HTTP error status code is enclosed in the
125 * exception, so that the caller may return it to the RESTCONF client
126 * to display.
Henry Yue20926e2016-08-25 22:58:02 -0400127 *
128 * @param streamId ID of the RESTCONF stream to subscribe
129 * @param output A string data stream
chengfanc58d4be2016-09-20 10:33:12 +0800130 * @throws RestconfException if the Event Stream cannot be subscribed
Henry Yue20926e2016-08-25 22:58:02 -0400131 */
chengfanc58d4be2016-09-20 10:33:12 +0800132 void subscribeEventStream(String streamId, ChunkedOutput<String> output)
133 throws RestconfException;
Henry Yue20926e2016-08-25 22:58:02 -0400134}