Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.53 KB

README.md

File metadata and controls

45 lines (34 loc) · 1.53 KB

netcup for libdns

Go Reference

This package implements the libdns interfaces for the netcup DNS API, allowing you to manage DNS records.

Configuration

The provider is configured by instantiating the netcup.Provider with the customer number, the API key and the API password for the DNS API obtained from netcup (guide). Here is a minimal working example to get all DNS records using environment variables for the credentials:

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/netcup"
)

func main() {
	provider := netcup.Provider{
		CustomerNumber: os.Getenv("LIBDNS_NETCUP_CUSTOMER_NUMBER"),
		APIKey:         os.Getenv("LIBDNS_NETCUP_API_KEY"),
		APIPassword:    os.Getenv("LIBDNS_NETCUP_API_PASSWORD"),
	}
	ctx := context.TODO()
	zone := os.Getenv("LIBDNS_NETCUP_ZONE")

	records, err := provider.GetRecords(ctx, zone)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	for _, record := range records {
		fmt.Printf("%+v\n", record)
	}
}

Usage

⚠️ The netcup API does not offer setting the TTL for individual records.

Updating and deleting records can be done by either filling all struct fields of the dnsRecord, including the ID, or just Name and Type (+ Priority for MX records). Then the first record matching these criteria is updated/deleted.