Class: PDNS::Client

Inherits:
API
  • Object
show all
Defined in:
lib/pdns_api/client.rb

Overview

Class for interaction with the top level API.

Instance Attribute Summary collapse

Attributes inherited from API

#class, #url

Instance Method Summary collapse

Methods inherited from API

#create, #delete, #ensure_array, #get, #info

Constructor Details

#initialize(args) ⇒ Client

Creates a Client object.


42
43
44
45
46
47
48
49
# 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

Instance Attribute Details

#versionInteger (readonly)


30
31
32
# File 'lib/pdns_api/client.rb', line 30

def version
  @version
end

Instance Method Details

#changeObject

Disabled common methods


34
# File 'lib/pdns_api/client.rb', line 34

undef_method :change, :create, :delete

#servers(id = nil) ⇒ Hash, Server Also known as: server

Returns existing or creates a Server object.


61
62
63
64
65
66
67
# 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