blob: f5835dcc48fd21f0cc4e5522ad71783e302d428c [file] [log] [blame]
Hesam Rahimi4a409b42016-08-12 18:37:33 -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 */
16
17package org.onosproject.protocol.http;
18
Matteo Gerola7e180c22017-03-30 11:57:58 +020019import java.io.InputStream;
20import java.util.Map;
21
22import javax.ws.rs.core.MediaType;
23
Hesam Rahimi4a409b42016-08-12 18:37:33 -040024import org.onlab.packet.IpAddress;
25import org.onosproject.net.DeviceId;
26import org.onosproject.protocol.rest.RestSBDevice;
27
Hesam Rahimi4a409b42016-08-12 18:37:33 -040028/**
29 * Abstraction of an HTTP controller. Serves as a one stop shop for obtaining
30 * HTTP southbound devices and (un)register listeners.
31 */
32public interface HttpSBController {
33
34 /**
35 * Returns all the devices known to this controller.
36 *
37 * @return map of devices
38 */
39 Map<DeviceId, RestSBDevice> getDevices();
40
41 /**
42 * Returns a device by node identifier.
43 *
44 * @param deviceInfo node identifier
45 * @return RestSBDevice rest device
46 */
47 RestSBDevice getDevice(DeviceId deviceInfo);
48
49 /**
50 * Returns a device by Ip and Port.
51 *
Matteo Gerola7e180c22017-03-30 11:57:58 +020052 * @param ip device ip
Hesam Rahimi4a409b42016-08-12 18:37:33 -040053 * @param port device port
54 * @return RestSBDevice rest device
55 */
56 RestSBDevice getDevice(IpAddress ip, int port);
57
58 /**
59 * Adds a device to the device map.
60 *
61 * @param device to be added
62 */
63 void addDevice(RestSBDevice device);
64
65 /**
66 * Removes the device from the devices map.
67 *
68 * @param deviceId to be removed
69 */
70 void removeDevice(DeviceId deviceId);
71
72 /**
73 * Does a HTTP POST request with specified parameters to the device.
74 *
Matteo Gerola7e180c22017-03-30 11:57:58 +020075 * @param device device to make the request to
76 * @param request url of the request
77 * @param payload payload of the request as an InputStream
Hesam Rahimi4a409b42016-08-12 18:37:33 -040078 * @param mediaType type of content in the payload i.e. application/json
79 * @return true if operation returned 200, 201, 202, false otherwise
Matteo Gerola7e180c22017-03-30 11:57:58 +020080 *
81 * @deprecated in Kingfisher (1.10.0)
Hesam Rahimi4a409b42016-08-12 18:37:33 -040082 */
Matteo Gerola7e180c22017-03-30 11:57:58 +020083 @Deprecated
Hesam Rahimi4a409b42016-08-12 18:37:33 -040084 boolean post(DeviceId device, String request, InputStream payload, String mediaType);
85
86 /**
87 * Does a HTTP POST request with specified parameters to the device.
88 *
Matteo Gerola7e180c22017-03-30 11:57:58 +020089 * @param <T> post return type
90 * @param device device to make the request to
91 * @param request url of the request
92 * @param payload payload of the request as an InputStream
93 * @param mediaType type of content in the payload i.e. application/json
Hesam Rahimi4a409b42016-08-12 18:37:33 -040094 * @param responseClass the type of response object we are interested in,
Matteo Gerola7e180c22017-03-30 11:57:58 +020095 * such as String, InputStream.
Hesam Rahimi4a409b42016-08-12 18:37:33 -040096 * @return Object of type requested via responseClass.
97 */
Matteo Gerola7e180c22017-03-30 11:57:58 +020098 @Deprecated
99 <T> T post(DeviceId device, String request, InputStream payload, String mediaType, Class<T> responseClass);
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400100
101 /**
102 * Does a HTTP PUT request with specified parameters to the device.
103 *
Matteo Gerola7e180c22017-03-30 11:57:58 +0200104 * @param device device to make the request to
105 * @param request resource path of the request
106 * @param payload payload of the request as an InputStream
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400107 * @param mediaType type of content in the payload i.e. application/json
108 * @return true if operation returned 200, 201, 202, false otherwise
Matteo Gerola7e180c22017-03-30 11:57:58 +0200109 *
110 * @deprecated in Kingfisher (1.10.0)
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400111 */
Matteo Gerola7e180c22017-03-30 11:57:58 +0200112 @Deprecated
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400113 boolean put(DeviceId device, String request, InputStream payload, String mediaType);
114
115 /**
Matteo Gerola7e180c22017-03-30 11:57:58 +0200116 *
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400117 * Does a HTTP GET request with specified parameters to the device.
118 *
Matteo Gerola7e180c22017-03-30 11:57:58 +0200119 * @param device device to make the request to
120 * @param request url of the request
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400121 * @param mediaType format to retrieve the content in
122 * @return an inputstream of data from the reply.
123 */
Matteo Gerola7e180c22017-03-30 11:57:58 +0200124 @Deprecated
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400125 InputStream get(DeviceId device, String request, String mediaType);
126
127 /**
128 * Does a HTTP PATCH request with specified parameters to the device.
129 *
Matteo Gerola7e180c22017-03-30 11:57:58 +0200130 * @param device device to make the request to
131 * @param request url of the request
132 * @param payload payload of the request as an InputStream
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400133 * @param mediaType format to retrieve the content in
134 * @return true if operation returned 200, 201, 202, false otherwise
Matteo Gerola7e180c22017-03-30 11:57:58 +0200135 *
136 * @deprecated in Kingfisher (1.10.0)
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400137 */
Matteo Gerola7e180c22017-03-30 11:57:58 +0200138 @Deprecated
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400139 boolean patch(DeviceId device, String request, InputStream payload, String mediaType);
140
141 /**
142 * Does a HTTP DELETE request with specified parameters to the device.
143 *
Matteo Gerola7e180c22017-03-30 11:57:58 +0200144 * @param device device to make the request to
145 * @param request url of the request
146 * @param payload payload of the request as an InputStream
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400147 * @param mediaType type of content in the payload i.e. application/json
148 * @return true if operation returned 200 false otherwise
Matteo Gerola7e180c22017-03-30 11:57:58 +0200149 *
150 * @deprecated in Kingfisher (1.10.0)
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400151 */
Matteo Gerola7e180c22017-03-30 11:57:58 +0200152 @Deprecated
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400153 boolean delete(DeviceId device, String request, InputStream payload, String mediaType);
154
Matteo Gerola7e180c22017-03-30 11:57:58 +0200155 /**
156 * Does a HTTP POST request with specified parameters to the device.
157 *
158 * @param device device to make the request to
159 * @param request url of the request
160 * @param payload payload of the request as an InputStream
161 * @param mediaType type of content in the payload i.e. application/json
162 * @return status Commonly used status codes defined by HTTP
163 */
164 int post(DeviceId device, String request, InputStream payload, MediaType mediaType);
165
166 /**
167 * Does a HTTP PUT request with specified parameters to the device.
168 *
169 * @param device device to make the request to
170 * @param request resource path of the request
171 * @param payload payload of the request as an InputStream
172 * @param mediaType type of content in the payload i.e. application/json
173 * @return status Commonly used status codes defined by HTTP
174 */
175 int put(DeviceId device, String request, InputStream payload, MediaType mediaType);
176
177 /**
178 * Does a HTTP PATCH request with specified parameters to the device.
179 *
180 * @param device device to make the request to
181 * @param request url of the request
182 * @param payload payload of the request as an InputStream
183 * @param mediaType format to retrieve the content in
184 * @return status Commonly used status codes defined by HTTP
185 */
186 int patch(DeviceId device, String request, InputStream payload, MediaType mediaType);
187
188 /**
189 * Does a HTTP DELETE request with specified parameters to the device.
190 *
191 * @param device device to make the request to
192 * @param request url of the request
193 * @param payload payload of the request as an InputStream
194 * @param mediaType type of content in the payload i.e. application/json
195 * @return status Commonly used status codes defined by HTTP
196 */
197 int delete(DeviceId device, String request, InputStream payload, MediaType mediaType);
198
199 /**
200 *
201 * Does a HTTP GET request with specified parameters to the device.
202 *
203 * @param device device to make the request to
204 * @param request url of the request
205 * @param mediaType format to retrieve the content in
206 * @return an inputstream of data from the reply.
207 */
208 InputStream get(DeviceId device, String request, MediaType mediaType);
209
210 /**
211 * Does a HTTP POST request with specified parameters to the device.
212 *
213 * @param <T> post return type
214 * @param device device to make the request to
215 * @param request url of the request
216 * @param payload payload of the request as an InputStream
217 * @param mediaType type of content in the payload i.e. application/json
218 * @param responseClass the type of response object we are interested in,
219 * such as String, InputStream.
220 * @return Object of type requested via responseClass.
221 */
222 <T> T post(DeviceId device, String request, InputStream payload, MediaType mediaType, Class<T> responseClass);
223
224
Hesam Rahimi4a409b42016-08-12 18:37:33 -0400225}