class RedfishClient::Root
Root resource represents toplevel entry point into Redfish service data. Its main purpose is to provide authentication support for the API.
Public Instance Methods
Return event listener.
If the service does not support SSE, this function will return nil.
@return [EventListener, nil] event listener
# File lib/redfish_client/root.rb, line 35 def event_listener address = dig("EventService", "ServerSentEventUri") return nil if address.nil? EventListener.new(ServerSentEvents.create_client(address)) end
Find Redfish service object by OData ID field.
@param oid [String] Odata id of the resource @return [Resource, nil] new resource or nil if resource cannot be found
# File lib/redfish_client/root.rb, line 15 def find(oid) find!(oid) rescue NoResource nil end
Find Redfish service object by OData ID field.
@param oid [String] Odata id of the resource @return [Resource] new resource @raise [NoResource] resource cannot be fetched
# File lib/redfish_client/root.rb, line 26 def find!(oid) Resource.new(@connector, oid: oid) end
Authenticate against the service.
Calling this method will select the appropriate method of authentication and try to login using provided credentials.
@param username [String] username @param password [String] password @raise [RedfishClient::AuthenticatedConnector::AuthError] if user
session could not be authenticated
# File lib/redfish_client/root.rb, line 51 def login(username, password) @connector.set_auth_info( username, password, auth_test_path, session_path ) @connector.login end
Sign out of the service.
# File lib/redfish_client/root.rb, line 59 def logout @connector.logout end
Private Instance Methods
# File lib/redfish_client/root.rb, line 72 def auth_test_path raw.values.find { |v| v["@odata.id"] }["@odata.id"] end
# File lib/redfish_client/root.rb, line 65 def session_path # We access raw values here on purpose, since calling dig on resource # instance would try to download the sessions collection, which would # fail since we are not yet logged in. raw.dig("Links", "Sessions", "@odata.id") end