Skip to content

libdns/njalla

Repository files navigation

Njalla for libdns

Go Reference

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

Configuration

To use this provider, you'll need to obtain an API token from Njalla. You can generate an API token from your Njalla account settings.

Example

package main

import (
	"context"
	"fmt"
	"net/netip"
	"time"

	"github.com/libdns/libdns"
	"github.com/libdns/njalla"
)

func main() {
	// Create the provider
	provider := njalla.Provider{
		APIToken: "your-njalla-api-token",
	}

	// Define your zone
	zone := "example.com"

	// Add a record
	records, err := provider.AppendRecords(context.TODO(), zone, []libdns.Record{
		libdns.Address{
			Name: "test",
			IP:   netip.MustParseAddr("192.0.2.1"),
			TTL:  time.Hour,
		},
	})
	if err != nil {
		fmt.Printf("Error adding record: %v\n", err)
		return
	}
	fmt.Printf("Records added: %v\n", records)

	// Get all records
	allRecords, err := provider.GetRecords(context.TODO(), zone)
	if err != nil {
		fmt.Printf("Error getting records: %v\n", err)
		return
	}
	fmt.Printf("All records: %v\n", allRecords)

	// Delete records
	deletedRecords, err := provider.DeleteRecords(context.TODO(), zone, records)
	if err != nil {
		fmt.Printf("Error deleting records: %v\n", err)
		return
	}
	fmt.Printf("Deleted records: %v\n", deletedRecords)
}

Caveats

  • This provider is compatible with libdns v1.1.0 and follows the updated interfaces that use the new Record type system.
  • The following record types are fully supported: A, AAAA, CNAME, TXT, MX, SRV
  • Other record types are supported using the generic RR structure.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages