lib/redfish_client/root.rb in redfish_client-0.3.0 vs lib/redfish_client/root.rb in redfish_client-0.4.0

- old
+ new

@@ -1,9 +1,11 @@ # frozen_string_literal: true require "base64" require "json" +require "server_sent_events" + require "redfish_client/resource" module RedfishClient # Root resource represents toplevel entry point into Redfish service data. # Its main purpose is to provide authentication support for the API. @@ -58,9 +60,21 @@ # @param oid [String] Odata id of the resource # @return [Resource] new resource # @raise [NoResource] resource cannot be fetched def find!(oid) Resource.new(@connector, oid: oid) + end + + # Return event listener. + # + # If the service does not support SSE, this function will return nil. + # + # @return [EventListener, nil] event listener + def event_listener + address = dig("EventService", "ServerSentEventUri") + return nil if address.nil? + + EventListener.new(ServerSentEvents.create_client(address)) end private def session_login_available?