Skip to content

Commit

Permalink
Enhance GoDaddyProvider.ListZonesAsync method to use marker argument … (
Browse files Browse the repository at this point in the history
#582)

* Enhance GoDaddyProvider.ListZonesAsync method to use marker argument to get paged list of zones #581

* Apply changes from review
  • Loading branch information
johnburns320 authored May 11, 2023
1 parent 8ed15f5 commit 552e761
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions KeyVault.Acmebot/Providers/GoDaddyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,29 @@ public GoDaddyClient(string apiKey, string apiSecret)

public async Task<IReadOnlyList<ZoneDomain>> ListZonesAsync()
{
var response = await _httpClient.GetAsync("v1/domains?statuses=ACTIVE&includes=nameServers");
var limit = 100;
var marker = "";
var allActiveDomains = new List<ZoneDomain>();

response.EnsureSuccessStatusCode();
while (true)
{
var response = await _httpClient.GetAsync($"v1/domains?statuses=ACTIVE&includes=nameServers&limit={limit}{marker}");

response.EnsureSuccessStatusCode();

var domains = await response.Content.ReadAsAsync<ZoneDomain[]>();
var domains = await response.Content.ReadAsAsync<ZoneDomain[]>();

if (domains.Length == 0)
{
break;
}

allActiveDomains.AddRange(domains);

marker = $"&marker={domains[^1].Domain}";
}

return domains;
return allActiveDomains;
}

public async Task DeleteRecordAsync(string domain, string type, string name)
Expand Down

0 comments on commit 552e761

Please sign in to comment.