Class: RedfishClient::Root
- Defined in:
- lib/redfish_client/root.rb
Overview
Root resource represents toplevel entry point into Redfish service data. Its main purpose is to provide authentication support for the API.
Defined Under Namespace
Classes: AuthError
Constant Summary collapse
- BASIC_AUTH_HEADER =
Basic and token authentication headers.
"Authorization"- TOKEN_AUTH_HEADER =
"X-Auth-Token"
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#event_listener ⇒ EventListener?
Return event listener.
-
#find(oid) ⇒ Resource?
Find Redfish service object by OData ID field.
-
#find!(oid) ⇒ Resource
Find Redfish service object by OData ID field.
-
#login(username, password) ⇒ Object
Authenticate against the service.
-
#logout ⇒ Object
Sign out of the service.
Methods inherited from Resource
#[], #delete, #dig, #initialize, #key?, #method_missing, #patch, #post, #raw, #reset, #respond_to_missing?, #to_s
Constructor Details
This class inherits a constructor from RedfishClient::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RedfishClient::Resource
Instance Method Details
#event_listener ⇒ EventListener?
Return event listener.
If the service does not support SSE, this function will return nil.
73 74 75 76 77 78 |
# File 'lib/redfish_client/root.rb', line 73 def event_listener address = dig("EventService", "ServerSentEventUri") return nil if address.nil? EventListener.new(ServerSentEvents.create_client(address)) end |
#find(oid) ⇒ Resource?
Find Redfish service object by OData ID field.
53 54 55 56 57 |
# File 'lib/redfish_client/root.rb', line 53 def find(oid) find!(oid) rescue NoResource nil end |
#find!(oid) ⇒ Resource
Find Redfish service object by OData ID field.
64 65 66 |
# File 'lib/redfish_client/root.rb', line 64 def find!(oid) Resource.new(@connector, oid: oid) end |
#login(username, password) ⇒ Object
Authenticate against the service.
Calling this method will try to create new session on the service using provided credentials. If the session creation fails, basic authentication will be attempted. If basic authentication fails, AuthError will be raised.
31 32 33 34 35 36 37 38 39 |
# File 'lib/redfish_client/root.rb', line 31 def login(username, password) # Since session auth is more secure, we try it first and use basic auth # only if session auth is not available. if session_login_available? session_login(username, password) else basic_login(username, password) end end |
#logout ⇒ Object
Sign out of the service.
If the session could not be deleted, AuthError will be raised.
44 45 46 47 |
# File 'lib/redfish_client/root.rb', line 44 def logout session_logout basic_logout end |