Documentation ¶
Index ¶
- Constants
- type APIBool
- type AccountService
- type Auth
- type AuthType
- type CAA
- type Client
- type DynamicURL
- type HTTPParams
- type NAPTR
- type Nameserver
- type Option
- func AuthSubUserID(id int, password string) Option
- func AuthSubUserName(user string, password string) Option
- func AuthUserID(id int, password string) Option
- func BaseURL(baseURL string) Option
- func HTTPClient(httpClient *http.Client) Option
- func Headers(headers http.Header) Option
- func Params(params HTTPParams) Option
- func UserAgent(userAgent string) Option
- type RP
- type Record
- func NewRecord(recordType RecordType, host, record string, ttl int) Record
- func NewRecordA(host, target string, ttl int) Record
- func NewRecordAAAA(host, target string, ttl int) Record
- func NewRecordALIAS(host, target string, ttl int) Record
- func NewRecordCAA(host string, flag uint8, caaType, value string, ttl int) Record
- func NewRecordCNAME(host, target string, ttl int) Record
- func NewRecordMX(host string, priority uint16, target string, ttl int) Record
- func NewRecordNAPTR(host string, order, preference uint16, ...) Record
- func NewRecordNS(host, target string, ttl int) Record
- func NewRecordPTR(host, target string, ttl int) Record
- func NewRecordRP(host string, mail, txt string, ttl int) Record
- func NewRecordSRV(host string, priority, weight, port uint16, target string, ttl int) Record
- func NewRecordSSHFP(host string, algorithm, fpType uint8, fingerprint string, ttl int) Record
- func NewRecordTLSA(host string, usage, selector, matchingType uint8, value string, ttl int) Record
- func NewRecordTXT(host, value string, ttl int) Record
- func NewRecordWebRedirect(host, target string, options WebRedirect, ttl int) Record
- type RecordFormat
- type RecordMap
- type RecordService
- func (svc *RecordService) AvailableRecordTypes(ctx context.Context, zoneType ZoneType, zoneKind ZoneKind) (result []string, err error)
- func (svc *RecordService) AvailableTTLs(ctx context.Context, zoneName string) (result []int, err error)
- func (svc *RecordService) ChangeDynamicURL(ctx context.Context, zoneName string, recordID int) (result DynamicURL, err error)
- func (svc *RecordService) CopyFromZone(ctx context.Context, targetZoneName, sourceZoneName string, overwrite bool) (result StatusResult, err error)
- func (svc *RecordService) Create(ctx context.Context, zoneName string, record Record) (result StatusResult, err error)
- func (svc *RecordService) Delete(ctx context.Context, zoneName string, recordID int) (result StatusResult, err error)
- func (svc *RecordService) DisableDynamicURL(ctx context.Context, zoneName string, recordID int) (result StatusResult, err error)
- func (svc *RecordService) Export(ctx context.Context, zoneName string) (result RecordsExport, err error)
- func (svc *RecordService) GetDynamicURL(ctx context.Context, zoneName string, recordID int) (result DynamicURL, err error)
- func (svc *RecordService) GetSOA(ctx context.Context, zoneName string) (result SOA, err error)
- func (svc *RecordService) Import(ctx context.Context, zoneName string, format RecordFormat, content string, ...) (result StatusResult, err error)
- func (svc *RecordService) ImportTransfer(ctx context.Context, zoneName, server string) (result StatusResult, err error)
- func (svc *RecordService) List(ctx context.Context, zoneName string) (result RecordMap, err error)
- func (svc *RecordService) Search(ctx context.Context, zoneName, host string, recordType RecordType) (result RecordMap, err error)
- func (svc *RecordService) SetActive(ctx context.Context, zoneName string, recordID int, isActive bool) (result StatusResult, err error)
- func (svc *RecordService) Update(ctx context.Context, zoneName string, recordID int, record Record) (result StatusResult, err error)
- func (svc *RecordService) UpdateSOA(ctx context.Context, zoneName string, soa SOA) (result StatusResult, err error)
- type RecordType
- type RecordsExport
- type SOA
- type SRV
- type SSHFP
- type StatusResult
- type TLSA
- type WebRedirect
- type Zone
- type ZoneKind
- type ZoneService
- func (svc *ZoneService) AvailableNameservers(ctx context.Context) (result []Nameserver, err error)
- func (svc *ZoneService) Get(ctx context.Context, zoneName string) (result Zone, err error)
- func (svc *ZoneService) GetUpdateStatus(ctx context.Context, zoneName string) (result []ZoneUpdateStatus, err error)
- func (svc *ZoneService) GetUsage(ctx context.Context) (result ZoneUsage, err error)
- func (svc *ZoneService) IsUpdated(ctx context.Context, zoneName string) (result bool, err error)
- func (svc *ZoneService) List(ctx context.Context) ([]Zone, error)
- func (svc *ZoneService) Search(ctx context.Context, search string, groupID int) ([]Zone, error)
- func (svc *ZoneService) SetActive(ctx context.Context, zoneName string, isActive bool) (result StatusResult, err error)
- func (svc *ZoneService) TriggerUpdate(ctx context.Context, zoneName string) (result StatusResult, err error)
- type ZoneType
- type ZoneUpdateStatus
- type ZoneUsage
Constants ¶
const ( ErrHTTPRequest = constError("http request failed") ErrAPIInvocation = constError("api invocation failed") ErrIllegalArgument = constError("illegal argument provided") ErrInvalidOptions = constError("invalid options provided") ErrMultipleCredentials = constError("more than one kind of credentials specified") )
Constant errors which can be returned by cloudns-go when something goes wrong
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIBool ¶
type APIBool bool
APIBool is a custom type representing the way how ClouDNS treats booleans in their API, as they usually appear as 1 or 0 (as a number or a string) instead of actual JSON booleans
func (APIBool) MarshalJSON ¶
MarshalJSON converts a APIBool into a 0 or 1 as a number according to the ClouDNS API docs
func (*APIBool) UnmarshalJSON ¶
UnmarshalJSON converts a boolean from the ClouDNS API into a sanitized Go boolean
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService is a service object which groups all operations related to ClouDNS account management
func (*AccountService) GetBalance ¶
func (svc *AccountService) GetBalance(ctx context.Context) (float64, error)
GetBalance returns the current account balance / funds for the configured credentials Official Docs: https://www.cloudns.net/wiki/article/354/
func (*AccountService) GetCurrentIP ¶
GetCurrentIP returns the IP address which the ClouDNS API backend sees while connecting to it. Official Docs: https://www.cloudns.net/wiki/article/307/
func (*AccountService) Login ¶
func (svc *AccountService) Login(ctx context.Context) (result StatusResult, err error)
Login attempts authentication against the ClouDNS backend with the configured set of credentials. Official Docs: https://www.cloudns.net/wiki/article/45/
type Auth ¶
Auth provides methods for turning human-friendly credentials into API parameters
func NewAuth ¶
func NewAuth() *Auth
NewAuth instantiates an empty Auth which contains no credentials / AuthTypeNone
func (*Auth) GetParams ¶
func (auth *Auth) GetParams() HTTPParams
GetParams returns the correct API parameters for the ClouDNS API which should be provided by either query parameters (when using GET) or the POST body as JSON
type AuthType ¶
type AuthType int
AuthType is an enumeration of the various ways of authenticating against the ClouDNS API
type CAA ¶
type CAA struct { Flag uint8 `json:"caa_flag,string,omitempty"` Type string `json:"caa_type,omitempty"` Value string `json:"caa_value,omitempty"` }
CAA represents parameters specifically for CAA records
type Client ¶
type Client struct { Account *AccountService Zones *ZoneService Records *RecordService // contains filtered or unexported fields }
Client provides the main object for interacting with the ClouDNS API. All service objects and settings are being stored underneath within this structure.
type DynamicURL ¶
DynamicURL represents a DynDNS URL for a specific zone record
type HTTPParams ¶
type HTTPParams map[string]interface{}
HTTPParams represents a map with string keys and a freely-chosen type. It is used to collect either GET or POST parameters for the ClouDNS API.
type NAPTR ¶
type NAPTR struct { Order uint16 `json:"order,string,omitempty"` Preference uint16 `json:"pref,string,omitempty"` Flags string `json:"flag"` Service string `json:"params"` Regexp string `json:"regexp"` Replacement string `json:"replace"` }
NAPTR represents parameters specifically for NAPTR records
type Nameserver ¶
type Nameserver struct { Type string `json:"type"` Name string `json:"name"` IPv4 net.IP `json:"ip4"` IPv6 net.IP `json:"ip6"` Location string `json:"location"` CountryCode string `json:"location_cc"` DDoSProtected APIBool `json:"ddos_protected"` }
Nameserver represents a ClouDNS nameserver according to the official API docs
type Option ¶
Option represents functional options which can be specified when instantiating a new API client
func AuthSubUserID ¶
AuthSubUserID setups sub-user-id based authentication against the ClouDNS API
func AuthSubUserName ¶
AuthSubUserName setups the sub-user-name based authentication against the ClouDNS API
func AuthUserID ¶
AuthUserID setups user-id based authentication against the ClouDNS API
func HTTPClient ¶
HTTPClient overrides the HTTPClient used by the API client, useful for mocking in unit tests.
func Headers ¶
Headers adds a set of headers to every sent API request. These headers can be overridden by request-specific headers.
func Params ¶
func Params(params HTTPParams) Option
Params adds a set of parameters (either GET or POST) to every sent API request. These are overridden by auth as well as request-specific parameters.
type Record ¶
type Record struct { // Base fields for all records ID int `json:"id,string,omitempty"` Host string `json:"host"` Record string `json:"record"` RecordType RecordType `json:"type"` TTL int `json:"ttl,string"` IsActive APIBool `json:"status"` GeoDNSLocationID int `json:"geodns-location,omitempty"` // Shared field between SRV and MX Priority uint16 `json:"priority,string,omitempty"` // Type-specific record fields CAA NAPTR RP SRV SSHFP TLSA WebRedirect }
Record represents a ClouDNS record according to the official API docs
func NewRecord ¶
func NewRecord(recordType RecordType, host, record string, ttl int) Record
NewRecord instantiates a new record which can be used within ClouDNS API methods. It does -not- add this record automatically to any given kind of zone.
func NewRecordA ¶
NewRecordA instantiates a new A record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordAAAA ¶
NewRecordAAAA instantiates a new AAAA record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordALIAS ¶
NewRecordALIAS instantiates a new ALIAS record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordCAA ¶
NewRecordCAA instantiates a new CAA record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordCNAME ¶
NewRecordCNAME instantiates a new CNAME record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordMX ¶
NewRecordMX instantiates a new MX record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordNAPTR ¶
func NewRecordNAPTR(host string, order, preference uint16, flags, service, regexp, replacement string, ttl int) Record
NewRecordNAPTR instantiates a new NAPTR record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordNS ¶
NewRecordNS instantiates a new NS record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordPTR ¶
NewRecordPTR instantiates a new PTR record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordRP ¶
NewRecordRP instantiates a new RP record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordSRV ¶
NewRecordSRV instantiates a new SRV record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordSSHFP ¶
NewRecordSSHFP instantiates a new SSHFP record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordTLSA ¶
NewRecordTLSA instantiates a new TLSA record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordTXT ¶
NewRecordTXT instantiates a new TXT record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func NewRecordWebRedirect ¶
func NewRecordWebRedirect(host, target string, options WebRedirect, ttl int) Record
NewRecordWebRedirect instantiates a new web redirect record. This can also be achieved by manually calling NewRecord and setting the required additional parameters.
func (Record) AsParams ¶
func (rec Record) AsParams() HTTPParams
AsParams returns the HTTP parameters for a record for use within the other API methods
type RecordFormat ¶
type RecordFormat int
RecordFormat is an enumeration of all supported record formats
const ( RecordFormatBIND RecordFormat = iota RecordFormatTinyDNS )
Enumeration values for RecordFormat
type RecordService ¶
type RecordService struct {
// contains filtered or unexported fields
}
RecordService is a service object which groups all operations related to ClouDNS record management
func (*RecordService) AvailableRecordTypes ¶
func (svc *RecordService) AvailableRecordTypes(ctx context.Context, zoneType ZoneType, zoneKind ZoneKind) (result []string, err error)
AvailableRecordTypes returns the available record types for a given zone type and kind Official Docs: https://www.cloudns.net/wiki/article/157/
func (*RecordService) AvailableTTLs ¶
func (svc *RecordService) AvailableTTLs(ctx context.Context, zoneName string) (result []int, err error)
AvailableTTLs returns the available record TTLs for a specified zone Official Docs: https://www.cloudns.net/wiki/article/153/
func (*RecordService) ChangeDynamicURL ¶
func (svc *RecordService) ChangeDynamicURL(ctx context.Context, zoneName string, recordID int) (result DynamicURL, err error)
ChangeDynamicURL creates or replaces the current DynDNS url for the given record Official Docs: https://www.cloudns.net/wiki/article/152/
func (*RecordService) CopyFromZone ¶
func (svc *RecordService) CopyFromZone(ctx context.Context, targetZoneName, sourceZoneName string, overwrite bool) (result StatusResult, err error)
CopyFromZone copies all records from one zone into another, optionally overwriting the existing records Official Docs: https://www.cloudns.net/wiki/article/61/
func (*RecordService) Create ¶
func (svc *RecordService) Create(ctx context.Context, zoneName string, record Record) (result StatusResult, err error)
Create a new record within the given zone Official Docs: https://www.cloudns.net/wiki/article/58/
func (*RecordService) Delete ¶
func (svc *RecordService) Delete(ctx context.Context, zoneName string, recordID int) (result StatusResult, err error)
Delete modifies a specific record with a given record ID inside the given zone Official Docs: https://www.cloudns.net/wiki/article/59/
func (*RecordService) DisableDynamicURL ¶
func (svc *RecordService) DisableDynamicURL(ctx context.Context, zoneName string, recordID int) (result StatusResult, err error)
DisableDynamicURL disables the current DynDNS url for the given record Official Docs: https://www.cloudns.net/wiki/article/152/
func (*RecordService) Export ¶
func (svc *RecordService) Export(ctx context.Context, zoneName string) (result RecordsExport, err error)
Export returns all records of the given zone as a BIND zone file Official Docs: https://www.cloudns.net/wiki/article/166/
func (*RecordService) GetDynamicURL ¶
func (svc *RecordService) GetDynamicURL(ctx context.Context, zoneName string, recordID int) (result DynamicURL, err error)
GetDynamicURL returns the current DynDNS url for the given record Official Docs: https://www.cloudns.net/wiki/article/64/
func (*RecordService) GetSOA ¶
GetSOA returns the SOA record of the given zone Official Docs: https://www.cloudns.net/wiki/article/62/
func (*RecordService) Import ¶
func (svc *RecordService) Import(ctx context.Context, zoneName string, format RecordFormat, content string, overwrite bool) (result StatusResult, err error)
Import records with a specific format into the zone, optionally overwriting the existing records Official Docs: https://www.cloudns.net/wiki/article/156/
func (*RecordService) ImportTransfer ¶
func (svc *RecordService) ImportTransfer(ctx context.Context, zoneName, server string) (result StatusResult, err error)
ImportTransfer imports records from an authoritative nameserver into the zone using AXFR, overwriting all records Official Docs: https://www.cloudns.net/wiki/article/65/
func (*RecordService) List ¶
List returns all the records of a given zone Official Docs: https://www.cloudns.net/wiki/article/57/
func (*RecordService) Search ¶
func (svc *RecordService) Search(ctx context.Context, zoneName, host string, recordType RecordType) (result RecordMap, err error)
Search returns all records matching a given host and/or record type within the given zone Official Docs: https://www.cloudns.net/wiki/article/57/
func (*RecordService) SetActive ¶
func (svc *RecordService) SetActive(ctx context.Context, zoneName string, recordID int, isActive bool) (result StatusResult, err error)
SetActive enables or disables a given record ID within the specified zone Official Docs: https://www.cloudns.net/wiki/article/66/
func (*RecordService) Update ¶
func (svc *RecordService) Update(ctx context.Context, zoneName string, recordID int, record Record) (result StatusResult, err error)
Update modifies a specific record with a given record ID inside the given zone Official Docs: https://www.cloudns.net/wiki/article/60/
func (*RecordService) UpdateSOA ¶
func (svc *RecordService) UpdateSOA(ctx context.Context, zoneName string, soa SOA) (result StatusResult, err error)
UpdateSOA updates the SOA record of the given zone Official Docs: https://www.cloudns.net/wiki/article/63/
type RecordType ¶
type RecordType string
RecordType is an enumeration of all known record types. It is based on a string, as this allows usage of new or unknown record types and avoids any internal mappings in cloudns-go.
const ( RecordTypeUnknown RecordType = "" RecordTypeA RecordType = "A" RecordTypeAAAA RecordType = "AAAA" RecordTypeALIAS RecordType = "ALIAS" RecordTypeCAA RecordType = "CAA" RecordTypeCNAME RecordType = "CNAME" RecordTypeMX RecordType = "MX" RecordTypeNAPTR RecordType = "NAPTR" RecordTypeNS RecordType = "NS" RecordTypePTR RecordType = "PTR" RecordTypeRP RecordType = "RP" RecordTypeSRV RecordType = "SRV" RecordTypeSSHFP RecordType = "SSHFP" RecordTypeTLSA RecordType = "TLSA" RecordTypeTXT RecordType = "TXT" RecordTypeWebRedirect RecordType = "WR" )
Enumeration values for RecordType
type RecordsExport ¶
type RecordsExport struct { StatusResult Zone string `json:"zone"` }
RecordsExport represents a BIND zone file export provided by the ClouDNS API
type SOA ¶
type SOA struct { Serial int `json:"serialNumber,string"` PrimaryNS string `json:"primaryNS"` AdminMail string `json:"adminMail"` Refresh int `json:"refresh,string"` Retry int `json:"retry,string"` Expire int `json:"expire,string"` DefaultTTL int `json:"defaultTTL,string"` }
SOA represents the SOA record of a ClouDNS zone
func (SOA) AsParams ¶
func (soa SOA) AsParams() HTTPParams
AsParams returns the HTTP parameters for the SOA record for use within the other API methods
type SRV ¶
type SRV struct { Weight uint16 `json:"weight,string,omitempty"` Port uint16 `json:"port,string,omitempty"` }
SRV represents parameters specifically for SRV records
type SSHFP ¶
type SSHFP struct { Algorithm uint8 `json:"algorithm,string,omitempty"` Type uint8 `json:"fp_type,string,omitempty"` }
SSHFP represents parameters specifically for SSHFP records
type StatusResult ¶
type StatusResult struct { Status string `json:"status"` StatusDescription string `json:"statusDescription"` StatusMessage string `json:"statusMessage"` }
StatusResult is a common result used by all ClouDNS API methods for either
type TLSA ¶
type TLSA struct { Usage uint8 `json:"tlsa_usage,string,omitempty"` Selector uint8 `json:"tlsa_selector,string,omitempty"` MatchingType uint8 `json:"tlsa_matching_type,string,omitempty"` }
TLSA represents parameters specifically for TLSA records
type WebRedirect ¶
type WebRedirect struct { MobileMeta APIBool `json:"mobile_meta"` SavePath APIBool `json:"save_path,omitempty"` RedirectType int `json:"redirect_type,string,omitempty"` IsFrame APIBool `json:"frame,omitempty"` FrameTitle string `json:"frame_title,omitempty"` FrameKeywords string `json:"frame_keywords,omitempty"` FrameDescription string `json:"frame_description,omitempty"` }
WebRedirect represents parameters specifically for web redirect records
type Zone ¶
type Zone struct { Name string `json:"name"` Type ZoneType `json:"type"` Kind ZoneKind `json:"zone"` IsActive APIBool `json:"status"` }
Zone represents a ClouDNS record according to the official API docs
type ZoneKind ¶
type ZoneKind int
ZoneKind is an enumeration of all supported zone kinds
Enumeration values for ZoneKind
func (*ZoneKind) UnmarshalJSON ¶
UnmarshalJSON converts the ClouDNS zone type into the correct ZoneType enumeration value
type ZoneService ¶
type ZoneService struct {
// contains filtered or unexported fields
}
ZoneService is a service object which groups all operations related to ClouDNS zone management
func (*ZoneService) AvailableNameservers ¶
func (svc *ZoneService) AvailableNameservers(ctx context.Context) (result []Nameserver, err error)
AvailableNameservers returns all nameservers available for the current account Official Docs: https://www.cloudns.net/wiki/article/47/
func (*ZoneService) Get ¶
Get returns a zone with a given name Official Docs: https://www.cloudns.net/wiki/article/134/
func (*ZoneService) GetUpdateStatus ¶
func (svc *ZoneService) GetUpdateStatus(ctx context.Context, zoneName string) (result []ZoneUpdateStatus, err error)
GetUpdateStatus returns a list of all nameservers for the given zone with their update status Official Docs: https://www.cloudns.net/wiki/article/53/
func (*ZoneService) GetUsage ¶
func (svc *ZoneService) GetUsage(ctx context.Context) (result ZoneUsage, err error)
GetUsage returns the current zone usage for the current account (actual usage and maximum zones for current plan) Official Docs: https://www.cloudns.net/wiki/article/52/
func (*ZoneService) IsUpdated ¶
IsUpdated returns a boolean if the given zone has been updated to all ClouDNS nameservers Official Docs: https://www.cloudns.net/wiki/article/54/
func (*ZoneService) List ¶
func (svc *ZoneService) List(ctx context.Context) ([]Zone, error)
List returns all zones Official Docs: https://www.cloudns.net/wiki/article/50/
func (*ZoneService) Search ¶
Search returns all zones matching a given name and/or group ID Official Docs: https://www.cloudns.net/wiki/article/50/
func (*ZoneService) SetActive ¶
func (svc *ZoneService) SetActive(ctx context.Context, zoneName string, isActive bool) (result StatusResult, err error)
SetActive enables or disables a zone with the given name Official Docs: https://www.cloudns.net/wiki/article/55/
func (*ZoneService) TriggerUpdate ¶
func (svc *ZoneService) TriggerUpdate(ctx context.Context, zoneName string) (result StatusResult, err error)
TriggerUpdate triggers a manual update for a given zone Official Docs: https://www.cloudns.net/wiki/article/135/
type ZoneType ¶
type ZoneType int
ZoneType is an enumeration of all supported zone types
const ( ZoneTypeUnknown ZoneType = iota ZoneTypeMaster ZoneTypeSlave ZoneTypeParked ZoneTypeGeoDNS )
Enumeration values for ZoneType
func (*ZoneType) UnmarshalJSON ¶
UnmarshalJSON converts the ClouDNS zone type into the correct ZoneType enumeration value