diff --git a/documentation/provider/index.md b/documentation/provider/index.md index 168423dbc..301d6d7c6 100644 --- a/documentation/provider/index.md +++ b/documentation/provider/index.md @@ -91,7 +91,7 @@ Jump to a table: | ------------- | -------------------------------------------------------------------- | ---------------------------------------------- | -------------- | --------- | | [`ADGUARDHOME`](adguardhome.md) | ❔ | ❔ | ❌ | ❌ | | [`AKAMAIEDGEDNS`](akamaiedgedns.md) | ❔ | ✅ | ✅ | ✅ | -| [`ALIDNS`](alidns.md) | ✅ | ❌ | ❌ | ❔ | +| [`ALIDNS`](alidns.md) | ✅ | ❌ | ❌ | ✅ | | [`AUTODNS`](autodns.md) | ✅ | ❌ | ❌ | ✅ | | [`AXFRDDNS`](axfrddns.md) | ✅ | ❌ | ❌ | ❌ | | [`AZURE_DNS`](azure_dns.md) | ✅ | ✅ | ✅ | ✅ | diff --git a/providers/alidns/aliDnsProvider.go b/providers/alidns/aliDnsProvider.go index 076829dc6..31e068a20 100644 --- a/providers/alidns/aliDnsProvider.go +++ b/providers/alidns/aliDnsProvider.go @@ -15,6 +15,7 @@ import ( var features = providers.DocumentationNotes{ providers.CanUseAlias: providers.Cannot(), + providers.CanGetZones: providers.Can(), providers.CanUseCAA: providers.Can(), providers.CanUsePTR: providers.Cannot(), providers.CanUseNAPTR: providers.Cannot(), @@ -119,6 +120,10 @@ func (a *aliDnsDsp) GetZoneRecords(domain string, meta map[string]string) (model return out, nil } +func (a *aliDnsDsp) ListZones() ([]string, error) { + return a.describeDomainsAll() +} + func removeTrailingDot(record string) string { return strings.TrimSuffix(record, ".") } diff --git a/providers/alidns/api.go b/providers/alidns/api.go index 538414a03..01388e950 100644 --- a/providers/alidns/api.go +++ b/providers/alidns/api.go @@ -149,3 +149,27 @@ func (a *aliDnsDsp) describeDomainRecordsAll(domain string) ([]*alidns.Record, e } return out, nil } + +func (a *aliDnsDsp) describeDomainsAll() ([]string, error) { + // describeDomainsAll fetches all domains in the account, handling pagination. + fetch := func(pageNumber, pageSize int) ([]string, int, error) { + req := alidns.CreateDescribeDomainsRequest() + req.PageNumber = requests.NewInteger(pageNumber) + req.PageSize = requests.NewInteger(pageSize) + + resp, err := a.client.DescribeDomains(req) + if err != nil { + return nil, 0, err + } + + domains := make([]string, 0, len(resp.Domains.Domain)) + for _, d := range resp.Domains.Domain { + domains = append(domains, d.DomainName) + } + + total := int(resp.TotalCount) + return domains, total, nil + } + + return paginateAll(fetch) +}