class Fog::DNS::PowerDNS::Real
Public Class Methods
# File lib/fog/dns/powerdns.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' @api_version = options[:api_version] || 'v1' @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/dns/powerdns/requests/create_zone.rb, line 41 def create_zone(server, name, nameservers, options = {}) body = { 'name' => name, 'nameservers' => nameservers } options.each do |option, value| body[option] = value end request( body: Fog::JSON.encode(body), expects: 201, method: 'POST', path: "/api/#{@api_version}/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/dns/powerdns/requests/delete_zone.rb, line 21 def delete_zone(server, zone) request( expects: 204, method: 'DELETE', path: "/api/#{@api_version}/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/dns/powerdns/requests/get_cryptokey.rb, line 28 def get_cryptokey(server, zone, cryptokey) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/get_server.rb, line 24 def get_server(server) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/get_server_config.rb, line 22 def get_server_config(server, config) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/get_server_stats.rb, line 21 def get_server_stats(server) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/get_zone.rb, line 37 def get_zone(server, zone) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/list_cryptokeys.rb, line 27 def list_cryptokeys(server, zone) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/list_server_configs.rb, line 21 def list_server_configs(server) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/list_servers.rb, line 25 def list_servers request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/list_zones.rb, line 38 def list_zones(server) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/notify_zone.rb, line 41 def notify_zone(server, zone) request( expects: 200, method: 'PUT', path: "/api/#{@api_version}/servers/#{server}/zones/#{zone}/notify" ) end
# File lib/fog/dns/powerdns.rb, line 49 def reload @connection.reset end
# File lib/fog/dns/powerdns.rb, line 53 def request(params) params[:headers] ||= {} params[:headers]['X-API-key'] = @pdns_api_key.to_s params[:headers].merge!( 'Accept' => 'application/json', 'Content-Type' => 'application/json' ) response = @connection.request(params) response.body = Fog::JSON.decode(response.body) unless response.body.empty? 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/dns/powerdns/requests/retrieve_zone.rb, line 41 def retrieve_zone(server, zone) request( expects: 200, method: 'PUT', path: "/api/#{@api_version}/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/dns/powerdns/requests/search_log.rb, line 19 def search_log(server, term) request( expects: 200, method: 'GET', path: "/api/#{@api_version}/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/dns/powerdns/requests/update_rrsets.rb, line 33 def update_rrsets(server, zone, options = {}) body = {} options.each do |option, value| body[option] = value end request( body: Fog::JSON.encode(body), expects: 204, method: 'PATCH', path: "/api/#{@api_version}/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/dns/powerdns/requests/update_server_config.rb, line 22 def update_server_config(server, config, body) if config == 'allows_from' request( body: body, expects: 200, method: 'PUT', path: "/api/#{@api_version}/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/dns/powerdns/requests/update_zone.rb, line 40 def update_zone(server, zone, options = {}) body = {} options.each do |option, value| body[option] = value end request( body: Fog::JSON.encode(body), expects: 200, method: 'PUT', path: "/api/#{@api_version}/servers/#{server}/zones/#{zone}" ).body end