Documentation
¶
Overview ¶
Package hosterby implements a DNS record management client compatible with the libdns interfaces for hoster.by.
Authentication ¶
The provider authenticates with an access key and a secret key, which can be issued in the hoster.by control panel. Short-lived access tokens are created from them and renewed automatically.
Record sets ¶
The API manages record sets (RRsets): all records of the same name and type are written together and share one TTL. Consequently:
- Appending or deleting a record rewrites its record set. This is serialized within a Provider value, but not across clients.
- Each record set is written with a separate request, so a failed call may leave the record sets written before the failure changed.
- Appending to an existing record set keeps its TTL. Within a call, the first TTL given for a record set is used.
- TTLs are clamped to the API range of 10 minutes to 7 days, and records without a TTL get 10 minutes.
- Disabled records are hidden from Provider.GetRecords and preserved by Append and Delete. Appending a disabled record enables it.
Record types ¶
Provider.GetRecords returns all types. Only A, AAAA, ALIAS, CAA, CNAME, MX, NS, SRV and TXT records can be written.
Index ¶
- type Provider
- func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)
- func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)
- func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// AccessKey is the access key of the API service account.
AccessKey string `json:"access_key,omitempty"`
// SecretKey is the secret key of the API service account.
SecretKey string `json:"secret_key,omitempty"`
// BaseURL overrides the default API endpoint, https://serviceapi.hoster.by.
BaseURL string `json:"base_url,omitempty"`
// HTTPClient overrides the default HTTP client, which has a 30 second
// timeout.
HTTPClient *http.Client `json:"-"`
// contains filtered or unexported fields
}
Provider facilitates DNS record manipulation with hoster.by.
func (*Provider) AppendRecords ¶
func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
AppendRecords adds records to the zone and returns the added ones. Records that already exist are skipped.
func (*Provider) DeleteRecords ¶
func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
DeleteRecords deletes matching records from the zone and returns them. An empty type, TTL or data matches any value. TTLs are clamped to the API range before comparison.
func (*Provider) GetRecords ¶
GetRecords lists all the records in the zone.
func (*Provider) ListZones ¶
ListZones lists the zones of the account, with internationalized names in Punycode.
func (*Provider) SetRecords ¶
func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
SetRecords makes the input records the only records of their (name, type) pairs in the zone, replacing all others, including disabled ones. It returns the records that were set.