Documentation
¶
Overview ¶
Package dns an SDK for the Hetzner DNS API.
Read the API docs over on https://dns.hetzner.com/api-docs.
Example:
package main import ( "context" "fmt" "log" "github.com/jobstoit/hetzner-dns-go/dns" ) func main() { client := dns.NewClient(dns.WithToken("token")) record, _, err := client.Record.GetByID(context.Background(), "randomid") if err != nil { log.Fatalf("error retrieving record: %v\n", err) } fmt.Printf("record of type: '%s' found with value: %s", record.Type, record.Value) }
Index ¶
- Constants
- type Client
- type ClientOption
- type ListOpts
- type Meta
- type Pagination
- type PrimaryServer
- type PrimaryServerClient
- func (c PrimaryServerClient) Create(ctx context.Context, opts PrimaryServerCreateOpts) (*PrimaryServer, *Response, error)
- func (c PrimaryServerClient) Delete(ctx context.Context, server *PrimaryServer) (*Response, error)
- func (c PrimaryServerClient) GetByID(ctx context.Context, id string) (*PrimaryServer, *Response, error)
- func (c PrimaryServerClient) List(ctx context.Context, opts PrimaryServerListOpts) ([]*PrimaryServer, *Response, error)
- func (c PrimaryServerClient) Update(ctx context.Context, server *PrimaryServer, opts PrimaryServerUpdateOpts) (*PrimaryServer, *Response, error)
- type PrimaryServerCreateOpts
- type PrimaryServerListOpts
- type PrimaryServerUpdateOpts
- type Record
- type RecordBulkCreateResponse
- type RecordBulkUpdateOpts
- type RecordBulkUpdateResponse
- type RecordClient
- func (c RecordClient) BulkCreate(ctx context.Context, bulkOpts []RecordCreateOpts) (*RecordBulkCreateResponse, *Response, error)
- func (c RecordClient) BulkUpdate(ctx context.Context, bulkOpts []RecordBulkUpdateOpts) (*RecordBulkUpdateResponse, *Response, error)
- func (c RecordClient) Create(ctx context.Context, opts RecordCreateOpts) (*Record, *Response, error)
- func (c RecordClient) Delete(ctx context.Context, rec *Record) (*Response, error)
- func (c RecordClient) GetByID(ctx context.Context, id string) (*Record, *Response, error)
- func (c RecordClient) List(ctx context.Context, opts RecordListOpts) ([]*Record, *Response, error)
- func (c RecordClient) Update(ctx context.Context, rec *Record, opts RecordUpdateOpts) (*Record, *Response, error)
- type RecordCreateOpts
- type RecordEntry
- type RecordListOpts
- type RecordType
- type RecordUpdateOpts
- type Response
- type TxtVerification
- type ValidatedZoneFile
- type Zone
- type ZoneClient
- func (c ZoneClient) Create(ctx context.Context, opts ZoneCreateOpts) (*Zone, *Response, error)
- func (c ZoneClient) Delete(ctx context.Context, zone *Zone) (*Response, error)
- func (c ZoneClient) Export(ctx context.Context, zone *Zone) (io.Reader, *Response, error)
- func (c ZoneClient) GetByID(ctx context.Context, id string) (*Zone, *Response, error)
- func (c ZoneClient) Import(ctx context.Context, zone *Zone, file io.Reader) (*Zone, *Response, error)
- func (c ZoneClient) List(ctx context.Context, opts ZoneListOpts) ([]*Zone, *Response, error)
- func (c ZoneClient) Update(ctx context.Context, zone *Zone, opts ZoneUpdateOpts) (*Zone, *Response, error)
- func (c ZoneClient) ValidateFile(ctx context.Context, file io.Reader) (*ValidatedZoneFile, *Response, error)
- type ZoneCreateOpts
- type ZoneListOpts
- type ZoneStatus
- type ZoneUpdateOpts
Constants ¶
const Endpoint = "https://dns.hetzner.com/api/v1"
Endpoint is the base URL of the API.
const UserAgent = "hetzner-dns/" + Version
const Version = "v0.1.0"
Version of the SDK
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Zone *ZoneClient Record *RecordClient PrimaryServer *PrimaryServerClient // contains filtered or unexported fields }
Client is the client for the Hetzner DNS API.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is used to configure a client.
func WithApplication ¶
func WithApplication(name, version string) ClientOption
WithApplication configures a Client with the given application name and application version. The version may be blank. Programs are encouraged to at least set an application name.
func WithDebugWriter ¶
func WithDebugWriter(wr io.Writer) ClientOption
WithDebugWriter configures the client to use the given debug writer.
func WithEndpoint ¶
func WithEndpoint(url string) ClientOption
WithEndpoint configures the client to use a different endpoint.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient configures a Client to perform HTTP requests with httpClient.
func WithToken ¶
func WithToken(token string) ClientOption
WithToken configures a client to use the specified token.
type Meta ¶
type Meta struct {
Pagination *Pagination
}
Meta represents meta inforation included in the API response.
type Pagination ¶
Pagination represents pagination meta information.
func PaginationFromSchema ¶
func PaginationFromSchema(s schema.MetaPagination) Pagination
PaginationFromSchema converts a schema.MetaPagination to a Pagination.
type PrimaryServer ¶
type PrimaryServer struct { ID string Port int Created schema.HdnsTime Modified schema.HdnsTime Zone *Zone Address string }
PrimaryServer represents a primary server in the Hetzner DNS API.
func PrimaryServerFromSchema ¶
func PrimaryServerFromSchema(s schema.PrimaryServer) *PrimaryServer
PrimaryServerFromSchema converts a schema.PrimaryServer to a PrimaryServer
type PrimaryServerClient ¶
type PrimaryServerClient struct {
// contains filtered or unexported fields
}
RecordClient is a client for primary server API.
func (PrimaryServerClient) Create ¶
func (c PrimaryServerClient) Create(ctx context.Context, opts PrimaryServerCreateOpts) (*PrimaryServer, *Response, error)
Create creates a new primary server record.
func (PrimaryServerClient) Delete ¶
func (c PrimaryServerClient) Delete(ctx context.Context, server *PrimaryServer) (*Response, error)
Delete deletes a primary server record.
func (PrimaryServerClient) GetByID ¶
func (c PrimaryServerClient) GetByID(ctx context.Context, id string) (*PrimaryServer, *Response, error)
GetByID returns the PrimaryServer with the given id.
func (PrimaryServerClient) List ¶
func (c PrimaryServerClient) List(ctx context.Context, opts PrimaryServerListOpts) ([]*PrimaryServer, *Response, error)
List returns all primary servers with the given parameters.
func (PrimaryServerClient) Update ¶
func (c PrimaryServerClient) Update(ctx context.Context, server *PrimaryServer, opts PrimaryServerUpdateOpts) (*PrimaryServer, *Response, error)
Update updates a primary server record.
type PrimaryServerCreateOpts ¶
PrimaryServerCreateOpts specifies options for creating a primary server.
type PrimaryServerListOpts ¶
type PrimaryServerListOpts struct {
ZoneID string
}
PrimaryServerListOpts specifies options for listing primary servers
type PrimaryServerUpdateOpts ¶
PrimaryServerUpdateOpts specifies options for updating a primary server.
type Record ¶
type Record struct { Type RecordType ID string Created schema.HdnsTime Modified schema.HdnsTime Zone *Zone Name string Value string Ttl int }
Record represents a record in the Hetzner DNS.
func RecordFromSchema ¶
RecordFromSchema convers a schema.Record to Record
type RecordBulkCreateResponse ¶
type RecordBulkCreateResponse struct { Records []*Record ValidRecords []*RecordEntry InvalidRecords []*RecordEntry }
RecordBulkCreateResponse is returned when creating records in bulk.
type RecordBulkUpdateOpts ¶
type RecordBulkUpdateOpts struct { ID string Type RecordType Zone *Zone Name string Value string Ttl *int }
RecordBulkUpdateOpts specifies options for a bulk record update entry
type RecordBulkUpdateResponse ¶
type RecordBulkUpdateResponse struct { Records []*Record FailedRecords []*RecordEntry }
RecordBulkUpdateResponse is returned when creating records in bulk.
type RecordClient ¶
type RecordClient struct {
// contains filtered or unexported fields
}
RecordClient is a client for records API.
func (RecordClient) BulkCreate ¶
func (c RecordClient) BulkCreate(ctx context.Context, bulkOpts []RecordCreateOpts) (*RecordBulkCreateResponse, *Response, error)
BulkCreate creates multiple records.
func (RecordClient) BulkUpdate ¶
func (c RecordClient) BulkUpdate(ctx context.Context, bulkOpts []RecordBulkUpdateOpts) (*RecordBulkUpdateResponse, *Response, error)
BulkUpdate updates multiple records.
func (RecordClient) Create ¶
func (c RecordClient) Create(ctx context.Context, opts RecordCreateOpts) (*Record, *Response, error)
Create creates a new record.
func (RecordClient) List ¶
func (c RecordClient) List(ctx context.Context, opts RecordListOpts) ([]*Record, *Response, error)
List returns all records with the given parameters.
func (RecordClient) Update ¶
func (c RecordClient) Update(ctx context.Context, rec *Record, opts RecordUpdateOpts) (*Record, *Response, error)
Update updates a record.
type RecordCreateOpts ¶
type RecordCreateOpts struct { Name string Ttl *int Type RecordType Value string Zone *Zone }
RecordCreateOpts specifies options for creating a record.
type RecordEntry ¶
type RecordEntry struct { Type RecordType ZoneID string Name string Value string Ttl *int }
RecordEntry represents a record entry used for verification and updates.
func RecordEntryFromSchema ¶
func RecordEntryFromSchema(s schema.RecordBulkEntry) *RecordEntry
RecordEntryFromSchema converts a schema.RecordCreateRequest to a RecordCreateOpts
type RecordListOpts ¶
RecordListOpts specifies options for listing records
type RecordType ¶
type RecordType string
const ( RecordTypeA RecordType = "A" RecordTypeAAAA RecordType = "AAAA" RecordTypePTR RecordType = "PTR" RecordTypeNS RecordType = "NS" RecordTypeMX RecordType = "MX" RecordTypeCNAME RecordType = "CNAME" RecordTypeRP RecordType = "RP" RecordTypeTXT RecordType = "TXT" RecordTypeSOA RecordType = "SOA" RecordTypeHINFO RecordType = "HINFO" RecordTypeSRV RecordType = "SRV" RecordTypeDANE RecordType = "DANE" RecordTypeTLSA RecordType = "TLSA" RecordTypeDS RecordType = "DS" RecordTypeCAA RecordType = "CAA" )
type RecordUpdateOpts ¶
type RecordUpdateOpts struct { Name string Ttl *int Type RecordType Value string Zone *Zone }
RecordUpdateOpts specifies options for creating a record.
type TxtVerification ¶
TxtVerification represents a txt verification of a zone.
func TxtVerificationFromSchema ¶
func TxtVerificationFromSchema(s schema.TxtVerification) *TxtVerification
TxtVerificationFromSchema converts schema.TxtVerification to TxtVerification
type ValidatedZoneFile ¶
ValidatedZoneFile is returned when validating a zone file.
func ValidateZoneFileFromSchema ¶
func ValidateZoneFileFromSchema(s schema.ValidateZoneFileResponse) *ValidatedZoneFile
ValidateZoneFileFromSchema converts a schema.ValidateZoneFileResponse to a ValidatedZoneFile.
type Zone ¶
type Zone struct { ID string Created schema.HdnsTime Modified schema.HdnsTime LegacyDNSHost string LegacyNS []string Name string NS []string Owner string Paused bool Permission string Project string Registrar string Status ZoneStatus Ttl int Verified schema.HdnsTime RecordsCount int IsSecondaryDNS bool TxtVerification *TxtVerification }
Zone represents a zone in Hetzner DNS.
func ZoneFromSchema ¶
ZoneFromSchema converts schema.Zone to a Zone.
type ZoneClient ¶
type ZoneClient struct {
// contains filtered or unexported fields
}
ZoneClient is a client for zones API.
func (ZoneClient) Create ¶
func (c ZoneClient) Create(ctx context.Context, opts ZoneCreateOpts) (*Zone, *Response, error)
Create creates a new zone.
func (ZoneClient) Import ¶
func (c ZoneClient) Import(ctx context.Context, zone *Zone, file io.Reader) (*Zone, *Response, error)
Import imports a zone file in text/plain format.
func (ZoneClient) List ¶
func (c ZoneClient) List(ctx context.Context, opts ZoneListOpts) ([]*Zone, *Response, error)
List returns all zones with the given parameters.
func (ZoneClient) Update ¶
func (c ZoneClient) Update(ctx context.Context, zone *Zone, opts ZoneUpdateOpts) (*Zone, *Response, error)
Update updates a zone.
func (ZoneClient) ValidateFile ¶
func (c ZoneClient) ValidateFile(ctx context.Context, file io.Reader) (*ValidatedZoneFile, *Response, error)
ValidateFile validates a zone file.
type ZoneCreateOpts ¶
ZoneCreateOpts specifies options for creating a new zone.
func (ZoneCreateOpts) Validate ¶
func (o ZoneCreateOpts) Validate() error
Validate checks if the options are valid.
type ZoneListOpts ¶
ZoneListOptions specifies options for listing zones.
type ZoneStatus ¶
type ZoneStatus string
const ( ZoneStatusVerified ZoneStatus = `verified` ZoneStatusFailed ZoneStatus = `failed` ZoneStatusPending ZoneStatus = `pending` )
type ZoneUpdateOpts ¶
ZoneUpdateOpts specifies options for updating a zone.
func (ZoneUpdateOpts) Validate ¶
func (o ZoneUpdateOpts) Validate() error
Validate checks if the options are valid.