Class: PDNS::Server
Overview
Server object for accessing data for a particular server.
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The ID of the server.
Attributes inherited from API
Instance Method Summary collapse
-
#cache_flush(domain) ⇒ Hash
Flushes cache for a domain.
-
#config(name = nil, value = nil) ⇒ Hash, Config
Returns existing configuration or creates a
Config
object. -
#failures ⇒ Object
Manipulates failure logging.
-
#initialize(http, parent, id, info = {}) ⇒ Server
constructor
Creates a Server object.
-
#overrides(id = nil) ⇒ Hash, Override
(also: #override)
Returns existing or creates an
Override
object. -
#search_log(search_term) ⇒ Hash
Searches through the server’s log with
search_term
. -
#statistics ⇒ Object
Gets the statistics for the server.
-
#trace ⇒ Hash
Retrieves the query tracing log.
-
#trace=(domain_regex) ⇒ Hash
Manipulates the query tracing log.
-
#zones(id = nil) ⇒ Hash, Zone
(also: #zone)
Returns existing or creates a
Zone
object.
Methods inherited from API
#change, #create, #delete, #ensure_array, #get, #info
Constructor Details
#initialize(http, parent, id, info = {}) ⇒ Server
Creates a Server object.
40 41 42 43 44 45 46 47 |
# File 'lib/pdns_api/server.rb', line 40 def initialize(http, parent, id, info = {}) @class = :servers @http = http @parent = parent @id = id @url = "#{parent.url}/#{@class}/#{id}" @info = info end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns the ID of the server.
30 31 32 |
# File 'lib/pdns_api/server.rb', line 30 def id @id end |
Instance Method Details
#cache_flush(domain) ⇒ Hash
Flushes cache for a domain.
55 56 57 |
# File 'lib/pdns_api/server.rb', line 55 def cache_flush(domain) @http.put("#{@url}/cache/flush?domain=#{domain}") end |
#config(name = nil, value = nil) ⇒ Hash, Config
Returns existing configuration or creates a Config
object.
114 115 116 117 118 119 120 121 |
# File 'lib/pdns_api/server.rb', line 114 def config(name = nil, value = nil) return Config.new(@http, self, name, value) unless name.nil? || value.nil? return Config.new(@http, self, name) unless name.nil? # Get all current configuration config = @http.get("#{@url}/config") config.map { |c| [c[:name], c[:value]] }.to_h end |
#failures ⇒ Object
Manipulates failure logging.
99 100 101 |
# File 'lib/pdns_api/server.rb', line 99 def failures # TODO: /servers/:server_id/failures: GET, PUT end |
#overrides(id = nil) ⇒ Hash, Override Also known as: override
Returns existing or creates an Override
object.
133 134 135 136 137 138 |
# File 'lib/pdns_api/server.rb', line 133 def overrides(id = nil) return Override.new(@http, self, id) unless id.nil? overrides = @http.get("#{@url}/config") overrides.map { |o| [o[:id], Override.new(@http, self, o[:id], o)] }.to_h end |
#search_log(search_term) ⇒ Hash
Searches through the server’s log with search_term
.
65 66 67 |
# File 'lib/pdns_api/server.rb', line 65 def search_log(search_term) # TODO: /servers/:server_id/search-log?q=:search_term: GET end |
#statistics ⇒ Object
Gets the statistics for the server.
71 72 73 |
# File 'lib/pdns_api/server.rb', line 71 def statistics # TODO: /servers/:server_id/statistics: GET end |
#trace ⇒ Hash
Retrieves the query tracing log.
93 94 95 |
# File 'lib/pdns_api/server.rb', line 93 def trace @http.get("#{@url}/trace") end |
#trace=(domain_regex) ⇒ Hash
Manipulates the query tracing log.
84 85 86 |
# File 'lib/pdns_api/server.rb', line 84 def trace=(domain_regex) @http.put("#{@url}/trace", domains: domain_regex) end |
#zones(id = nil) ⇒ Hash, Zone Also known as: zone
Returns existing or creates a Zone
object.
150 151 152 153 154 155 |
# File 'lib/pdns_api/server.rb', line 150 def zones(id = nil) return Zone.new(@http, self, id) unless id.nil? zones = @http.get("#{@url}/zones") zones.map { |z| [z[:id], Zone.new(@http, self, z[:id], z)] }.to_h end |