This community project provides bindings for the currently latest version of PowerDNS.
- 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)
go get -u github.com/joeig/go-powerdns
import "github.com/joeig/go-powerdns"
headers := make(map[string]string)
headers["X-API-Key"] = "apipw"
pdns := powerdns.NewClient("http://localhost:80", "localhost", headers, nil)
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
.
zones, err := pdns.GetZones()
zone, err := pdns.GetZone("example.com")
export, err := zone.Export()
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()
statistics, err := pdns.GetStatistics()
servers, err := pdns.GetServers()
server, err := pdns.GetServer()
cryptokeys, err := zone.GetCryptokeys()
cryptokey, err := zone.GetCryptokey("1337")
err := cryptokey.ToggleCryptokey()
err := cryptokey.DeleteCryptokey()
See GoDoc.
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