Class: RedfishClient::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/redfish_client/response.rb

Overview

Response struct.

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ Response

Returns a new instance of Response.



12
13
14
15
16
# File 'lib/redfish_client/response.rb', line 12

def initialize(status, headers, body)
  @status = status
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/redfish_client/response.rb', line 10

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/redfish_client/response.rb', line 9

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/redfish_client/response.rb', line 8

def status
  @status
end

Class Method Details

.from_hash(data) ⇒ Object



30
31
32
# File 'lib/redfish_client/response.rb', line 30

def self.from_hash(data)
  new(*data.values_at("status", "headers", "body"))
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/redfish_client/response.rb', line 18

def done?
  status != 202
end

#monitorObject



22
23
24
# File 'lib/redfish_client/response.rb', line 22

def monitor
  done? ? nil : headers["location"]
end

#to_hObject



26
27
28
# File 'lib/redfish_client/response.rb', line 26

def to_h
  { "status" => status, "headers" => headers, "body" => body }
end