class CloudParty::Responses::Zones
'/zones' endpoint response object
Attributes
errors[R]
messages[R]
results[R]
Public Class Methods
new(method_name, endpoint, response, options)
click to toggle source
@raise [CloudParty::APIError] if the library encountered
an error and {#successful?} is false
@raise [CloudParty::UnRecognizedEndpointError] if the library encountered
an unknown endpoint for this class
# File lib/cloud_party/responses/zones.rb, line 15 def initialize(method_name, endpoint, response, options) @code = response.code @body = JSON.parse(response.body, symbolize_names: true) @parsed_response = response.parsed_response @success = @body[:success] unless successful? message = <<~MESSAGE Unable to #{method_name.to_s.upcase} to endpoint: #{endpoint}. Inspect CloudParty::APIError#response for further details MESSAGE raise CloudParty::Errors::APIError.new(message, response) end @results = [] if endpoint =~ /^\/zones\/?$/ @body[:result].each do |res| @results << CloudParty::Responses::Result.new(res) end elsif endpoint =~ /^\/zones\/:id\/dns_records\/?$/ raise CloudParty::Errors::RequestError.new("Use CloudParty::Nodes::DNSRecords for this endpoint.", method_name, endpoint, @code, nil) elsif endpoint =~ /^\/zones\/:id\/?$/ @result = CloudParty::Responses::Result.new(@body[:result]) @results << @result else raise Errors::UnRecognizedEndpointError.new(endpoint, self.class) end @errors = [] @body[:errors].each do |err| @errors << CloudParty::Responses::Error.new(err) end @messages = [] @body[:messages].each do |msg| @messages << CloudParty::Responses::Message.new(msg) end end
Public Instance Methods
inspect()
click to toggle source
# File lib/cloud_party/responses/zones.rb, line 67 def inspect wanted_methods = %i[success messages errors results] our_methods = methods.select do |m| wanted_methods.include? m end outputs = [] our_methods.sort.each do |m| outputs << "#{m}=#{send(m)}" end "#<Response: #{outputs.join(', ')}>" end
result()
click to toggle source
# File lib/cloud_party/responses/zones.rb, line 61 def result @body[:result] end
successful?()
click to toggle source
# File lib/cloud_party/responses/zones.rb, line 55 def successful? @success end
Also aliased as: success
to_s()
click to toggle source
# File lib/cloud_party/responses/zones.rb, line 79 def to_s inspect end