cloudns

package module
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 7 Imported by: 0

README

ClouDNS-Go

This is an API-Client for the ClouDNS HTTP API written in Go

Usage

Structs

There are three structs that you need to know:

  • Apiaccess: Holds your authentication parameters (auth-id/sub-auth-id, auth-password)
  • Atention: If you are using API auth sub user(sub-auth-id), you need first to delegate the DNS zone that you want to make changes. If you don't have an access you will receive the "Missing domain name" error.
// Apiaccess ClouDNS API Credentials, see https://www.cloudns.net/wiki/article/42/
type Apiaccess struct {
	Authid       int    `json:"auth-id,omitempty"`
	Subauthid    int    `json:"sub-auth-id,omitempty"`
	Authpassword string `json:"auth-password"`
}
  • Zone: Holds information about a zone
// Zone is the external representation of a zone
// check the ...zone types in api.go for details
type Zone struct {
	Domain string   `json:"domain-name"`
	Ztype  string   `json:"zone-type"`
	Ns     []string `json:"ns,omitempty"`
}
  • Record: Holds information about a record
// Record is the external representation of a record
// check the ...record types in api.go for details
type Record struct {
   ID     string `json:"id"`
   Domain string `json:"domain-name"`
   Host   string `json:"host"`
   Rtype  string `json:"record-type"`
   TTL    int    `json:"ttl"`
   Record string `json:"record"`
}
Examples for the structs
a := cloudns.Apiaccess{
    Authid:       1234,
    Authpassword: "super-secret-password",
}

z := cloudns.Zone{
    Domain: "testdomain.xxx",
    Ztype:  "master",
}

r := cloudns.Record{
    Domain: "testdomain.xxx",
    ID:     "",
    Host:   "foo",
    Rtype:  "TXT",
    Record: "bar",
    TTL:    3600,
}
Methods

These structs have methods, that call the API, most of them return either an Array of the other ones or the updated input struct and an error.

Create(*auth): create a zone

fmt.Println("create zone testdomain.xxx")
zc, zcerr := z.Create(&a)
if zcerr == nil {
    spew.Println(zc)
z = zc
} else {
    spew.Println(zcerr)
}

Destroy(*auth): destroy a zone

fmt.Println("destroying zone testdomain.xxx ...")
zd, zderr := z.Destroy(&a)
if zderr == nil {
    spew.Println(zd)
} else {
    spew.Println(zderr)
}
Record Methods

Create(*auth): Create a record

fmt.Println("creating record foo TXT bar 3600")
rc, rcerr := r.Create(&a)
if rcerr == nil {
    spew.Println(rc)
} else {
    spew.Println(rcerr)
}

Update(*auth): Update a record

rc.Record = "foobar"
fmt.Println("Updating record to foo TXT foobar 3600")
ru, ruerr := rc.Update(&a)
if ruerr == nil {
    spew.Println(ru)
} else {
    spew.Println(ruerr)
}

Read(*auth): Read a record

fmt.Println("Reading Record back")
rr, rrerr := ru.Read(&a)
if rrerr == nil {
    spew.Println(rr)
} else {
    spew.Println(rrerr)
}

Destroy(*auth): Destroy a record

fmt.Println("Destroying record")
rd, rderr := rr.Destroy(&a)
if rderr == nil {
    spew.Println(rd)
} else {
    spew.Println(rderr)
}

Documentation

Overview

Package cloudns private api functions

Package cloudns public structs/functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateFailover added in v1.0.6

type ActivateFailover struct {
	Authid           int        `json:"auth-id,omitempty"`
	Subauthid        int        `json:"sub-auth-id,omitempty"`
	Authpassword     string     `json:"auth-password"`
	ID               string     `json:"id"`
	Domain           string     `json:"domain-name"`
	RecordId         string     `json:"record-id"`
	FailoverType     string     `json:"check_type"`
	DownEventHandler string     `json:"down_event_handler"`
	UpEventHandler   string     `json:"up_event_handler"`
	MainIP           string     `json:"main_ip"`
	BackupIp1        string     `json:"backup_ip_1,omitempty"`
	BackupIp2        string     `json:"backup_ip_2,omitempty"`
	BackupIp3        string     `json:"backup_ip_3,omitempty"`
	BackupIp4        string     `json:"backup_ip_4,omitempty"`
	BackupIp5        string     `json:"backup_ip_5,omitempty"`
	MonitoringRegion string     `json:"monitoring_region,omitempty"`
	Host             string     `json:"host,omitempty"`
	Port             CustomPort `json:"port,omitempty"`
	Path             string     `json:"path,omitempty"`
	Content          string     `json:"content,omitempty"`
	QueryType        string     `json:"query_type,omitempty"`
	QueryResponse    string     `json:"query_response,omitempty"`
	CheckPeriod      string     `json:"check_period,omitempty"`
	NotificationMail string     `json:"notification_mail,omitempty"`
	LatencyLimit     string     `json:"latency_limit,omitempty"`
	Timeout          string     `json:"timeout,omitempty"`
	CheckRegion      string     `json:"checkregion,omitempty"`
	HttpRequestType  string     `json:"http_request_type,omitempty"`
}

type ApiFailover added in v1.0.6

type ApiFailover struct {
	Domain           string     `json:"domain-name"`
	RecordId         string     `json:"record-id"`
	FailoverType     string     `json:"check_type"`
	DownEventHandler string     `json:"down_event_handler"`
	UpEventHandler   string     `json:"up_event_handler"`
	MainIP           string     `json:"main_ip"`
	BackupIp1        string     `json:"backup_ip_1,omitempty"`
	BackupIp2        string     `json:"backup_ip_2,omitempty"`
	BackupIp3        string     `json:"backup_ip_3,omitempty"`
	BackupIp4        string     `json:"backup_ip_4,omitempty"`
	BackupIp5        string     `json:"backup_ip_5,omitempty"`
	MonitoringRegion string     `json:"monitoring_region,omitempty"`
	Host             string     `json:"host,omitempty"`
	Port             CustomPort `json:"port,omitempty"`
	Path             string     `json:"path,omitempty"`
	Content          string     `json:"content,omitempty"`
	QueryType        string     `json:"query_type,omitempty"`
	QueryResponse    string     `json:"query_response,omitempty"`
	CheckPeriod      string     `json:"check_period,omitempty"`
	NotificationMail string     `json:"notification_mail,omitempty"`
	LatencyLimit     string     `json:"latency_limit,omitempty"`
	Timeout          string     `json:"timeout,omitempty"`
	CheckRegion      string     `json:"checkregion,omitempty"`
	HttpRequestType  string     `json:"http_request_type,omitempty"`
}

type Apiaccess

type Apiaccess struct {
	Authid       int    `json:"auth-id,omitempty"`
	Subauthid    int    `json:"sub-auth-id,omitempty"`
	Authpassword string `json:"auth-password"`
}

Apiaccess ClouDNS API Credentials, see https://www.cloudns.net/wiki/article/42/

func (Apiaccess) Listzones

func (a Apiaccess) Listzones() ([]Zone, error)

Listzones returns all zones (max: 100)

type CheckSettings added in v1.0.6

type CheckSettings struct {
	LatencyLimit    string     `json:"latency_limit,omitempty"`
	Timeout         string     `json:"timeout,omitempty"`
	HttpRequestType string     `json:"http_request_type,omitempty"`
	Host            string     `json:"host,omitempty"`
	Port            CustomPort `json:"port,omitempty"`
	Path            string     `json:"path,omitempty"`
	Content         string     `json:"content,omitempty"`
	QueryResponse   string     `json:"query_response,omitempty"`
	QueryType       string     `json:"query_type,omitempty"`
}

type CustomPort added in v1.0.6

type CustomPort int

If the PORT is default it is returned as int but if it is not default it is returned as string

func (*CustomPort) UnmarshalJSON added in v1.0.6

func (cp *CustomPort) UnmarshalJSON(data []byte) error

type Failover added in v1.0.6

type Failover struct {
	Domain           string        `json:"domain-name"`
	RecordId         string        `json:"record-id"`
	FailoverType     string        `json:"check_type"`
	CheckSettings    CheckSettings `json:"check_settings"`
	MonitoringRegion string        `json:"monitoring_region,omitempty"`
	CheckPeriod      string        `json:"check_period,omitempty"`
	CheckRegion      string        `json:"checkregion,omitempty"`
	DownEventHandler string        `json:"down_event_handler"`
	UpEventHandler   string        `json:"up_event_handler"`
	MainIP           string        `json:"main_ip"`
	BackupIp1        string        `json:"backup_ip_1,omitempty"`
	BackupIp2        string        `json:"backup_ip_2,omitempty"`
	BackupIp3        string        `json:"backup_ip_3,omitempty"`
	BackupIp4        string        `json:"backup_ip_4,omitempty"`
	BackupIp5        string        `json:"backup_ip_5,omitempty"`
	NotificationMail string        `json:"notification_mail,omitempty"`
}

func (Failover) Create added in v1.0.6

func (f Failover) Create(a *Apiaccess) (Failover, error)

func (Failover) Delete added in v1.0.6

func (f Failover) Delete(a *Apiaccess) (Failover, error)

func (Failover) Read added in v1.0.6

func (f Failover) Read(a *Apiaccess) (Failover, error)

func (Failover) Update added in v1.0.6

func (f Failover) Update(a *Apiaccess) (Failover, error)

type FailoverData added in v1.0.6

type FailoverData struct {
	FailoverType     string        `json:"check_type"`
	DownEventHandler string        `json:"down_event_handler"`
	UpEventHandler   string        `json:"up_event_handler"`
	MainIP           string        `json:"main_ip"`
	BackupIp1        string        `json:"backup_ip_1,omitempty"`
	BackupIp2        string        `json:"backup_ip_2,omitempty"`
	BackupIp3        string        `json:"backup_ip_3,omitempty"`
	BackupIp4        string        `json:"backup_ip_4,omitempty"`
	BackupIp5        string        `json:"backup_ip_5,omitempty"`
	MonitoringRegion string        `json:"monitoring_region,omitempty"`
	CheckSettings    CheckSettings `json:"check_settings"`
	CheckPeriod      string        `json:"check_period,omitempty"`
	NotificationMail string        `json:"notification_mail,omitempty"`
	CheckRegion      string        `json:"checkregion,omitempty"`
}

type Ns added in v1.0.8

type Ns struct {
	Id            string `json:"id,omitempty"`
	Type          string `json:"type"`
	Name          string `json:"name"`
	Ip4           string `json:"ip4"`
	Ip6           string `json:"ip6"`
	Location      string `json:"location"`
	LocationCc    string `json:"location_cc"`
	DdosProtected int    `json:"ddos_protected"`
}

Ns is the external representation of a nameserver

func (Ns) List added in v1.0.8

func (n Ns) List(a Apiaccess) ([]Ns, error)

Listns returns all ns servers available

type Record

type Record struct {
	ID                 string  `json:"id"`
	Domain             string  `json:"domain-name"`
	Host               string  `json:"host"`
	Rtype              string  `json:"record-type"`
	TTL                int     `json:"ttl"`
	Record             string  `json:"record"`
	Priority           int     `json:"priority,omitempty"`
	Weight             int     `json:"weight,omitempty"`
	Port               int     `json:"port,omitempty"`
	Frame              string  `json:"frame,omitempty"`
	FrameTitle         string  `json:"frame-title,omitempty"`
	FrameKeywords      string  `json:"frame-keywords,omitempty"`
	FrameDescription   string  `json:"frame-description,omitempty"`
	MobileMeta         int     `json:"mobile-meta,omitempty"`
	SavePath           int     `json:"save-path,omitempty"`
	RedirectType       int     `json:"redirect-type,omitempty"`
	Mail               string  `json:"mail,omitempty"`
	Txt                string  `json:"txt,omitempty"`
	Algorithm          int     `json:"algorithm,omitempty"`
	Fptype             int     `json:"fptype,omitempty"`
	Status             int     `json:"status,omitempty"`
	GeodnsLocation     string  `json:"geodns-location,omitempty"`
	GeodnsCode         string  `json:"geodns-code,omitempty"`
	CaaFlag            string  `json:"caa_flag,omitempty"`
	CaaType            string  `json:"caa_type,omitempty"`
	CaaValue           string  `json:"caa_value,omitempty"`
	TlsaUsage          string  `json:"tlsa_usage,omitempty"`
	TlsaSelector       string  `json:"tlsa_selector,omitempty"`
	TlsaMatchingType   string  `json:"tlsa_matching_type,omitempty"`
	SmimeaUsage        string  `json:"smimea-usage,omitempty"`
	SmimeaSelector     string  `json:"smimea-selector,omitempty"`
	SmimeaMatchingType string  `json:"smimea-matching_type,omitempty"`
	KeyTag             int     `json:"key-tag,omitempty"`
	DigestType         int     `json:"digest-type,omitempty"`
	Order              string  `json:"order,omitempty"`
	Pref               string  `json:"pref,omitempty"`
	Flag               string  `json:"flag,omitempty"`
	Params             string  `json:"params,omitempty"`
	Regexp             string  `json:"regexp,omitempty"`
	Replace            string  `json:"replace,omitempty"`
	CertType           int     `json:"cert-type,omitempty"`
	CertKeyTag         int     `json:"cert-key-tag,omitempty"`
	CertAlgorithm      int     `json:"cert-algorithm,omitempty"`
	LatDeg             float64 `json:"lat-deg,omitempty"`
	LatMin             float64 `json:"lat-min,omitempty"`
	LatSec             float64 `json:"lat-sec,omitempty"`
	LatDir             string  `json:"lat-dir,omitempty"`
	LongDeg            float64 `json:"long-deg,omitempty"`
	LongMin            float64 `json:"long-min,omitempty"`
	LongSec            float64 `json:"long-sec,omitempty"`
	LongDir            string  `json:"long-dir,omitempty"`
	Altitude           string  `json:"altitude,omitempty"`
	Size               string  `json:"size,omitempty"`
	HPrecision         string  `json:"h-precision,omitempty"`
	VPrecision         string  `json:"v-precision,omitempty"`
	CPU                string  `json:"cpu,omitempty"`
	OS                 string  `json:"os,omitempty"`
}

Record is the external representation of a record check the ...record types in api.go for details

func (Record) Create

func (r Record) Create(a *Apiaccess) (Record, error)

Create a new record

func (Record) Destroy

func (r Record) Destroy(a *Apiaccess) (Record, error)

Destroy a record

func (Record) Read

func (r Record) Read(a *Apiaccess) (Record, error)

Read a record

func (Record) Update

func (r Record) Update(a *Apiaccess) (Record, error)

Update a record

type Zone

type Zone struct {
	Domain string   `json:"domain-name"`
	Ztype  string   `json:"zone-type"`
	Ns     []string `json:"ns,omitempty"`
	Master string   `json:"master-ip,omitempty"`
}

Zone is the external representation of a zone check the ...zone types in api.go for details

func (Zone) Create

func (z Zone) Create(a *Apiaccess) (Zone, error)

Create a new zone

func (Zone) Destroy

func (z Zone) Destroy(a *Apiaccess) (Zone, error)

Destroy a zone

func (Zone) List

func (z Zone) List(a *Apiaccess) ([]Record, error)

List returns all records from a zone

func (Zone) Read

func (z Zone) Read(a *Apiaccess) (Zone, error)

Read a zone

func (Zone) Update

func (z Zone) Update(a *Apiaccess) (Zone, error)

Update a zone [dummy]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL