Class: RedfishClient::Root

Inherits:
Resource show all
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.

Instance Attribute Summary

Attributes inherited from Resource

#headers, #raw

Instance Method Summary collapse

Methods inherited from Resource

#[], #delete, #dig, #get, #initialize, #key?, #method_missing, #patch, #post, #refresh, #request, #respond_to_missing?, #to_s, #wait

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_listenerEventListener?

Return event listener.

If the service does not support SSE, this function will return nil.

Returns:



36
37
38
39
40
41
# 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) ⇒ Resource?

Find Redfish service object by OData ID field.

Parameters:

  • oid (String)

    Odata id of the resource

Returns:

  • (Resource, nil)

    new resource or nil if resource cannot be found



16
17
18
19
20
# File 'lib/redfish_client/root.rb', line 16

def find(oid)
  find!(oid)
rescue NoResource
  nil
end

#find!(oid) ⇒ Resource

Find Redfish service object by OData ID field.

Parameters:

  • oid (String)

    Odata id of the resource

Returns:

Raises:



27
28
29
# File 'lib/redfish_client/root.rb', line 27

def find!(oid)
  Resource.new(@connector, oid: oid)
end

#login(username, password) ⇒ Object

Authenticate against the service.

Calling this method will select the appropriate method of authentication and try to login using provided credentials.

Parameters:

  • username (String)

    username

  • password (String)

    password

Raises:

  • (RedfishClient::AuthenticatedConnector::AuthError)

    if user session could not be authenticated



52
53
54
55
56
57
# File 'lib/redfish_client/root.rb', line 52

def (username, password)
  @connector.set_auth_info(
    username, password, auth_test_path, session_path
  )
  @connector.
end

#logoutObject

Sign out of the service.



60
61
62
# File 'lib/redfish_client/root.rb', line 60

def logout
  @connector.logout
end