lib/redfish_client/root.rb in redfish_client-0.2.1 vs lib/redfish_client/root.rb in redfish_client-0.2.2
- old
+ new
@@ -44,12 +44,23 @@
end
# Find Redfish service object by OData ID field.
#
# @param oid [String] Odata id of the resource
- # @return [Resource] new resource
+ # @return [Resource, nil] new resource or nil if resource cannot be found
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
+ def find!(oid)
Resource.new(@connector, oid: oid)
end
private
@@ -58,10 +69,10 @@
end
def session_login(username, password)
r = @connector.post(
@content["Links"]["Sessions"]["@odata.id"],
- { "UserName" => username, "Password" => password }.to_json
+ "UserName" => username, "Password" => password
)
raise AuthError, "Invalid credentials" unless r.status == 201
session_logout