This package contains a Go library for accessing the PowerDNS Authoritative API.
- Servers
- Zones
- Cryptokeys
- Metadata
- TSIG Keys
- Searching
- Statistics
- Cache
Install using go get:
> go get github.com/mittwald/go-powerdnsFirst, instantiate a client using pdns.New:
client, err := pdns.New( pdns.WithBaseURL("http://localhost:8081"), pdns.WithAPIKeyAuthentication("supersecret"), )The client then offers more specialiced sub-clients, for example for managing server and zones. Have a look at this library's documentation for more information.
package main import "context" import "github.com/mittwald/go-powerdns" import "github.com/mittwald/go-powerdns/apis/zones" func main() { client, err := pdns.New( pdns.WithBaseURL("http://localhost:8081"), pdns.WithAPIKeyAuthentication("supersecret"), ) if err != nil { panic(err) } client.Zones().CreateZone(context.Background(), "localhost", zones.Zone{ Name: "mydomain.example.", Type: zones.ZoneTypeZone, Kind: zones.ZoneKindNative, Nameservers: []string{ "ns1.example.com.", "ns2.example.com.", }, ResourceRecordSets: []zones.ResourceRecordSet{ {Name: "foo.mydomain.example.", Type: "A", TTL: 60, Records: []zones.Record{{Content: "127.0.0.1"}}}, }, }) }