Giter Site home page Giter Site logo

ncode / go-powerdns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeig/go-powerdns

0.0 2.0 0.0 56 KB

Go PowerDNS 4.1 API Client

Home Page: https://godoc.org/github.com/joeig/go-powerdns

License: MIT License

Makefile 0.95% Go 98.06% Shell 1.00%

go-powerdns's Introduction

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"

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.

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.

go-powerdns's People

Contributors

joeig avatar ncode avatar waynz0r avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.