hosttech

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 10 Imported by: 1

README

hosttech for libdns

Go Reference

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

Example Use

See for an example here.

Constraints

Some constraints.

Supported record types

Because the Hosttech API does not provide a way to manipulate a generic "Type,Name,Value"-Record, not every type of record can be set. Currently supported are:

  • AAAA
  • A
  • NS
  • CNAME
  • MX
  • TXT
  • TLSA

Any unsupported record types returns an error.

Minimal TTL

The Time-to-Life has to be at least 600 seconds, anything below that will be rejected by the API

Further documentation

Any further documentation that could be helpful:

Documentation

Overview

Package hosttech implements methods for manipulating Hosttech.ch DNS records with the libdns interfaces. Manipulation is achieved with the Hosttech API at https://api.ns1.hosttech.eu/api/documentation/#/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveTrailingDot added in v1.0.3

func RemoveTrailingDot(input string) string

Types

type AAAARecord

type AAAARecord struct {
	Base
	Name string `json:"name,omitempty"`
	IPV6 string `json:"ipv6,omitempty"`
}

AAAARecord is an implementation of the AAAA record type

type ARecord

type ARecord struct {
	Base
	Name string `json:"name,omitempty"`
	IPV4 string `json:"ipv4,omitempty"`
}

ARecord is an implementation of the A record type

type ApiError

type ApiError struct {
	ErrorCode int
	// contains filtered or unexported fields
}

func (ApiError) Error

func (a ApiError) Error() string

type Base

type Base struct {
	Id      int    `json:"id,omitempty"`
	Type    string `json:"type,omitempty"`
	TTL     int    `json:"ttl,omitempty"`
	Comment string `json:"comment,omitempty"`
}

Base holds all the values that are present in each record

type CNAMERecord

type CNAMERecord struct {
	Base
	Name  string `json:"name,omitempty"`
	Cname string `json:"cname,omitempty"`
}

CNAMERecord is an implementation of the CNAME record type

type HosttechListResponseWrapper

type HosttechListResponseWrapper struct {
	Data []HosttechRecordWrapper `json:"data"`
}

type HosttechRecord

type HosttechRecord interface {
	// contains filtered or unexported methods
}

HosttechRecord must be implemented by each different type of record representation from the Hosttech.ch API, to allow a transformation from and to libdns.record.

func LibdnsRecordToHosttechRecordWrapper

func LibdnsRecordToHosttechRecordWrapper(record libdns.Record) (HosttechRecord, error)

type HosttechRecordWrapper

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

func (*HosttechRecordWrapper) UnmarshalJSON

func (h *HosttechRecordWrapper) UnmarshalJSON(b []byte) error

type HosttechSingleResponseWrapper

type HosttechSingleResponseWrapper struct {
	Data HosttechRecordWrapper `json:"data"`
}

type HosttechZone added in v1.0.4

type HosttechZone struct {
	Id          uint   `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Email       string `json:"email,omitempty"`
	TTL         uint32 `json:"ttl,omitempty"`
	Nameserver  string `json:"nameserver,omitempty"`
	DNSSEC      bool   `json:"dnssec,omitempty"`
	DNSSECEmail string `json:"dnssec_email,omitempty"`
}

HosttechZone is an implementation of the zone without records

type HosttechZoneListResponseWrapper added in v1.0.4

type HosttechZoneListResponseWrapper struct {
	Data []HosttechZone `json:"data"`
}

type MXRecord

type MXRecord struct {
	Base
	Name      string `json:"name,omitempty"`
	OwnerName string `json:"ownername,omitempty"`
	Pref      uint   `json:"pref,omitempty"`
}

MXRecord is an implementation of the MX record type

type NSRecord

type NSRecord struct {
	Base
	OwnerName  string `json:"ownername,omitempty"`
	TargetName string `json:"targetname,omitempty"`
}

NSRecord is an implementation of the NS record type

type Provider

type Provider struct {
	APIToken string `json:"api_token,omitempty"`
}

Provider facilitates DNS record manipulation with Hosttech.ch.

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 all records that were added. If an error occurs while records are being added, the already successfully added records will be returned along with an error.

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. If an error occurs while records are being deleted, the already successfully deleted records will be returned along with an error.

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) ListZones added in v1.0.4

func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)

List all available zones

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 TLSARecord

type TLSARecord struct {
	Base
	Name string `json:"name,omitempty"`
	Text string `json:"text,omitempty"`
}

TLSARecord is an implementation of the TLSA record type

type TXTRecord

type TXTRecord struct {
	Base
	Name string `json:"name,omitempty"`
	Text string `json:"text,omitempty"`
}

TXTRecord is an implementation of the TXT record type

Jump to

Keyboard shortcuts

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