autodns

package module
v0.0.0-...-a9bfef4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 12 Imported by: 1

README

<autodns> for libdns

Go Reference

This package implements the libdns interfaces for <autodns>, allowing you to manage DNS records.

Example:

package main

import (
	"context"
	"os"
	"log"

	"github.com/libdns/autodns"
)

func main() {
	provider := autodns.Provider{
		Username: os.Getenv("AUTODNS_USERNAME"),
		Password: os.Getenv("AUTODNS_PASSWORD"),
	}

	records, err := provider.GetRecords(context.TODO(), "zone.example.org")
	if err != nil {
		log.Fatalf("unexpected error: %s", err)
	}

	fmt.Printf("%#v", records)
}

As an alternative, configure the provider struct with the following:

Field Description (default) Required
 Username username, empty yes
 Password password, empty yes
 Endpoint https://api.autodns.com/v1 no
 Context 4 no
 HttpClient &http.Client{} no

Documentation

Overview

Helper functions for record conversion

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToLibDNS

func ToLibDNS(zr ZoneRecord) (libdns.Record, error)

ToLibDNS converts an AutoDNS ZoneRecord to a libdns Record

Types

type AutoDNSError

type AutoDNSError struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(messages []*AutoDNSMessage) *AutoDNSError

func (*AutoDNSError) Error

func (m *AutoDNSError) Error() string

func (*AutoDNSError) Messages

func (m *AutoDNSError) Messages() []*AutoDNSMessage

type AutoDNSMessage

type AutoDNSMessage struct {
	Text    string          `json:"text"`
	Objects []AutoDNSObject `json:"objects"`
	Code    string          `json:"code"`
	Status  string          `json:"status"`
}

type AutoDNSObject

type AutoDNSObject struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type AutoDNSResponse

type AutoDNSResponse struct {
	STID string `json:"stid"`

	Status struct {
		Type string  `json:"type"`
		Code *string `json:"resultCode,omitempty"`
		Text *string `json:"text,omitempty"`
	} `json:"status"`

	Object *AutoDNSObject `json:"object,omitempty"`

	// potential error messages
	Messages []*AutoDNSMessage `json:"messages,omitempty"`
}

type AutoDNSUser

type AutoDNSUser struct {
	Context int32  `json:"context"`
	User    string `json:"user"`
}

type Provider

type Provider struct {
	Username   string       `json:"username"`
	Password   string       `json:"password"`
	Endpoint   string       `json:"Endpoint"`
	Context    string       `json:"context"`
	Primary    string       `json:"primary"`
	HttpClient *http.Client `json:"-"`
}

Provider facilitates DNS record manipulation with Autodns.

func NewWithDefaults

func NewWithDefaults(username, password string) *Provider

NewWithDefaults is a convenience method to create the provider with sensible defaults.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords lists all the records in the zone.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

type RequestZone

type RequestZone struct {
	Domain string `json:"domain"`
}

type ResponseSearch

type ResponseSearch struct {
	AutoDNSResponse
	Data []ResponseSearchItem `json:"data"`
}

type ResponseSearchItem

type ResponseSearchItem struct {
	Created     string      `json:"created"`
	Updated     string      `json:"updated"`
	Origin      string      `json:"origin"`
	NSGroup     string      `json:"nameServerGroup"`
	Owner       AutoDNSUser `json:"owner"`
	Updater     AutoDNSUser `json:"updater"`
	DomainSafe  bool        `json:"domainsafe"`
	WWWWInclude bool        `json:"wwwInclude"`
	Nameserver  string      `json:"virtualNameserver"`
}

type ResponseZone

type ResponseZone struct {
	AutoDNSResponse
	Data []ZoneItem `json:"data"`
}

type ZoneItem

type ZoneItem struct {
	Created string `json:"created"`
	Updated string `json:"updated"`
	Origin  string `json:"origin"`

	SOA struct {
		Refresh int    `json:"refresh"`
		Retry   int    `json:"retry"`
		Expire  int    `json:"expire"`
		TTL     int    `json:"ttl"`
		Email   string `json:"email"`
	} `json:"soa"`

	NSGroup    string      `json:"nameServerGroup"`
	Owner      AutoDNSUser `json:"owner"`
	Updater    AutoDNSUser `json:"updater"`
	DomainSafe bool        `json:"domainsafe"`
	PurgeType  string      `json:"purgeType"`

	Nameservers []struct {
		Name string `json:"name"`
	} `json:"nameservers"`

	Main struct {
		Address string `json:"address"`
	} `json:"main"`

	WWWWInclude bool   `json:"wwwInclude"`
	Nameserver  string `json:"virtualNameserver"`
	Action      string `json:"action"`

	Records []ZoneRecord `json:"resourceRecords"`

	ROID int `json:"roid"`
}

type ZoneRecord

type ZoneRecord struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Value string `json:"value"`
	TTL   int    `json:"ttl"`
}

func ToAutoDNS

func ToAutoDNS(record libdns.Record) (ZoneRecord, error)

ToAutoDNS converts a libdns Record to an AutoDNS ZoneRecord

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL