Interface HttpSBController

  • All Known Subinterfaces:
    RestSBController
    All Known Implementing Classes:
    HttpSBControllerImpl

    public interface HttpSBController
    Abstraction 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
      void addDevice​(RestSBDevice device)
      Adds a device to the device map.
      int cancelServerSentEvents​(org.onosproject.net.DeviceId deviceId)
      Cancels a Server Sent Events listener to a device.
      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.
      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.
      RestSBDevice getDevice​(org.onlab.packet.IpAddress ip, int port)
      Returns a device by Ip and Port.
      RestSBDevice getDevice​(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.
      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.
      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.
      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.
      <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.
      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.
      void removeDevice​(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 ip
        port - 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 to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - 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 to
        request - resource path of the request
        payload - payload of the request as an InputStream
        mediaType - 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 to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - 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 to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - 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 to
        request - url of the request
        mediaType - 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 to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - type of content in the payload i.e. application/json
        responseClass - 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 to
        request - url of the request
        onEvent - A consumer of inbound SSE_INBOUND events
        onError - 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