@@ -245,26 +245,40 @@ func (c *unifiClient) getSiteID() (string, error) {
245245 return "" , fmt .Errorf ("site '%s' not found" , c .site )
246246}
247247
248- // getRecordsNew fetches all DNS policy records using the NEW API.
248+ // dnsPoliciesPageLimit is the number of records to request per page when listing DNS policies.
249+ const dnsPoliciesPageLimit = 200
250+
251+ // getRecordsNew fetches all DNS policy records using the NEW API, paginating as needed.
249252func (c * unifiClient ) getRecordsNew () ([]dnsPolicyRecord , error ) {
250253 siteID , err := c .getSiteID ()
251254 if err != nil {
252255 return nil , err
253256 }
254257
255- path := fmt .Sprintf ("/integration/v1/sites/%s/dns/policies" , siteID )
258+ var allRecords []dnsPolicyRecord
259+ offset := 0
260+ for {
261+ path := fmt .Sprintf ("/integration/v1/sites/%s/dns/policies?offset=%d&limit=%d" , siteID , offset , dnsPoliciesPageLimit )
256262
257- respBytes , err := c .do ("GET" , path , nil )
258- if err != nil {
259- return nil , fmt .Errorf ("failed to fetch records: %w" , err )
260- }
263+ respBytes , err := c .do ("GET" , path , nil )
264+ if err != nil {
265+ return nil , fmt .Errorf ("failed to fetch records: %w" , err )
266+ }
261267
262- var response dnsPolicyResponse
263- if err := json .Unmarshal (respBytes , & response ); err != nil {
264- return nil , fmt .Errorf ("failed to parse records: %w" , err )
268+ var response dnsPolicyResponse
269+ if err := json .Unmarshal (respBytes , & response ); err != nil {
270+ return nil , fmt .Errorf ("failed to parse records: %w" , err )
271+ }
272+
273+ allRecords = append (allRecords , response .Data ... )
274+
275+ if len (response .Data ) < dnsPoliciesPageLimit {
276+ break
277+ }
278+ offset += dnsPoliciesPageLimit
265279 }
266280
267- return response . Data , nil
281+ return allRecords , nil
268282}
269283
270284// createRecordNew creates a new DNS record using the NEW API.
@@ -346,7 +360,7 @@ func (c *unifiClient) detectAPIAvailability() {
346360 if _ , err := c .getSiteID (); err == nil {
347361 // Site ID fetched successfully, try to get records
348362 siteID := c .siteID
349- path := fmt .Sprintf ("/integration/v1/sites/%s/dns/policies" , siteID )
363+ path := fmt .Sprintf ("/integration/v1/sites/%s/dns/policies?limit=1 " , siteID )
350364 if _ , err := c .do ("GET" , path , nil ); err == nil {
351365 newAvailable = true
352366 }
0 commit comments