|
| 1 | +// Package libdnstemplate implements a DNS record management client compatible |
| 2 | +// with the libdns interfaces for <PROVIDER NAME>. TODO: This package is a |
| 3 | +// template only. Customize all godocs for actual implementation. |
| 4 | +package libdnstemplate |
| 5 | + |
| 6 | +import ( |
| 7 | + "context" |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/libdns/libdns" |
| 11 | +) |
| 12 | + |
| 13 | +// TODO: Providers must not require additional provisioning steps by the callers; it |
| 14 | +// should work simply by populating a struct and calling methods on it. If your DNS |
| 15 | +// service requires long-lived state or some extra provisioning step, do it implicitly |
| 16 | +// when methods are called; sync.Once can help with this, and/or you can use a |
| 17 | +// sync.(RW)Mutex in your Provider struct to synchronize implicit provisioning. |
| 18 | + |
| 19 | +// Provider facilitates DNS record manipulation with <TODO: PROVIDER NAME>. |
| 20 | +type Provider struct { |
| 21 | + // TODO: put config fields here (with snake_case json |
| 22 | + // struct tags on exported fields), for example: |
| 23 | + APIToken string `json:"api_token,omitempty"` |
| 24 | +} |
| 25 | + |
| 26 | +// GetRecords lists all the records in the zone. |
| 27 | +func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) { |
| 28 | + return nil, fmt.Errorf("TODO: not implemented") |
| 29 | +} |
| 30 | + |
| 31 | +// AppendRecords adds records to the zone. It returns the records that were added. |
| 32 | +func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { |
| 33 | + return nil, fmt.Errorf("TODO: not implemented") |
| 34 | +} |
| 35 | + |
| 36 | +// SetRecords sets the records in the zone, either by updating existing records or creating new ones. |
| 37 | +// It returns the updated records. |
| 38 | +func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { |
| 39 | + return nil, fmt.Errorf("TODO: not implemented") |
| 40 | +} |
| 41 | + |
| 42 | +// DeleteRecords deletes the records from the zone. It returns the records that were deleted. |
| 43 | +func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { |
| 44 | + return nil, fmt.Errorf("TODO: not implemented") |
| 45 | +} |
| 46 | + |
| 47 | +// Interface guards |
| 48 | +var ( |
| 49 | + _ libdns.RecordGetter = (*Provider)(nil) |
| 50 | + _ libdns.RecordAppender = (*Provider)(nil) |
| 51 | + _ libdns.RecordSetter = (*Provider)(nil) |
| 52 | + _ libdns.RecordDeleter = (*Provider)(nil) |
| 53 | +) |
0 commit comments