From 552e761e6ce2615ff696fb37829d24fcb3e0190f Mon Sep 17 00:00:00 2001 From: John Burns Date: Thu, 11 May 2023 01:44:41 -0500 Subject: [PATCH] =?UTF-8?q?Enhance=20GoDaddyProvider.ListZonesAsync=20meth?= =?UTF-8?q?od=20to=20use=20marker=20argument=20=E2=80=A6=20(#582)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Enhance GoDaddyProvider.ListZonesAsync method to use marker argument to get paged list of zones #581 * Apply changes from review --- KeyVault.Acmebot/Providers/GoDaddyProvider.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/KeyVault.Acmebot/Providers/GoDaddyProvider.cs b/KeyVault.Acmebot/Providers/GoDaddyProvider.cs index cf244fee..96173103 100644 --- a/KeyVault.Acmebot/Providers/GoDaddyProvider.cs +++ b/KeyVault.Acmebot/Providers/GoDaddyProvider.cs @@ -81,13 +81,29 @@ public GoDaddyClient(string apiKey, string apiSecret) public async Task> ListZonesAsync() { - var response = await _httpClient.GetAsync("v1/domains?statuses=ACTIVE&includes=nameServers"); + var limit = 100; + var marker = ""; + var allActiveDomains = new List(); - 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(); + var domains = await response.Content.ReadAsAsync(); + + 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)