Skip to content

libdns/netcup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Netcup provider implementation for libdns

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages