mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
PORKBUN: implement ListZones() (#2622)
This commit is contained in:
@ -41,6 +41,23 @@ type recordResponse struct {
|
|||||||
Records []domainRecord `json:"records"`
|
Records []domainRecord `json:"records"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type domainListRecord struct {
|
||||||
|
Domain string `json:"domain"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
TLD string `json:"tld"`
|
||||||
|
CreateDate string `json:"createDate"`
|
||||||
|
ExpireDate string `json:"expireDate"`
|
||||||
|
SecurityLock string `json:"securityLock"`
|
||||||
|
WhoisPrivacy string `json:"whoisPrivacy"`
|
||||||
|
AutoRenew string `json:"autoRenew"`
|
||||||
|
NotLocal string `json:"notLocal"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type domainListResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Domains []domainListRecord `json:"domains"`
|
||||||
|
}
|
||||||
|
|
||||||
type nsResponse struct {
|
type nsResponse struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Nameservers []string `json:"ns"`
|
Nameservers []string `json:"ns"`
|
||||||
@ -150,3 +167,21 @@ func (c *porkbunProvider) updateNameservers(ns []string, domain string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *porkbunProvider) listAllDomains() ([]string, error) {
|
||||||
|
params := requestParams{}
|
||||||
|
var bodyString, err = c.post("/domain/listAll", params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed listing all domains from porkbun: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dlr domainListResponse
|
||||||
|
json.Unmarshal(bodyString, &dlr)
|
||||||
|
|
||||||
|
var domains []string
|
||||||
|
for _, domain := range dlr.Domains {
|
||||||
|
domains = append(domains, domain.Domain)
|
||||||
|
}
|
||||||
|
sort.Strings(domains)
|
||||||
|
return domains, nil
|
||||||
|
}
|
||||||
|
9
providers/porkbun/listzones.go
Normal file
9
providers/porkbun/listzones.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package porkbun
|
||||||
|
|
||||||
|
func (client *porkbunProvider) ListZones() ([]string, error) {
|
||||||
|
zones, err := client.listAllDomains()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return zones, err
|
||||||
|
}
|
Reference in New Issue
Block a user