Class: PDNS::Server
Overview
PDNS Server
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from API
Instance Method Summary collapse
-
#cache(domain) ⇒ Object
Server actions.
-
#config(name = nil, value = nil) ⇒ Object
Get or set server config.
- #failures ⇒ Object
-
#initialize(http, parent, id, info = {}) ⇒ Server
constructor
A new instance of Server.
-
#overrides(id = nil) ⇒ Object
(also: #override)
Get or set server overrides, not yet implemented.
- #search_log(search_term) ⇒ Object
- #statistics ⇒ Object
- #trace ⇒ Object
-
#zones(zone_id = nil) ⇒ Object
(also: #zone)
Get zones or create one.
Methods inherited from API
#create, #delete, #ensure_array, #get, hash_string_to_sym, hash_sym_to_string, #info
Constructor Details
#initialize(http, parent, id, info = {}) ⇒ Server
Returns a new instance of Server.
11 12 13 14 15 16 17 18 |
# File 'lib/pdns_api/server.rb', line 11 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 ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/pdns_api/server.rb', line 9 def id @id end |
Instance Method Details
#cache(domain) ⇒ Object
Server actions
25 26 27 |
# File 'lib/pdns_api/server.rb', line 25 def cache(domain) # TODO: #{url}/cache/flush?domain=:domain: PUT end |
#config(name = nil, value = nil) ⇒ Object
Get or set server config
48 49 50 51 52 53 54 55 |
# File 'lib/pdns_api/server.rb', line 48 def config(name = nil, value = nil) return Config.new(@http, self, name, value).create 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
41 42 43 |
# File 'lib/pdns_api/server.rb', line 41 def failures # TODO: /servers/:server_id/failures: GET, PUT end |
#overrides(id = nil) ⇒ Object Also known as: override
Get or set server overrides, not yet implemented
58 59 60 61 62 63 |
# File 'lib/pdns_api/server.rb', line 58 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) ⇒ Object
29 30 31 |
# File 'lib/pdns_api/server.rb', line 29 def search_log(search_term) # TODO: /servers/:server_id/search-log?q=:search_term: GET end |
#statistics ⇒ Object
33 34 35 |
# File 'lib/pdns_api/server.rb', line 33 def statistics # TODO: /servers/:server_id/statistics: GET end |
#trace ⇒ Object
37 38 39 |
# File 'lib/pdns_api/server.rb', line 37 def trace # TODO: /servers/:server_id/trace: GET, PUT end |
#zones(zone_id = nil) ⇒ Object Also known as: zone
Get zones or create one
66 67 68 69 70 71 |
# File 'lib/pdns_api/server.rb', line 66 def zones(zone_id = nil) return Zone.new(@http, self, zone_id) unless zone_id.nil? zones = @http.get("#{@url}/zones") zones.map { |z| [z[:id], Zone.new(@http, self, z[:id], z)] }.to_h end |