blob: 28d5617c9deae0978abfffae67e094013384c46c [file] [log] [blame]
Andrea Campanella945ded22016-01-07 13:17:43 -08001/*
2 * Copyright 2016 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.rest;
18
19import org.onlab.packet.IpAddress;
20import org.onosproject.net.DeviceId;
21
22import java.io.InputStream;
23import java.util.Map;
24
25/**
26 * Abstraction of an REST controller. Serves as a one stop shop for obtaining
27 * Rest southbound devices and (un)register listeners.
28 */
29public interface RestSBController {
30
31 /**
32 * Returns all the devices known to this controller.
33 *
34 * @return map of devices
35 */
36 Map<DeviceId, RestSBDevice> getDevices();
37
38 /**
39 * Returns a device by node identifier.
40 *
41 * @param deviceInfo node identifier
42 * @return RestSBDevice rest device
43 */
44 RestSBDevice getDevice(DeviceId deviceInfo);
45
46 /**
47 * Returns a device by Ip and Port.
48 *
49 * @param ip device ip
50 * @param port device port
51 * @return RestSBDevice rest device
52 */
53 RestSBDevice getDevice(IpAddress ip, int port);
54
55 /**
56 * Adds a device to the device map.
57 *
58 * @param device to be added
59 */
60 void addDevice(RestSBDevice device);
61
62 /**
63 * Removes the device from the devices map.
64 *
65 * @param device to be removed
66 */
67 void removeDevice(RestSBDevice device);
68
69 /**
70 * Does a REST POST request with specified parameters to the device.
71 *
72 * @param device device to make the request to
73 * @param request url of the request
74 * @param payload payload of the request as an InputStream
75 * @param mediaType type of content in the payload i.e. application/json
76 * @return true if operation returned 200, 201, 202, false otherwise
77 */
78 boolean post(DeviceId device, String request, InputStream payload, String mediaType);
79
80 /**
81 * Does a REST PUT request with specified parameters to the device.
82 *
83 * @param device device to make the request to
84 * @param request resource path of the request
85 * @param payload payload of the request as an InputStream
86 * @param mediaType type of content in the payload i.e. application/json
87 * @return true if operation returned 200, 201, 202, false otherwise
88 */
89 boolean put(DeviceId device, String request, InputStream payload, String mediaType);
90
91 /**
92 * Does a REST GET request with specified parameters to the device.
93 *
94 * @param device device to make the request to
95 * @param request url of the request
96 * @param mediaType format to retrieve the content in
97 * @return an inputstream of data from the reply.
98 */
99 InputStream get(DeviceId device, String request, String mediaType);
100
101 /**
102 * Does a REST DELETE request with specified parameters to the device.
103 *
104 * @param device device to make the request to
105 * @param request url of the request
106 * @param payload payload of the request as an InputStream
107 * @param mediaType type of content in the payload i.e. application/json
108 * @return true if operation returned 200 false otherwise
109 */
110 boolean delete(DeviceId device, String request, InputStream payload, String mediaType);
111
112}