api

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package api implements protocols to update DNS records.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	// New uses the authentication information to create a Handle.
	New(ctx context.Context, ppfmt pp.PP, cacheExpiration time.Duration) (Handle, bool)
}

An Auth contains authentication information.

type CloudflareAuth

type CloudflareAuth struct {
	Token     string
	AccountID string
	BaseURL   string
}

A CloudflareAuth implements the Auth interface, holding the authentication data to create a CloudflareHandle.

func (*CloudflareAuth) New

func (t *CloudflareAuth) New(ctx context.Context, ppfmt pp.PP, cacheExpiration time.Duration) (Handle, bool)

New creates a CloudflareHandle from the authentication data.

type CloudflareCache added in v1.8.0

type CloudflareCache = struct {
	// contains filtered or unexported fields
}

CloudflareCache holds the previous repsonses from the Cloudflare API.

type CloudflareHandle

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

A CloudflareHandle implements the Handle interface with the Cloudflare API.

func (*CloudflareHandle) ActiveZones

func (h *CloudflareHandle) ActiveZones(ctx context.Context, ppfmt pp.PP, name string) ([]string, bool)

ActiveZones returns a list of zone IDs with the zone name.

func (*CloudflareHandle) CreateRecord

func (h *CloudflareHandle) CreateRecord(ctx context.Context, ppfmt pp.PP,
	domain domain.Domain, ipNet ipnet.Type, ip netip.Addr, ttl TTL, proxied bool,
) (string, bool)

CreateRecord creates one DNS record.

func (*CloudflareHandle) DeleteRecord

func (h *CloudflareHandle) DeleteRecord(ctx context.Context, ppfmt pp.PP,
	domain domain.Domain, ipNet ipnet.Type, id string,
) bool

DeleteRecord deletes one DNS record.

func (*CloudflareHandle) FlushCache

func (h *CloudflareHandle) FlushCache()

FlushCache flushes the API cache.

func (*CloudflareHandle) ListRecords

func (h *CloudflareHandle) ListRecords(ctx context.Context, ppfmt pp.PP,
	domain domain.Domain, ipNet ipnet.Type,
) (map[string]netip.Addr, bool)

ListRecords lists all matching DNS records.

func (*CloudflareHandle) UpdateRecord

func (h *CloudflareHandle) UpdateRecord(ctx context.Context, ppfmt pp.PP,
	domain domain.Domain, ipNet ipnet.Type, id string, ip netip.Addr,
) bool

UpdateRecord updates one DNS record.

func (*CloudflareHandle) ZoneOfDomain

func (h *CloudflareHandle) ZoneOfDomain(ctx context.Context, ppfmt pp.PP, domain domain.Domain) (string, bool)

ZoneOfDomain finds the active zone ID governing a particular domain.

type Handle

type Handle interface {
	// ListRecords lists all matching DNS records.
	ListRecords(ctx context.Context, ppfmt pp.PP, domain domain.Domain, ipNet ipnet.Type) (map[string]netip.Addr, bool)

	// DeleteRecord deletes one DNS record.
	DeleteRecord(ctx context.Context, ppfmt pp.PP, domain domain.Domain, ipNet ipnet.Type, id string) bool

	// UpdateRecord updates one DNS record.
	UpdateRecord(ctx context.Context, ppfmt pp.PP, domain domain.Domain, ipNet ipnet.Type, id string, ip netip.Addr) bool

	// CreateRecord creates one DNS record.
	CreateRecord(ctx context.Context, ppfmt pp.PP, domain domain.Domain, ipNet ipnet.Type,
		ip netip.Addr, ttl TTL, proxied bool) (string, bool)

	// FlushCache flushes the API cache. Flushing should automatically happen when other operations encounter errors.
	FlushCache()
}

A Handle represents a generic API to update DNS records. Currently, the only implementation is Cloudflare.

type TTL

type TTL int

A TTL represents a time-to-live value of a DNS record.

const TTLAuto TTL = 1

TTLAuto represents the "auto" value for Cloudflare servers.

func (TTL) Describe

func (t TTL) Describe() string

Describe converts a TTL into a human-readable, user-friendly description that is suitable for printing.

func (TTL) Int

func (t TTL) Int() int

Int converts a TTL into its raw integer value.

func (TTL) String

func (t TTL) String() string

String converts a TTL into the string representation of its raw integer value.

Jump to

Keyboard shortcuts

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