Documentation ¶
Index ¶
- Constants
- func Err(code int, args ...interface{}) error
- func FormatDomainIDInts(rs []DomainEntryIDInt, format string) string
- func FormatDomains(rs []DomainEntry, format string) string
- func FormatRecords(rs []RecordEntry, format string, domain string) string
- func GetVersion() (string, error)
- func HTTPResp(module, action string, vs url.Values, data url.Values) (int, []byte, error)
- func ModuleActionString(module, action string) string
- func Register(module string, rf ReflectFunc) error
- func RemoveDomain(name string) (bool, error)
- func RemoveRecord(domain string, domainID string, recordID string) (bool, error)
- func SetAPIToken(appid int, token string)
- func SetDomainStatus(name string, status string) error
- func SetEndpoint(ep string)
- func SetRecordStatus(domain, domainID, recordID, status string) error
- type ActionEntry
- type ActionResult
- type Auth
- type AuthEntry
- type Config
- type DPA
- type Domain
- type DomainCreateInfo
- type DomainCreateResult
- type DomainEntry
- type DomainEntryIDInt
- type DomainInfoResult
- type DomainListInfo
- type DomainListResult
- type DomainRemoveResult
- type DomainStatusResult
- type Global
- type Info
- type InfoVersionResult
- type Params
- type Playbook
- type Record
- func (r Record) Create(bs []byte) *RecordCreateOrModifyResult
- func (r Record) Info(bs []byte) *RecordInfoResult
- func (r Record) List(bs []byte) *RecordListResult
- func (r Record) Modify(bs []byte) *RecordCreateOrModifyResult
- func (r Record) Remove(bs []byte) *RecordRemoveResult
- func (r Record) Status(bs []byte) *RecordStatusResult
- type RecordCreateOrModifyResult
- type RecordDomainEntry
- type RecordDomainEntryIDInt
- type RecordEntry
- func CreateRecord(domain string, domainID string, data Params) (*RecordEntry, error)
- func GetRecordInfo(domain string, domainID string, recordID string) (*RecordEntry, error)
- func ListRecord(domain string, domainID string) ([]RecordEntry, error)
- func ModifyRecord(domain string, domainID string, recordID string, data Params) (*RecordEntry, error)
- type RecordEntryIDInt
- type RecordInfoResult
- type RecordListInfo
- type RecordListResult
- type RecordRemoveResult
- type RecordStatusResult
- type ReflectFunc
- type RespCommon
- type Scene
Constants ¶
const ( // StatusEnable defines the string of `enable` of a domain StatusEnable = "enable" // StatusDisable defines the string of `disable` of a domain StatusDisable = "disable" // StatusUnkown defines the string of `unkown` of a domain StatusUnkown = "" )
const ( // DefaultEndpoint defines the default endpoint URL of dnspodapi DefaultEndpoint = "https://dnsapi.cn" // DefaultFormat defines the default format of response DefaultFormat = "json" )
const ( // ErrUnkownError for unkown ErrUnkownError = iota + 1000 // ErrUnkownModule for unregisterd module ErrUnkownModule // ErrReflectStructIsNil for nil reflect struct value ErrReflectStructIsNil // ErrReflectFuncIsNil for nil reflect struct func ErrReflectFuncIsNil // ErrReflectFuncInvalidReturnValue for invalid return value for reflect func ErrReflectFuncInvalidReturnValue // ErrInvalidTypeAssertion for invalid type assertion ErrInvalidTypeAssertion // ErrInvalidStatus for invalid status code ErrInvalidStatus )
const (
// DomainModuleName defines the const value of domain module
DomainModuleName = "domain"
)
const InfoModuleName = "info"
InfoModuleName defines the module name used in API
const (
// RecordModuleName defines the const value of record module
RecordModuleName = "record"
)
Variables ¶
This section is empty.
Functions ¶
func FormatDomainIDInts ¶ added in v1.1.0
func FormatDomainIDInts(rs []DomainEntryIDInt, format string) string
FormatDomainIDInts returns output string
func FormatDomains ¶
func FormatDomains(rs []DomainEntry, format string) string
FormatDomains returns output string
func FormatRecords ¶
func FormatRecords(rs []RecordEntry, format string, domain string) string
FormatRecords returns output string
func ModuleActionString ¶
ModuleActionString returns the string to join module and action for URL
func Register ¶
func Register(module string, rf ReflectFunc) error
Register registeres a func with module
func RemoveDomain ¶ added in v1.1.0
RemoveDomain removes domain
func RemoveRecord ¶
RemoveRecord removes a record
func SetDomainStatus ¶ added in v1.1.0
SetDomainStatus set domain status enable: enable, 1, online, on disable: disable, 0, offline, off
func SetRecordStatus ¶ added in v1.2.0
SetRecordStatus set record status 'enable|disable' enable: enable, 1, online, on disable: disable, 0, offline, off
Types ¶
type ActionEntry ¶ added in v1.2.0
type ActionEntry struct { Auth string `json:"auth" yaml:"auth"` Category string `json:"category" yaml:"category"` Action string `json:"action" yaml:"action"` Subject string `json:"subject" yaml:"subject"` Params map[string]string `json:"params" yaml:"params"` }
ActionEntry defines the struct of a action
type ActionResult ¶
type ActionResult struct { Code int `json:"code"` // Data map[string]string `json:"data"` Data interface{} `json:"data"` Err error }
ActionResult defines the result struct of a action
func ErrActionResult ¶
func ErrActionResult(en int, args ...interface{}) ActionResult
ErrActionResult returns ActionResult with error
type AuthEntry ¶ added in v1.2.0
type AuthEntry struct { APIID int `json:"api_id" yaml:"api_id"` APIToken string `json:"api_token" yaml:"api_token"` }
AuthEntry defines the auth entry
type Config ¶
type Config struct { Global Global `json:"global" yaml:"global"` Auth Auth `json:"auth" yaml:"auth"` Playbook Playbook `json:"playbook" yaml:"playbook"` }
Config defines the token info for api
func ParseYamlBytes ¶ added in v1.2.0
ParseYamlBytes parse yaml config bytes into Config struct
func ParseYamlFile ¶ added in v1.2.0
ParseYamlFile parses yaml config file into Config struct
type DPA ¶
type DPA struct {
// contains filtered or unexported fields
}
DPA defines the struct for api related info
type Domain ¶
type Domain struct{}
Domain defines the dummy struct
func (Domain) Create ¶ added in v1.1.0
func (d Domain) Create(bs []byte) *DomainCreateResult
Create returns domain created result
func (Domain) Remove ¶ added in v1.1.0
func (d Domain) Remove(bs []byte) *DomainRemoveResult
Remove removes a domain
func (Domain) Status ¶ added in v1.1.0
func (d Domain) Status(bs []byte) *DomainStatusResult
Status sets status of a domain
type DomainCreateInfo ¶ added in v1.1.0
type DomainCreateInfo struct { ID string `json:"id"` Punnycode string `json:"punnycode"` Domain string `json:"domain"` }
DomainCreateInfo defines the struct of field `domain` in create result
type DomainCreateResult ¶ added in v1.1.0
type DomainCreateResult struct { Status RespCommon `json:"status"` Domain DomainCreateInfo `json:"domain"` }
DomainCreateResult defines the API result of `create`
type DomainEntry ¶
type DomainEntry struct { ID string `json:"id"` Status string `json:"status"` Grade string `json:"grade"` GroupID string `json:"group_id"` SearchenginePush string `json:"searchengine_push"` IsMark string `json:"is_marK"` TTL string `json:"ttl"` CnameSpeedup string `json:"cname_speedup"` Remark string `json:"remark"` CreatedOn string `json:"created_on"` UpdatedOn string `json:"updated_on"` Punycode string `json:"punycode"` ExtStatus string `json:"ext_status"` SrcFlag string `json:"src_flag"` Name string `json:"name"` GradeTitle string `json:"grade_title"` IsVIP string `json:"is_ip"` Owner string `json:"owner"` Records string `json:"records"` }
DomainEntry defines the API result struct of domain line
func CreateDomain ¶ added in v1.1.0
func CreateDomain(domain string) (*DomainEntry, error)
CreateDomain creates a domain entry optional param: group_id, is_mark
func CreateDomainDetail ¶ added in v1.1.0
func CreateDomainDetail(domain, groupID, isMark string) (*DomainEntry, error)
CreateDomainDetail with optional params
func GetDomainInfo ¶
func GetDomainInfo(name string) (*DomainEntry, error)
GetDomainInfo returns domain entry
type DomainEntryIDInt ¶
type DomainEntryIDInt struct { ID int `json:"id"` Status string `json:"status"` Grade string `json:"grade"` GroupID string `json:"group_id"` SearchenginePush string `json:"searchengine_push"` IsMark string `json:"is_marK"` TTL string `json:"ttl"` CnameSpeedup string `json:"cname_speedup"` Remark string `json:"remark"` CreatedOn string `json:"created_on"` UpdatedOn string `json:"updated_on"` Punycode string `json:"punycode"` ExtStatus string `json:"ext_status"` SrcFlag string `json:"src_flag"` Name string `json:"name"` GradeTitle string `json:"grade_title"` IsVIP string `json:"is_ip"` Owner string `json:"owner"` Records string `json:"records"` }
DomainEntryIDInt defines same for DomainEntry only id is int
func GetDomainList ¶
func GetDomainList() ([]DomainEntryIDInt, error)
GetDomainList returns domain entry list
type DomainInfoResult ¶
type DomainInfoResult struct { Status RespCommon `json:"status"` Domain DomainEntry `json:"domain"` }
DomainInfoResult defines the API result of `info“
type DomainListInfo ¶
type DomainListInfo struct { DomainTotal int `json:"domain_total"` AllTotal int `json:"all_total"` MineTotal int `json:"mine_total"` VIPTotal int `json:"vip_total"` IsmarkTotal int `json:"ismark_total"` PauseTotal int `json:"pause_total"` ErrorTotal int `json:"error_total"` LockTotal int `json:"lock_total"` SpamTotal int `json:"spam_total"` VIPExpire int `json:"vip_expire"` }
DomainListInfo defines the API struct of `info` field
type DomainListResult ¶
type DomainListResult struct { Status RespCommon `json:"status"` Info DomainListInfo `json:"info"` Domains []DomainEntryIDInt `json:"domains"` }
DomainListResult defines the API result of `list`
type DomainRemoveResult ¶ added in v1.1.0
type DomainRemoveResult struct {
Status RespCommon `json:"status"`
}
DomainRemoveResult defines the API result of `remove`
type DomainStatusResult ¶ added in v1.1.0
type DomainStatusResult struct {
Status RespCommon `json:"status"`
}
DomainStatusResult defines the API result of `status`
type Global ¶ added in v1.2.0
type Global struct { LogOutput string `json:"log_output" yaml:"log_output"` Format string `json:"format" yaml:"format"` Auth string `json:"auth" yaml:"auth"` }
Global defines the `global` section in config file
type InfoVersionResult ¶ added in v1.1.0
type InfoVersionResult struct {
Status RespCommon `json:"status"`
}
InfoVersionResult defines the API result of info.version
type Record ¶
type Record struct{}
Record defines the dummy struct
func (Record) Create ¶
func (r Record) Create(bs []byte) *RecordCreateOrModifyResult
Create returns created record
func (Record) Modify ¶
func (r Record) Modify(bs []byte) *RecordCreateOrModifyResult
Modify returns modified record
func (Record) Remove ¶
func (r Record) Remove(bs []byte) *RecordRemoveResult
Remove returns removed record
func (Record) Status ¶ added in v1.2.0
func (r Record) Status(bs []byte) *RecordStatusResult
Status set status of a record
type RecordCreateOrModifyResult ¶
type RecordCreateOrModifyResult struct { Status RespCommon `json:"status"` Record RecordEntry `json:"record"` }
RecordCreateOrModifyResult defines the API result of `create` or `Modify`
type RecordDomainEntry ¶
type RecordDomainEntry struct { ID string `json:"id"` Name string `json:"name"` TTL int `json:"ttl"` MinTTL int `json:"min_ttl"` Status string `json:"status"` DnspodNS []string `json:"dnspod_ns"` }
RecordDomainEntry defines the `domain field in `list`
type RecordDomainEntryIDInt ¶
type RecordDomainEntryIDInt struct { ID int `json:"id"` Name string `json:"name"` TTL int `json:"ttl"` MinTTL int `json:"min_ttl"` Status string `json:"status"` DnspodNS []string `json:"dnspod_ns"` }
RecordDomainEntryIDInt same as RecordDomainEntry but ID is int
type RecordEntry ¶
type RecordEntry struct { ID string `json:"id"` TTL string `json:"ttl"` Value string `json:"value"` Enabled string `json:"enabled"` Status string `json:"status"` UpdatedOn string `json:"updated_on"` Name string `json:"name"` Line string `json:"line"` LineID string `json:"line_id"` Type string `json:"type"` Weight string `json:"weight"` MonitorStatus string `json:"monitor_status"` Remark string `json:"remark"` UseAqb string `json:"use_aqb"` MX string `json:"mx"` Hold string `json:"hold"` }
RecordEntry defines the API result struct of record line
func CreateRecord ¶
func CreateRecord(domain string, domainID string, data Params) ( *RecordEntry, error)
CreateRecord creates a new record
func GetRecordInfo ¶
func GetRecordInfo(domain string, domainID string, recordID string) (*RecordEntry, error)
GetRecordInfo returns record entry
func ListRecord ¶
func ListRecord(domain string, domainID string) ([]RecordEntry, error)
ListRecord lists all record by domain
func ModifyRecord ¶
func ModifyRecord(domain string, domainID string, recordID string, data Params) ( *RecordEntry, error)
ModifyRecord modifies a record
func (RecordEntry) ExportLine ¶ added in v1.2.0
func (r RecordEntry) ExportLine() string
ExportLine returns a string line for export
type RecordEntryIDInt ¶ added in v1.2.0
type RecordEntryIDInt struct { ID int `json:"id"` TTL string `json:"ttl"` Value string `json:"value"` Enabled string `json:"enabled"` Status string `json:"status"` UpdatedOn string `json:"updated_on"` Name string `json:"name"` Line string `json:"line"` LineID string `json:"line_id"` Type string `json:"type"` Weight string `json:"weight"` MonitorStatus string `json:"monitor_status"` Remark string `json:"remark"` UseAqb string `json:"use_aqb"` MX string `json:"mx"` Hold string `json:"hold"` }
RecordEntryIDInt is same as RecordEntry but ID field is int
type RecordInfoResult ¶
type RecordInfoResult struct { Status RespCommon `json:"status"` Domain RecordDomainEntryIDInt `json:"domain"` Record RecordEntry `json:"record"` }
RecordInfoResult defines the API result of `info`
type RecordListInfo ¶
type RecordListInfo struct { SubDomains string `json:"sub_domains"` RecordTotal string `json:"record_total"` RecordsNum string `json:"records_num"` }
RecordListInfo defines the `info` field in `list`
type RecordListResult ¶
type RecordListResult struct { Status RespCommon `json:"status"` Info RecordListInfo `json:"info"` Records []RecordEntry `json:"records"` }
RecordListResult defiens the API result of `list`
type RecordRemoveResult ¶
type RecordRemoveResult struct {
Status RespCommon `json:"status"`
}
RecordRemoveResult defines the API result of `remove`
type RecordStatusResult ¶ added in v1.2.0
type RecordStatusResult struct { Status RespCommon `json:"status"` Record RecordEntryIDInt `json:"record"` }
RecordStatusResult defines the API result of `status`
type ReflectFunc ¶
type ReflectFunc func(string, Params) ActionResult
ReflectFunc declares the func format to reflect action to different modules
type RespCommon ¶
type RespCommon struct { Code string `json:"code"` Message string `json:"message"` CreatedAt string `json:"created_at"` }
RespCommon defines common struct in http endpoint