DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
709 stars 205 forks source link

Add per_page query paramter to getAll request #288

Closed timramseyjr closed 3 years ago

timramseyjr commented 3 years ago

DO is only returning 20 records per request - which is limited by the per_page query parameter

{
    "domain_records": [{
            {
                "id": 12345,
                "type": "NS",
                "name": "@",
                "data": "ns1.digitalocean.com",
                "priority": null,
                "port": null,
                "ttl": 1800,
                "weight": null,
                "flags": null,
                "tag": null
            },
            ...
        ],
        "links": {
            "pages": {
                "last": "https://api.digitalocean.com/v2/domains/example.com/records?page=2&per_page=20",
                "next": "https://api.digitalocean.com/v2/domains/example.com/records?page=2&per_page=20"
            }
        },
        "meta": {
            "total": 24
        }
    }
GrahamCampbell commented 3 years ago

Thanks, but the correct usage here is to use the result pager class.

GrahamCampbell commented 3 years ago

Please see the readme for more:

image

Using the lazy fetch, you can keep going through until you've seen enough, and break out of your for loop. It'll stop loading from the server at that point.