class RedfishClient::Response

Response struct.

This struct is returned from the methods that interact with the remote API.

Attributes

body[R]
headers[R]
status[R]

Public Class Methods

from_hash(data) click to toggle source
# File lib/redfish_client/response.rb, line 43
def self.from_hash(data)
  new(*data.values_at("status", "headers", "body"))
end
new(status, headers, body) click to toggle source
# File lib/redfish_client/response.rb, line 14
def initialize(status, headers, body)
  @status = status
  @headers = headers
  @body = body
end

Public Instance Methods

done?() click to toggle source

Returns wether the request is completed or ongoing. Be aware than completed doesn't mean completed successfully, and that you still need to check status for success or failure. @return [true] if the request was completed

# File lib/redfish_client/response.rb, line 24
def done?
  status != 202
end
monitor() click to toggle source
# File lib/redfish_client/response.rb, line 28
def monitor
  return nil if done?

  uri = URI.parse(headers["location"])
  [uri.path, uri.query].compact.join("?")
end
to_h() click to toggle source
# File lib/redfish_client/response.rb, line 35
def to_h
  { "status" => status, "headers" => headers, "body" => body }
end
to_s() click to toggle source
# File lib/redfish_client/response.rb, line 39
def to_s
  "Response[status=#{status}, headers=#{headers}, body='#{body}']"
end