Go PowerDNS 4.1 API Client
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
scripts
vendor
.travis.yml
Gopkg.lock Bump dependencies Aug 18, 2018
Gopkg.toml
LICENSE MIT License Oct 12, 2018
Makefile PowerDNS API mocks Jul 17, 2018
README.md
cryptokeys.go
cryptokeys_test.go Documentation of exported types and methods Sep 8, 2018
docker-compose.yml
powerdns.go
powerdns_test.go
servers.go
servers_test.go
statistics.go
statistics_test.go
zones.go
zones_test.go Documentation of exported types and methods Sep 8, 2018

README.md

PowerDNS 4.1 API bindings for Golang

This community project provides bindings for the currently latest version of PowerDNS.

Build Status Go Report Card

Setup

Requirements

  • PowerDNS 4.1 ("API v1")
    • --webserver=yes --api=yes --api-key=apipw --api-readonly=no
    • Note that API v1 is actively maintained. There are differences between 3.x, 4.0 and 4.1 and this client works only with 4.1.
  • Go 1.10/1.11 (should work with other minor releases as well)

Install from source

go get -u github.com/joeig/go-powerdns

Usage

Initialize the handle

import "github.com/joeig/go-powerdns"

pdns := powerdns.NewClient("http://localhost:80", "localhost", "apipw")

Assuming that the server is listening on http://localhost:80 for virtual host localhost, the API password is apipw and you want to edit the domain example.com.

Request zone data

zones, err := pdns.GetZones()
zone, err := pdns.GetZone("example.com")
export, err := zone.Export()

Add/change/delete resource records

err := zone.AddRecord("www.example.com", "AAAA", 60, []string{"::1"})
err := zone.ChangeRecord("www.example.com", "AAAA", 3600, []string{"::1"})
err := zone.DeleteRecord("www.example.com", "A")
notifyResult, err := zone.Notify()

Request server information and statistics

statistics, err := pdns.GetStatistics()
servers, err := pdns.GetServers()
server, err := pdns.GetServer()

Handle DNSSEC cryptographic material

cryptokeys, err := zone.GetCryptokeys()
cryptokey, err := zone.GetCryptokey("1337")
err := cryptokey.ToggleCryptokey()
err := cryptokey.DeleteCryptokey()

Documentation

See GoDoc.

Contribution

This API client has not been completed yet, so feel free to contribute. The OpenAPI specification might be a good reference.

Start a PowerDNS authoritative server including a generic MySQL backend, DNSSEC support and some fixtures using Docker compose:

docker-compose up
docker-compose exec powerdns sh init_docker_fixtures.sh

Based on the work of jgreat and waynz0r.