class PDNS::Client
Class for interaction with the top level API
.
Attributes
version[R]
@return [Integer] the PowerDNS API
version in use.
Public Class Methods
new(args)
click to toggle source
Creates a Client
object.
@param args [Hash] Arguments used to create an HTTP
object,
which is used by all created objects.
# File lib/pdns_api/client.rb, line 42 def initialize(args) @class = :client @http = PDNS::HTTP.new(args) @version = @http.version @parent = self @url = @http.uri @info = {} end
Public Instance Methods
change()
click to toggle source
Disabled common methods
# File lib/pdns_api/client.rb, line 34 undef_method :change, :create, :delete
servers(id = nil)
click to toggle source
Returns existing or creates a Server
object.
@param id [String, nil] ID of a Server
.
@return [Hash, Server] Hash of Server
objects or a single Server
object.
- If +id+ is not set the current servers are returned in a hash containing +Server+ objects. - If +id+ is set a +Server+ object with the provided ID is returned.
# File lib/pdns_api/client.rb, line 61 def servers(id = nil) return Server.new(@http, self, id) unless id.nil? # Return a hash of server objects servers = @http.get "#{@url}/servers" servers.map! { |s| [s[:id], Server.new(@http, self, s[:id], s)] }.to_h end
Also aliased as: server