Project

pdns_api

0.02
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A gem for manipulation of DNS through the PowerDNS API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Ruby PowerDNS API interface

Gem Version Build Status Inline docs Documentation

A ruby client for version 0 and 1 of the PowerDNS HTTP API.

Installation

Install like any ruby gem:

gem install pdns_api

Or add the following to your Gemfile:

gem 'pdns_api'

Usage

For any action, an instance of PDNS::Client is required with the proper credentials:

require 'pdns_api'

pdns = PDNS::Client.new(
  host:    'ns0.example.com',
  port:    8081,
  key:     'secret',
  version: 1
)

port and version are optional and default to 8081 and 1 respectively.

From here a list of servers can be requested with:

servers = pdns.servers

Or a zone can be requested from the localhost server:

zone = pdns.servers('localhost').zone('example.com')

Example

This example connect to a server, creates a zone (example.com), and adds two records.

require 'pdns_api'

pdns = PDNS::Client.new(
  host:    'ns0.example.com',
  key:     'secret',
  version: 1
)

zone = pdns.server('localhost').zone('example.com.')
zone.create(
  name: zone.id,
  kind: 'Native',
  dnssec: true,
  nameservers: %w( ns0.example.com. ns1.example.com. )
)
zone.update({
              name: 'www.example.com.',
              type: 'AAAA',
              ttl:  86400,
              records: '2001:db8::1'
            }, {
              name: 'mail.example.com.',
              type: 'AAAA',
              ttl:  2880,
              records: %w( 2001:db8::1 2001:db8:cff::1 )
            })