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
-
#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
#find(oid) ⇒ Resource?
Find Redfish service object by OData ID field.
50 51 52 53 54 |
# File 'lib/redfish_client/root.rb', line 50 def find(oid) find!(oid) rescue NoResource nil end |
#find!(oid) ⇒ Resource
Find Redfish service object by OData ID field.
61 62 63 |
# File 'lib/redfish_client/root.rb', line 61 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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/redfish_client/root.rb', line 28 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.
41 42 43 44 |
# File 'lib/redfish_client/root.rb', line 41 def logout session_logout basic_logout end |