class Wavefront::Type::Status
An object which provides information about whether the request was successful or not. Ordinarily this is easy to construct from the API's JSON response, but some classes, for instance Wavefront::Write
fake it by constructing their own.
@!attribute [r] result
@return [OK, ERROR] a string telling us how the request went
@!attribute [r] message
@return [String] Any informational message from the API
@!attribute [r] code
@return [Integer] the HTTP response code from the API request
Attributes
obj[R]
status[R]
Public Class Methods
new(response, status)
click to toggle source
@param response [Hash] the API response, turned into a hash @param status [Integer] HTTP status code
# File lib/wavefront-sdk/types/status.rb, line 30 def initialize(response, status) @obj = response.fetch(:status, response) @status = status end
Public Instance Methods
code()
click to toggle source
# File lib/wavefront-sdk/types/status.rb, line 46 def code obj[:code] || status end
message()
click to toggle source
# File lib/wavefront-sdk/types/status.rb, line 39 def message return obj[:message] if obj[:message] return obj[:error] if obj[:error] nil end
result()
click to toggle source
# File lib/wavefront-sdk/types/status.rb, line 50 def result return obj[:result] if obj[:result] return 'OK' if status.between?(200, 299) 'ERROR' end
to_s()
click to toggle source
# File lib/wavefront-sdk/types/status.rb, line 35 def to_s obj.inspect.to_s end