Package org.onosproject.protocol.http
Interface HttpSBController
-
- All Known Subinterfaces:
RestSBController
- All Known Implementing Classes:
HttpSBControllerImpl
public interface HttpSBControllerAbstraction of an HTTP controller. Serves as a one stop shop for obtaining HTTP southbound devices and (un)register listeners.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddDevice(RestSBDevice device)Adds a device to the device map.intcancelServerSentEvents(org.onosproject.net.DeviceId deviceId)Cancels a Server Sent Events listener to a device.intdelete(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP DELETE request with specified parameters to the device.java.io.InputStreamget(org.onosproject.net.DeviceId device, java.lang.String request, javax.ws.rs.core.MediaType mediaType)Does a HTTP GET request with specified parameters to the device.RestSBDevicegetDevice(org.onlab.packet.IpAddress ip, int port)Returns a device by Ip and Port.RestSBDevicegetDevice(org.onosproject.net.DeviceId deviceInfo)Returns a device by node identifier.java.util.Map<org.onosproject.net.DeviceId,RestSBDevice>getDevices()Returns all the devices known to this controller.intgetServerSentEvents(org.onosproject.net.DeviceId deviceId, java.lang.String request, java.util.function.Consumer<javax.ws.rs.sse.InboundSseEvent> onEvent, java.util.function.Consumer<java.lang.Throwable> onError)Does a HTTP GET against a Server Sent Events (SSE_INBOUND) resource on the device.intpatch(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP PATCH request with specified parameters to the device.intpost(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP POST request with specified parameters to the device.<T> Tpost(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType, java.lang.Class<T> responseClass)Does a HTTP POST request with specified parameters to the device and extracts an object of type T from the response entity field.intput(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP PUT request with specified parameters to the device.voidremoveDevice(org.onosproject.net.DeviceId deviceId)Removes the device from the devices map.
-
-
-
Method Detail
-
getDevices
java.util.Map<org.onosproject.net.DeviceId,RestSBDevice> getDevices()
Returns all the devices known to this controller.- Returns:
- map of devices
-
getDevice
RestSBDevice getDevice(org.onosproject.net.DeviceId deviceInfo)
Returns a device by node identifier.- Parameters:
deviceInfo- node identifier- Returns:
- RestSBDevice rest device
-
getDevice
RestSBDevice getDevice(org.onlab.packet.IpAddress ip, int port)
Returns a device by Ip and Port.- Parameters:
ip- device ipport- device port- Returns:
- RestSBDevice rest device
-
addDevice
void addDevice(RestSBDevice device)
Adds a device to the device map.- Parameters:
device- to be added
-
removeDevice
void removeDevice(org.onosproject.net.DeviceId deviceId)
Removes the device from the devices map.- Parameters:
deviceId- to be removed
-
post
int post(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP POST request with specified parameters to the device.- Parameters:
device- device to make the request torequest- url of the requestpayload- payload of the request as an InputStreammediaType- type of content in the payload i.e. application/json- Returns:
- status Commonly used status codes defined by HTTP
-
put
int put(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP PUT request with specified parameters to the device.- Parameters:
device- device to make the request torequest- resource path of the requestpayload- payload of the request as an InputStreammediaType- type of content in the payload i.e. application/json- Returns:
- status Commonly used status codes defined by HTTP
-
patch
int patch(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP PATCH request with specified parameters to the device.- Parameters:
device- device to make the request torequest- url of the requestpayload- payload of the request as an InputStreammediaType- format to retrieve the content in- Returns:
- status Commonly used status codes defined by HTTP
-
delete
int delete(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Does a HTTP DELETE request with specified parameters to the device.- Parameters:
device- device to make the request torequest- url of the requestpayload- payload of the request as an InputStreammediaType- type of content in the payload i.e. application/json- Returns:
- status Commonly used status codes defined by HTTP
-
get
java.io.InputStream get(org.onosproject.net.DeviceId device, java.lang.String request, javax.ws.rs.core.MediaType mediaType)Does a HTTP GET request with specified parameters to the device.- Parameters:
device- device to make the request torequest- url of the requestmediaType- format to retrieve the content in- Returns:
- an inputstream of data from the reply.
-
post
<T> T post(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType, java.lang.Class<T> responseClass)Does a HTTP POST request with specified parameters to the device and extracts an object of type T from the response entity field.- Type Parameters:
T- post return type- Parameters:
device- device to make the request torequest- url of the requestpayload- payload of the request as an InputStreammediaType- type of content in the payload i.e. application/jsonresponseClass- the type of response object we are interested in, such as String, InputStream.- Returns:
- Object of type requested via responseClass.
-
getServerSentEvents
int getServerSentEvents(org.onosproject.net.DeviceId deviceId, java.lang.String request, java.util.function.Consumer<javax.ws.rs.sse.InboundSseEvent> onEvent, java.util.function.Consumer<java.lang.Throwable> onError)Does a HTTP GET against a Server Sent Events (SSE_INBOUND) resource on the device. This is a low level function that can take callbacks. For a higher level function that emits events based on this callback see startServerSentEvents() in the RestSBController- Parameters:
deviceId- device to make the request torequest- url of the requestonEvent- A consumer of inbound SSE_INBOUND eventsonError- A consumer of inbound SSE_INBOUND errors- Returns:
- status Commonly used status codes defined by HTTP
-
cancelServerSentEvents
int cancelServerSentEvents(org.onosproject.net.DeviceId deviceId)
Cancels a Server Sent Events listener to a device.- Parameters:
deviceId- device to cancel the listener for- Returns:
- status Commonly used status codes defined by HTTP
-
-