From 51d9037ab101b0731877daaf4111f513cc10e35f Mon Sep 17 00:00:00 2001 From: Alex Fattouche Date: Mon, 10 Jan 2022 12:14:16 +0000 Subject: [PATCH] Replace hard coded per_page parameter on DNS API with default The API has increased its limit to 5000 therefore its easier for both client and server to grab as many records as possible per query. This may change in the future and therefore we should just use default. https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records --- dns.go | 3 +-- dns_test.go | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dns.go b/dns.go index fa1a367aa83..899f7018f60 100644 --- a/dns.go +++ b/dns.go @@ -94,8 +94,7 @@ func (api *API) CreateDNSRecord(ctx context.Context, zoneID string, rr DNSRecord func (api *API) DNSRecords(ctx context.Context, zoneID string, rr DNSRecord) ([]DNSRecord, error) { // Construct a query string v := url.Values{} - // Request as many records as possible per page - API max is 100 - v.Set("per_page", "100") + // Using default per_page value as specified by the API if rr.Name != "" { v.Set("name", toUTS46ASCII(rr.Name)) } diff --git a/dns_test.go b/dns_test.go index 5d85e47bcaa..b2cc16fdb05 100644 --- a/dns_test.go +++ b/dns_test.go @@ -169,7 +169,6 @@ func TestDNSRecords(t *testing.T) { handler := func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method) - assert.Equal(t, "100", r.URL.Query().Get("per_page")) assert.Equal(t, asciiInput.Name, r.URL.Query().Get("name")) assert.Equal(t, asciiInput.Type, r.URL.Query().Get("type")) assert.Equal(t, asciiInput.Content, r.URL.Query().Get("content"))