Class HttpSBControllerImpl
- java.lang.Object
-
- org.onosproject.protocol.http.ctl.HttpSBControllerImpl
-
- All Implemented Interfaces:
HttpSBController
public class HttpSBControllerImpl extends java.lang.Object implements HttpSBController
The implementation of HttpSBController.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOLONprotected static java.lang.StringDOUBLESLASH
-
Constructor Summary
Constructors Constructor Description HttpSBControllerImpl()
-
Method Summary
All Methods Instance Methods Concrete 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.java.util.Map<org.onosproject.net.DeviceId,javax.ws.rs.client.Client>getClientMap()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>getDeviceMap()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.java.util.Map<org.onosproject.net.DeviceId,javax.ws.rs.sse.SseEventSource>getSseEventSourceMap()protected java.lang.StringgetUrlString(org.onosproject.net.DeviceId deviceId, java.lang.String request)protected javax.ws.rs.client.WebTargetgetWebTarget(org.onosproject.net.DeviceId device, java.lang.String request)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.
-
-
-
Field Detail
-
DOUBLESLASH
protected static final java.lang.String DOUBLESLASH
- See Also:
- Constant Field Values
-
COLON
protected static final java.lang.String COLON
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDeviceMap
public java.util.Map<org.onosproject.net.DeviceId,RestSBDevice> getDeviceMap()
-
getClientMap
public java.util.Map<org.onosproject.net.DeviceId,javax.ws.rs.client.Client> getClientMap()
-
getSseEventSourceMap
public java.util.Map<org.onosproject.net.DeviceId,javax.ws.rs.sse.SseEventSource> getSseEventSourceMap()
-
getDevices
public java.util.Map<org.onosproject.net.DeviceId,RestSBDevice> getDevices()
Description copied from interface:HttpSBControllerReturns all the devices known to this controller.- Specified by:
getDevicesin interfaceHttpSBController- Returns:
- map of devices
-
getDevice
public RestSBDevice getDevice(org.onosproject.net.DeviceId deviceInfo)
Description copied from interface:HttpSBControllerReturns a device by node identifier.- Specified by:
getDevicein interfaceHttpSBController- Parameters:
deviceInfo- node identifier- Returns:
- RestSBDevice rest device
-
getDevice
public RestSBDevice getDevice(org.onlab.packet.IpAddress ip, int port)
Description copied from interface:HttpSBControllerReturns a device by Ip and Port.- Specified by:
getDevicein interfaceHttpSBController- Parameters:
ip- device ipport- device port- Returns:
- RestSBDevice rest device
-
addDevice
public void addDevice(RestSBDevice device)
Description copied from interface:HttpSBControllerAdds a device to the device map.- Specified by:
addDevicein interfaceHttpSBController- Parameters:
device- to be added
-
removeDevice
public void removeDevice(org.onosproject.net.DeviceId deviceId)
Description copied from interface:HttpSBControllerRemoves the device from the devices map.- Specified by:
removeDevicein interfaceHttpSBController- Parameters:
deviceId- to be removed
-
post
public int post(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Description copied from interface:HttpSBControllerDoes a HTTP POST request with specified parameters to the device.- Specified by:
postin interfaceHttpSBController- 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
-
post
public <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)Description copied from interface:HttpSBControllerDoes a HTTP POST request with specified parameters to the device and extracts an object of type T from the response entity field.- Specified by:
postin interfaceHttpSBController- 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.
-
put
public int put(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Description copied from interface:HttpSBControllerDoes a HTTP PUT request with specified parameters to the device.- Specified by:
putin interfaceHttpSBController- 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
-
get
public java.io.InputStream get(org.onosproject.net.DeviceId device, java.lang.String request, javax.ws.rs.core.MediaType mediaType)Description copied from interface:HttpSBControllerDoes a HTTP GET request with specified parameters to the device.- Specified by:
getin interfaceHttpSBController- 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.
-
patch
public int patch(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Description copied from interface:HttpSBControllerDoes a HTTP PATCH request with specified parameters to the device.- Specified by:
patchin interfaceHttpSBController- 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
public int delete(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)Description copied from interface:HttpSBControllerDoes a HTTP DELETE request with specified parameters to the device.- Specified by:
deletein interfaceHttpSBController- 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
-
getServerSentEvents
public 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)Description copied from interface:HttpSBControllerDoes 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- Specified by:
getServerSentEventsin interfaceHttpSBController- 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
public int cancelServerSentEvents(org.onosproject.net.DeviceId deviceId)
Description copied from interface:HttpSBControllerCancels a Server Sent Events listener to a device.- Specified by:
cancelServerSentEventsin interfaceHttpSBController- Parameters:
deviceId- device to cancel the listener for- Returns:
- status Commonly used status codes defined by HTTP
-
getWebTarget
protected javax.ws.rs.client.WebTarget getWebTarget(org.onosproject.net.DeviceId device, java.lang.String request)
-
getUrlString
protected java.lang.String getUrlString(org.onosproject.net.DeviceId deviceId, java.lang.String request)
-
-