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

event_listener() click to toggle source

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 36
def event_listener
  address = dig("EventService", "ServerSentEventUri")
  return nil if address.nil?

  EventListener.new(ServerSentEvents.create_client(address))
end
find(oid) click to toggle source

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 16
def find(oid)
  find!(oid)
rescue NoResource
  nil
end
find!(oid) click to toggle source

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 27
def find!(oid)
  Resource.new(@connector, oid: oid)
end
login(username, password) click to toggle source

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 52
def login(username, password)
  @connector.set_auth_info(
    username, password, auth_test_path, session_path
  )
  @connector.login
end
logout() click to toggle source

Sign out of the service.

# File lib/redfish_client/root.rb, line 60
def logout
  @connector.logout
end

Private Instance Methods

auth_test_path() click to toggle source
# File lib/redfish_client/root.rb, line 73
def auth_test_path
  raw.values.find { |v| v["@odata.id"] }["@odata.id"]
end
session_path() click to toggle source
# File lib/redfish_client/root.rb, line 66
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