Documentation ¶
Overview ¶
Package dnspod implements a client for the dnspod API.
In order to use this package you will need a dnspod account and your API Token.
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- type CommonParams
- type Date
- type Domain
- type DomainInfo
- type DomainsService
- type ErrorResponse
- type Record
- type RecordsService
- func (s *RecordsService) Create(domain string, recordAttributes Record) (Record, *Response, error)
- func (s *RecordsService) Delete(domain string, recordID string) (*Response, error)
- func (s *RecordsService) Get(domain string, recordID string) (Record, *Response, error)
- func (s *RecordsService) List(domainID string, recordName string) ([]Record, *Response, error)
- func (s *RecordsService) Update(domain string, recordID string, recordAttributes Record) (Record, *Response, error)
- type Response
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if the status code is different than 2xx. Specific requests may have additional requirements, but this is sufficient in most of the cases.
Types ¶
type Client ¶
type Client struct { // HTTP client used to communicate with the API. HTTPClient *http.Client // CommonParams used communicating with the dnspod API. CommonParams CommonParams // Base URL for API requests. // Defaults to the public dnspod API, but can be set to a different endpoint (e.g. the sandbox). // BaseURL should always be specified with a trailing slash. BaseURL string // User agent used when communicating with the dnspod API. UserAgent string // Services used for talking to different parts of the dnspod API. Domains *DomainsService Records *RecordsService // contains filtered or unexported fields }
Client is the DNSPod client.
func NewClient ¶
func NewClient(params CommonParams) *Client
NewClient returns a new dnspod API client.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. The path is expected to be a relative path and will be resolved according to the BaseURL of the Client. Paths should always be specified without a preceding slash.
type CommonParams ¶
type CommonParams struct { LoginToken string Format string Lang string ErrorOnEmpty string UserID string Timeout int KeepAlive int }
CommonParams is the commons parameters.
type Date ¶
Date custom type.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON handles the deserialization of the custom Date type.
type Domain ¶
type Domain struct { ID json.Number `json:"id,omitempty"` Name string `json:"name,omitempty"` PunyCode string `json:"punycode,omitempty"` Grade string `json:"grade,omitempty"` GradeTitle string `json:"grade_title,omitempty"` Status string `json:"status,omitempty"` ExtStatus string `json:"ext_status,omitempty"` Records string `json:"records,omitempty"` GroupID json.Number `json:"group_id,omitempty"` IsMark string `json:"is_mark,omitempty"` Remark string `json:"remark,omitempty"` IsVIP string `json:"is_vip,omitempty"` SearchenginePush string `json:"searchengine_push,omitempty"` UserID string `json:"user_id,omitempty"` CreatedOn string `json:"created_on,omitempty"` UpdatedOn string `json:"updated_on,omitempty"` TTL string `json:"ttl,omitempty"` CNameSpeedUp string `json:"cname_speedup,omitempty"` Owner string `json:"owner,omitempty"` AuthToAnquanBao bool `json:"auth_to_anquanbao,omitempty"` }
Domain handles domain.
type DomainInfo ¶
type DomainInfo struct { DomainTotal json.Number `json:"domain_total,omitempty"` AllTotal json.Number `json:"all_total,omitempty"` MineTotal json.Number `json:"mine_total,omitempty"` VipTotal json.Number `json:"vip_total,omitempty"` IsMarkTotal json.Number `json:"ismark_total,omitempty"` PauseTotal json.Number `json:"pause_total,omitempty"` ErrorTotal json.Number `json:"error_total,omitempty"` LockTotal json.Number `json:"lock_total,omitempty"` SpamTotal json.Number `json:"spam_total,omitempty"` VipExpire json.Number `json:"vip_expire,omitempty"` }
DomainInfo handles domain information.
type DomainsService ¶
type DomainsService struct {
// contains filtered or unexported fields
}
DomainsService handles communication with the domain related methods of the dnspod API.
dnspod API docs: https://www.dnspod.cn/docs/domains.html
func (*DomainsService) Create ¶
func (s *DomainsService) Create(domainAttributes Domain) (Domain, *Response, error)
Create a new domain.
dnspod API docs: https://www.dnspod.cn/docs/domains.html#domain-create
func (*DomainsService) Delete ¶
func (s *DomainsService) Delete(id int) (*Response, error)
Delete a domain.
dnspod API docs: https://dnsapi.cn/Domain.Remove
func (*DomainsService) Get ¶
func (s *DomainsService) Get(id int) (Domain, *Response, error)
Get fetches a domain.
dnspod API docs: https://www.dnspod.cn/docs/domains.html#domain-info
func (*DomainsService) List ¶
func (s *DomainsService) List() ([]Domain, *Response, error)
List the domains.
dnspod API docs: https://www.dnspod.cn/docs/domains.html#domain-list
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Message string `json:"message"` // human-readable message }
An ErrorResponse represents an error caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Error implements the error interface.
type Record ¶
type Record struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Line string `json:"line,omitempty"` LineID string `json:"line_id,omitempty"` Type string `json:"type,omitempty"` TTL string `json:"ttl,omitempty"` Value string `json:"value,omitempty"` MX string `json:"mx,omitempty"` Enabled string `json:"enabled,omitempty"` Status string `json:"status,omitempty"` MonitorStatus string `json:"monitor_status,omitempty"` Remark string `json:"remark,omitempty"` UpdateOn string `json:"updated_on,omitempty"` UseAQB string `json:"use_aqb,omitempty"` }
Record is the DNS record representation.
type RecordsService ¶ added in v0.4.0
type RecordsService struct {
// contains filtered or unexported fields
}
RecordsService handles communication with the DNS records related methods of the dnspod API.
dnspod API docs: https://www.dnspod.cn/docs/records.html
func (*RecordsService) Create ¶ added in v0.4.0
Create Creates a domain record.
dnspod API docs: https://www.dnspod.cn/docs/records.html#record-create
func (*RecordsService) Delete ¶ added in v0.4.0
func (s *RecordsService) Delete(domain string, recordID string) (*Response, error)
Delete Deletes a domain record.
dnspod API docs: https://www.dnspod.cn/docs/records.html#record-remove
func (*RecordsService) Get ¶ added in v0.4.0
Get Fetches the domain record.
dnspod API docs: https://www.dnspod.cn/docs/records.html#record-info
func (*RecordsService) List ¶ added in v0.4.0
List List the domain records.
dnspod API docs: https://www.dnspod.cn/docs/records.html#record-list
func (*RecordsService) Update ¶ added in v0.4.0
func (s *RecordsService) Update(domain string, recordID string, recordAttributes Record) (Record, *Response, error)
Update Updates a domain record.
dnspod API docs: https://www.dnspod.cn/docs/records.html#record-modify