Documentation
¶
Overview ¶
Package liara implements a DNS record management client compatible with the libdns interfaces for Liara.
Index ¶
- type APIError
- type APIRecord
- type APIRecordContent
- type GetRecordsResponse
- type PostRecordResponse
- 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) 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 APIError ¶
type APIError struct {
StatusCode int `json:"statusCode"`
StatusMessage string `json:"error"`
ErrorMessage string `json:"message"`
}
The generic api error schema of Liara's dns api. E.x. StatusCode: 400 StatusMessage: "Bad Request" ErrorMessage: "invalid record type."
type APIRecord ¶
type APIRecord struct {
// omitting the "id" field is a requirement in PUT operations.
ID string `json:"id,omitempty"`
Name string `json:"name"`
Type string `json:"type"` // A, AAAA, CNAME, MX, SRV, TXT
TTL int `json:"ttl"`
Contents []APIRecordContent `json:"contents"`
}
func APIRecordContains ¶
func ToLiaraAPIRecords ¶
turns a flat []libdns.Record into Liara's []APIRecord, where records with the same name + type can possibly share one APIRecord with multiple contents.
func (APIRecord) ToLibdnsRRType ¶
Converts the Liara specific "APIRecord" type to an appropriate, concrete RR type struct in libdns(the types are in the file "rrtypes.go").
It returns an slice(mostly a single item slice), because an APIRecord can consist of multiple "Contents" which doesn't fit into a single libdns type.
type APIRecordContent ¶
type APIRecordContent struct {
IP string `json:"ip,omitempty"`
// Relevant to the CNAME record type
Host string `json:"host,omitempty"`
// Relevant to the MX And Srv record types.
Priority uint16 `json:"priority,omitempty"`
Weight uint16 `json:"weight,omitempty"`
Port uint16 `json:"port,omitempty"`
// Relevant to the TXT record types.
Text string `json:"text,omitempty"`
}
func RemainingContent ¶
func RemainingContent( existing []APIRecordContent, recordsToRemove []APIRecordContent, ) []APIRecordContent
Differentiates Remaining content in "APIRecord.Content". Takes the existing APIRecord.Contents and removes the contents that the user asked to delete.
type GetRecordsResponse ¶
type PostRecordResponse ¶
Liara's response model. The same model is also used for its PUT operation.
type Provider ¶
type Provider struct {
APIToken string `json:"api_token,omitempty"`
}
Provider facilitates DNS record manipulation with Liara
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 the records that were added in a form of libdns concrete type, and not a opaque RR type.
func (*Provider) DeleteRecords ¶
func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
DeleteRecords deletes the specified records from the zone. It returns the records that were deleted.
func (*Provider) GetRecords ¶
GetRecords lists all the records in the zone.
func (*Provider) SetRecords ¶
func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
Here, the "SetRecords" method doesn't provide atomicity. Meaning a non nil value for the returned "error" can indicate that the zone is in a invalid state, and there is no rollback operation happened to rollback the previous changes.
SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records, And not the skipped ones.
