class Fog::DNS::PowerDNS::Real
Public Class Methods
# File lib/fog/powerdns/dns.rb, line 37 def initialize(options={}) @pdns_api_key = options[:pdns_api_key] @connection_options = options[:connection_options] || {} @host = options[:host] || "127.0.0.1" @persistent = options[:persistent]|| false @port = options[:port] || 8081 @scheme = options[:scheme] || 'http' puts @api_key puts @persistent puts @connection_options puts @scheme puts @host puts @port @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Public Instance Methods
Create a single zone in PowerDNS Server, name and nameservers LIST are required
Parameters¶ ↑
-
server<~String> - Server ID
-
name<~String> - Name of domain
-
nameservers<~Array> - List of nameservers
-
options<~Hash> - Other options
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
status<~Integer> 201 when successful
-
# File lib/fog/powerdns/requests/dns/create_zone.rb, line 39 def create_zone(server, name, nameservers, options = {}) body = { "name" => name, "nameservers" => nameservers } options.each { |option, value| body[option] = value; } request( :body => Fog::JSON.encode(body), :expects => 201, :method => 'POST', :path => "/servers/#{server}/zones" ).body end
Parameters¶ ↑
-
server<~String> - server id
-
zone<~String> - zone id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
status<~Integer> - 204 when successful
-
# File lib/fog/powerdns/requests/dns/delete_zone.rb, line 19 def delete_zone(server, zone) request( :expects => 204, :method => 'DELETE', :path => "/servers/#{server}/zones/#{zone}" ) end
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'type': <~String>,
-
'id': <~Integer>,
-
'active': <~Boolean>,
-
'keytype': <~String>,
-
'dnskey': <~String>,
-
'content': <~String>,
-
'ds': <~Array>
-
-
status<~Integer> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/get_cryptokey.rb, line 26 def get_cryptokey(server, zone, cryptokey) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/zones/#{zone}/cryptokeys/#{cryptokey}" ).body end
Get details of a DNS server
Parameters¶ ↑
-
server<~String> - server id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'type': <~String>,
-
'id': <~String>,
-
'url': <~String>,
-
'daemon_type': <~String>,
-
'version': <~String>,
-
'config_url': <~String>,
-
'zones_url': <~String>,
-
-
status<~String> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/get_server.rb, line 22 def get_server(server) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}" ).body end
Get a specific config setting of one server TODO: Can only get / retrieve recursor's allow_from
Parameters¶ ↑
-
server<~String> - server id
-
config<~String> - config name
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'type': <~String>,
-
'name': <~String>,
-
'value': <~String>
-
-
status<~String> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/get_server_config.rb, line 20 def get_server_config(server, config) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/config/#{config}" ).body end
Retrieves server stats
Parameters¶ ↑
-
server<~String> - server id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Array>:
* statistics<~Hash>: * 'type': <~String>, * 'name': <~String>, * 'value': <~String>
-
status<~Integer> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/get_server_stats.rb, line 19 def get_server_stats(server) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/statistics" ).body end
Get details of a DNS zone
Parameters¶ ↑
-
zone<~String> - Zone id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
status<~Integer> 200 when successful
-
# File lib/fog/powerdns/requests/dns/get_zone.rb, line 35 def get_zone(server, zone) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/zones/#{zone}" ).body end
Get details of all public cryptokeys
Parameters¶ ↑
server<~String> - server id zone<~String> - zone id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Array>:
* Cryptokey<~Hash>: * 'type': <~String>, * 'id': <~Integer>, * 'active': <~Boolean>, * 'keytype': <~String>, * 'dnskey': <~String>, * 'content': <~String>, * 'ds': <~Array>
-
status<~Integer> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/list_cryptokeys.rb, line 25 def list_cryptokeys(server, zone) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/zones/#{zone}/cryptokeys" ).body end
Get all of a DNS server's config settings
Parameters¶ ↑
-
server<~String> - server id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Array>:
* Config<~Hash>: * 'type': <~String>, * 'name': <~String>, * 'value': <~String>
-
status<~String> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/list_server_configs.rb, line 19 def list_server_configs(server) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/config" ).body end
Get details of all powerdns servers
Parameters¶ ↑
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
server<~Array>:
-
'type': <~String>,
-
'id': <~String>,
-
'url': <~String>,
-
'daemon_type': <~String>,
-
'version': <~String>,
-
'config_url': <~String>,
-
'zones_url': <~String>,
-
-
-
status<~String> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/list_servers.rb, line 23 def list_servers request( :expects => 200, :method => 'GET', :path => "/servers" ).body end
Get details of a server's DNS zones
Parameters¶ ↑
-
server<~String> - server id
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
zone<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
-
status<~Integer> 200 when successful
-
# File lib/fog/powerdns/requests/dns/list_zones.rb, line 36 def list_zones(server) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/zones" ).body end
DNS Notify all slaves of the zone Authoritative only, zone must be set up as master or slave (fails otherwise)
Parameters¶ ↑
-
server<~String> - server id
-
zone<~String> - zone name
Returns¶ ↑
TODO: Untested
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
status<~Integer> 200 when successful
-
# File lib/fog/powerdns/requests/dns/notify_zone.rb, line 39 def notify_zone(server, zone) request( :expects => 200, :method => 'PUT', :path => "/servers/#{server}/zones/#{zone}/notify" ) end
# File lib/fog/powerdns/dns.rb, line 54 def reload @connection.reset end
# File lib/fog/powerdns/dns.rb, line 58 def request(params) params[:headers] ||= {} params[:headers].merge!("X-API-key" => "#{@pdns_api_key}") params[:headers].merge!( "Accept" => "application/json", "Content-Type" => "application/json" ) response = @connection.request(params) unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end
Retrieves master Authoritative only, zone must be set up as slave (fails otherwise)
Parameters¶ ↑
-
server<~String> - server id
-
zone<~String> - zone name
Returns¶ ↑
TODO: Untested
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
status<~Integer> 201 when successful
-
# File lib/fog/powerdns/requests/dns/retrieve_zone.rb, line 39 def retrieve_zone(server, zone) request( :expects => 200, :method => 'PUT', :path => "/servers/#{server}/zones/#{zone}/axfr-retrieve" ) end
Searches for term in server logs
Parameters¶ ↑
-
server<~String> - server id
-
term<~String> - search term
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Array>:
-
log-line<~String>
-
-
status<~Integer> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/search_log.rb, line 17 def search_log(server, term) request( :expects => 200, :method => 'GET', :path => "/servers/#{server}/search-log?q=#{term}" ).body end
Modify existing RRset's of a zone
Parameters¶ ↑
server<~String> - server id zone<~String> - zone id options<~Hash> - see pdns api for rules
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'rrsets'<~Hash> The representation of the rrsets:
-
'name': <~String>,
-
'type': <~String>,
-
'changetype': <~String>,
-
'records' <~Hash> domain records:
-
'content': <~String>,
-
'name': <~String>,
-
'ttl': <~Integer>,
-
'type': <~String>,
-
'disabled': <~Boolean>,
-
'set-ptr': <~Boolean>
-
-
'comments' <~Hash> comments:
-
'account': <~String>,
-
'content': <~String>,
-
'modfied_at': <~Integer>
-
-
-
-
# File lib/fog/powerdns/requests/dns/update_rrsets.rb, line 32 def update_rrsets(server, zone, options = {}) options.each { |option, value| body[option] = value; } request( :body => Fog::JSON.encode(body), :expects => 200, :method => 'PATCH', :path => "/servers/#{server}/zones/#{zone}/" ) end
Update a specific config setting of one server TODO: Can only get / retrieve recursor's allow_from
Parameters¶ ↑
-
server<~String> - server id
-
config<~String> - config name
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'type': <~String>,
-
'name': <~String>,
-
'value': <~String>
-
-
status<~String> - 200 when successful
-
# File lib/fog/powerdns/requests/dns/update_server_config.rb, line 20 def update_server_config(server, config, body) if config == 'allows_from' request( :body => body, :expects => 200, :method => 'PUT', :path => "/servers/#{server}/config/#{config}" ).body else puts 'Only allows_from config is allowed.' end end
Modify a single zone in PowerDNS
Parameters¶ ↑
server<~String> - server id zone<~String> - zone id options<~Hash> - pairs enumerated below
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id': <~String>,
-
“name”: <~String>,
-
'type': <~String>,
-
'url': <~String>,
-
'kind': <~String>,
-
'serial': <~Integer>,
-
'notified_serial': <~Int>,
-
'masters': <~Array,
-
'dnssec': <~Boolean>,
-
'nsec3param': <~String>,
-
'nsec3narrow': <~Boolean>,
-
'presigned': <~Boolean>,
-
'soa_edit': '<~String>',
-
'soa_edit_api': '<~String>',
-
'account': '<~String>',
-
'nameservers': <~Array>,
-
'servers': <~Array>,
-
'recursion_desired': <~Boolean>,
-
'records': <~Array>,
-
'comments': <~Array>,
-
-
status<~Integer> 200 when successful
-
# File lib/fog/powerdns/requests/dns/update_zone.rb, line 38 def update_zone(server, zone, options = {}) options.each { |option, value| body[option] = value; } request( :body => Fog::JSON.encode(body), :expects => 200, :method => 'PUT', :path => "/servers/#{server}/zones/#{zone}" ).body end