Documentation
¶
Index ¶
- Constants
- type BadRequestError
- type Client
- func (c *Client) CreateManyRecords(ctx context.Context, zone *Zone, recs []*RR) ([]*Record, error)
- func (c *Client) CreateRecord(ctx context.Context, zone *Zone, attrs *Record) (*Record, error)
- func (c *Client) CreateZone(ctx context.Context, attrs *Zone) (*Zone, error)
- func (c *Client) DeleteManyRecords(ctx context.Context, zone *Zone, recs []*RR) ([]*Record, error)
- func (c *Client) DeleteRecord(ctx context.Context, zone *Zone, recordID int64) (*Record, error)
- func (c *Client) DeleteZone(ctx context.Context, zoneID int64) (*Zone, error)
- func (c *Client) GetRecord(ctx context.Context, zone *Zone, recordID int64) (*Record, error)
- func (c *Client) GetZone(ctx context.Context, zoneID int64) (*Zone, error)
- func (c *Client) ListRecords(ctx context.Context, zone *Zone, options *ListParams, handlers ...HandlerFunc) ([]*Record, error)
- func (c *Client) ListZones(ctx context.Context, options *ListParams, handlers ...HandlerFunc) ([]*Zone, error)
- func (c *Client) Me(ctx context.Context) (*User, error)
- func (c *Client) UpdateManyRecords(ctx context.Context, zone *Zone, recs []*RR) ([]*Record, error)
- func (c *Client) UpdateRecord(ctx context.Context, zone *Zone, recordID int64, attrs *Record) (*Record, error)
- func (c *Client) UpdateZone(ctx context.Context, zoneID int64, attrs *Zone) (*Zone, error)
- func (c *Client) UserAgent(product string)
- type ErrBadContentType
- type ErrBadStatusCode
- type ErrTooManyRequests
- type ForbiddenRequestError
- type HandlerFunc
- type InputError
- type JSONClient
- func (c *JSONClient) Delete(ctx context.Context, url string, handlers ...HandlerFunc) ([]byte, error)
- func (c *JSONClient) Get(ctx context.Context, url string, handlers ...HandlerFunc) ([]byte, error)
- func (c *JSONClient) Patch(ctx context.Context, url string, data any, handlers ...HandlerFunc) ([]byte, error)
- func (c *JSONClient) Post(ctx context.Context, url string, attrs any, handlers ...HandlerFunc) ([]byte, error)
- func (c *JSONClient) Put(ctx context.Context, url string, data any, handlers ...HandlerFunc) ([]byte, error)
- type ListMeta
- type ListParams
- type OptFunc
- type RR
- type Record
- type RecordType
- type RestCallFunc
- type Transport
- type User
- type Zone
Constants ¶
const ( TypeA = "A" TypeAAAA = "AAAA" TypeALIAS = "ALIAS" TypeCAA = "CAAA" TypeCNAME = "CNAME" TypeDS = "DS" TypeFORWARD = "FORWARD" TypeMX = "MX" TypeNS = "NS" TypePTR = "PTR" TypeREDIRECT = "REDIRECT" TypeSLAVE = "SLAVE" TypeSOA = "SOA" TypeSPF = "SPF" TypeSRV = "SRV" TypeSSHFP = "SSHFP" TypeTLSA = "TLSA" TypeTXT = "TXT" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadRequestError ¶
type BadRequestError []InputError
BadRequestError represents a list of validation errors returned by the API server.
func (BadRequestError) Error ¶
func (e BadRequestError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a REST API client for LuaDNS API.
func (*Client) CreateManyRecords ¶ added in v0.3.0
CreateManyRecords creates multiple DNS records using supplied RRs.
func (*Client) CreateRecord ¶
CreateRecord creates a zone record using supplied attributes.
func (*Client) CreateZone ¶
CreateZone creates a new zone using supplied attributes.
func (*Client) DeleteManyRecords ¶ added in v0.3.0
DeleteManyRecords deletes multiple zone records matching supplied RRs.
Only records with exact match of input name, type, content and TTL are being deleted. For input RRs only name is required, the other fields are optional.
See: http://www.luadns.com/api.html#delete-many-records
Example:
- &RR{{Name: "example.com."}} - matches all example.com. records
- &RR{{Name: "example.com.", Type: "TXT"}} - matches all example.com. records of TXT type
func (*Client) DeleteRecord ¶
DeleteRecord deletes a zone record identfied by `recordID`.
func (*Client) DeleteZone ¶
DeleteZone delete specific zone using zone ID.
func (*Client) ListRecords ¶
func (c *Client) ListRecords(ctx context.Context, zone *Zone, options *ListParams, handlers ...HandlerFunc) ([]*Record, error)
ListRecords returns zone records.
func (*Client) ListZones ¶
func (c *Client) ListZones(ctx context.Context, options *ListParams, handlers ...HandlerFunc) ([]*Zone, error)
ListZones returns user zones.
func (*Client) UpdateManyRecords ¶ added in v0.3.0
UpdateManyRecords updates multiple DNS records using supplied RRs.
For any (name, type) pairs in the input it will change zone records with supplied input records, other records remains unchanged.
See: http://www.luadns.com/api.html#update-many-records
Example:
;; Original records example.com. 3600 IN A 1.1.1.1 example.com. 3600 IN A 2.2.2.2 example.com. 3600 IN TXT "hello world" ;; Input records example.com. 3600 IN A 1.1.1.1 example.com. 3600 IN A 3.3.3.3 ;; Result records example.com. 3600 IN A 1.1.1.1 example.com. 3600 IN A 3.3.3.3 example.com. 3600 IN TXT "hello world"
func (*Client) UpdateRecord ¶
func (c *Client) UpdateRecord(ctx context.Context, zone *Zone, recordID int64, attrs *Record) (*Record, error)
UpdateRecord updates a zone record identfied by `recordID` using supplied attributes.
func (*Client) UpdateZone ¶
UpdateZone zone identified by `zoneID` using supplied attributes.
type ErrBadContentType ¶
type ErrBadContentType struct {
ContentType string
}
ErrBadContentType represents an error for unexpected content type returned by the API server.
func (*ErrBadContentType) Error ¶
func (e *ErrBadContentType) Error() string
type ErrBadStatusCode ¶
type ErrBadStatusCode struct {
StatusCode int
}
ErrBadStatusCode represents an error for unexpected status code returned by the API server.
func (*ErrBadStatusCode) Error ¶
func (e *ErrBadStatusCode) Error() string
type ErrTooManyRequests ¶
ErrTooManyRequests represents an error returned when users exeeds requests quota (status code 429).
func (*ErrTooManyRequests) Error ¶
func (e *ErrTooManyRequests) Error() string
type ForbiddenRequestError ¶
ForbiddenRequestError represents an error returned by the server when input data is valid but the operation is not allowed (status code 403).
func (*ForbiddenRequestError) Error ¶
func (e *ForbiddenRequestError) Error() string
type HandlerFunc ¶
HandlerFunc represents a response handler.
func GetListMeta ¶
func GetListMeta(meta *ListMeta) HandlerFunc
GetListMeta parses response headers and fills pagination details.
type InputError ¶
type InputError struct {
Classification string `json:"classification"` // DeserializationError, RequiredError, ValidationError
FieldNames []string `json:"fieldNames"` // Example: name
Message string `json:"message"` // Example: invalid name
}
InputError represents a validation error returned by the API server when input data is invalid (status code 400).
func (*InputError) Error ¶
func (e *InputError) Error() string
type JSONClient ¶
type JSONClient struct {
// contains filtered or unexported fields
}
JSONClient represents a REST client using JSON format.
func NewAuthJSONClient ¶
func NewAuthJSONClient(username, password string) *JSONClient
NewAuthJSONClient initializes JSON client using Basic authentication.
func NewJSONClient ¶
func NewJSONClient(client *http.Client) *JSONClient
NewJSONClient initializes JSON client.
func (*JSONClient) Delete ¶
func (c *JSONClient) Delete(ctx context.Context, url string, handlers ...HandlerFunc) ([]byte, error)
Delete executes a DELETE request and returns JSON response.
func (*JSONClient) Get ¶
func (c *JSONClient) Get(ctx context.Context, url string, handlers ...HandlerFunc) ([]byte, error)
Get executes a GET request and returns JSON response.
func (*JSONClient) Patch ¶ added in v0.3.0
func (c *JSONClient) Patch(ctx context.Context, url string, data any, handlers ...HandlerFunc) ([]byte, error)
Patch executes a PATCH request using JSON body and returns JSON response.
func (*JSONClient) Post ¶
func (c *JSONClient) Post(ctx context.Context, url string, attrs any, handlers ...HandlerFunc) ([]byte, error)
Post executes a POST request using JSON body and returns JSON response.
func (*JSONClient) Put ¶
func (c *JSONClient) Put(ctx context.Context, url string, data any, handlers ...HandlerFunc) ([]byte, error)
Put executes a PUT request using JSON body and returns JSON response.
type ListParams ¶
type ListParams struct {
Query string // q=example.com
SortBy string // sort_by=name
SortOrder string // sort_order=asc/desc
Limit uint64 // limit=10
Page uint64 // page=1
}
ListParams represents list options accepted by a list endpoints.
func (*ListParams) QueryString ¶
func (opts *ListParams) QueryString() string
QueryString convert the list options to a query string.
type OptFunc ¶
type OptFunc func(*Client)
OptFunc represents a configuration function which are used to configure the REST API client.
func SetBaseURL ¶
SetBaseURL sets a custom baseURL for API requests (used in unit tests).
type RR ¶ added in v0.3.0
type RR struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Content string `json:"content,omitempty"`
TTL uint32 `json:"ttl,omitempty"`
}
RR represents a DNS resource record.
type RecordType ¶
type RecordType string
type RestCallFunc ¶
RestCallFunc represents a call to REST API.
type Transport ¶
Transport represents a HTTP transport using Basic authentication and accepts `application/json`.
type User ¶
type User struct {
Email string `json:"email"`
Name string `json:"name"`
RepoURI string `json:"repo_uri"`
APIEnabled bool `json:"api_enabled"`
TFA bool `json:"tfa"`
DeployKey string `json:"deploy_key"`
TTL uint32 `json:"ttl"`
Package string `json:"package"`
NameServers []string `json:"name_servers"`
}
type Zone ¶
type Zone struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name"`
Tags []string `json:"tags,omitempty"`
TemplateID int64 `json:"template_id,omitempty"`
Records []*Record `json:"records,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}