Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.
/ ruby-pdns_api Public archive

Gem for interaction with the PowerDNS HTTP API

License

Notifications You must be signed in to change notification settings

silkeh/ruby-pdns_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 )
            })

About

Gem for interaction with the PowerDNS HTTP API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages