hetzner

package
v0.0.0-...-3cdddeb Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

README

hetzner

Client library for Hetzner DNS API.

API docs: https://dns.hetzner.com/api-docs/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAPIKey          = errors.New("no API key found in request")
	ErrInvalidAPIKey     = errors.New("invalid authentication credentials")
	ErrZoneNotFound      = errors.New("zone not found")
	ErrInvalidArgument   = errors.New("invalid argument")
	ErrInvalidARecord    = errors.New("invalid A record")
	ErrInvalidAAAARecord = errors.New("invalid AAAA record")
)
View Source
var (
	BaseURL = "https://dns.hetzner.com/api/v1"
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(key string) *Client

Return a new Client without timeout.

func NewClientWithTimeout

func NewClientWithTimeout(key string, timeout time.Duration) *Client

Return a new Client with specified timeout.

func (*Client) CreateRecord

func (c *Client) CreateRecord(name string, ttl int, t string, value string, zone string) (Record, error)

CreateRecord creates a new record. Valid t types are: "A", "AAAA", "NS", "MX", "CNAME", "RP", "TXT", "SOA", "HINFO", "SRV", "DANE", "TLSA", "DS" and "CAA".

func (*Client) DeleteRecord

func (c *Client) DeleteRecord(id string) error

DeleteRecord deletes a record with id id.

func (*Client) GetAllRecords

func (c *Client) GetAllRecords() ([]Record, error)

GetAllRecords returns all records associated with user.

func (*Client) GetAllRecordsByZone

func (c *Client) GetAllRecordsByZone(zone string) ([]Record, error)

GetAllRecordsByZone returns all records associated with user from zone zone.

func (*Client) GetAllZones

func (c *Client) GetAllZones() ([]Zone, error)

GetAllZones returns every zones associated with the user.

func (*Client) GetZoneByName

func (c *Client) GetZoneByName(name string) (Zone, error)

GetZoneByName returns the zone associated with the user with name name.

type Meta

type Meta struct {
	Pagination Pagination `json:"pagination"`
}

type Pagination

type Pagination struct {
	Page         int `json:"page"`
	PerPage      int `json:"per_page"`
	LastPage     int `json:"last_page"`
	TotalEntries int `json:"total_entries"`
}

type Record

type Record struct {
	Type     string
	ID       string
	Created  string
	Modified string
	ZoneID   string `json:"zone_id"`
	Name     string
	Value    string
	TTL      int
}

type Records

type Records struct {
	Records []Record
}

type TXTVerification

type TXTVerification struct {
	Name  string `json:"name"`
	Token string `json:"token"`
}

type Zone

type Zone struct {
	ID              string          `json:"id"`
	Created         string          `json:"created"`
	Modified        string          `json:"modified"`
	LegacyDNSHost   string          `json:"legacy_dns_host"`
	LegacyNS        []string        `json:"legacy_ns"`
	Name            string          `json:"name"`
	NS              []string        `json:"ns"`
	Owner           string          `json:"owner"`
	Paused          bool            `json:"paused"`
	Permission      string          `json:"permission"`
	Project         string          `json:"project"`
	Registrar       string          `json:"registrar"`
	Status          string          `json:"status"`
	TTL             int             `json:"ttl"`
	Verified        string          `json:"verified"`
	RecordsCount    int             `json:"records_count"`
	IsSecondaryDNS  bool            `json:"is_secondary_dns"`
	TXTVerification TXTVerification `json:"txt_verification"`
}

type Zones

type Zones struct {
	Zones []Zone `json:"zones"`
	Meta  Meta   `json:"meta"`
}

Jump to

Keyboard shortcuts

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