PagerDuty / pdpyras

Low-level PagerDuty REST/Events API client for Python
MIT License
130 stars 30 forks source link

Pagination doesn't seem to work with `iter_all` #46

Closed jacklund closed 3 years ago

jacklund commented 3 years ago

When I have code like the following:

from pdpyras import APISession

api_token = '<redacted>'
session = APISession(api_token)

for incident in session.iter_all('incidents', params={'service_ids[]': ['<redacted>'], 'since': '2020-08-01T00:00:00Z'}):
    print("{id}\t{created_at}\t{html_url}\t{description}\t{resolve_reason}".format(**incident))

I only get around 25 incidents. If I change the since date, I get a different 25-ish incidents, so it seems like the pagination isn't working. (Also, I know from the PD website that there are definitely much more than 25 incidents for this query).

Any ideas?

Thanks.

blardo commented 3 years ago

Have this same issue - attempting to bulk update incidents using this library with no luck getting pagination to work properly. My result set is limited the same way.

Deconstrained commented 3 years ago

Hi @jacklund and @blardo,

In the incidents API, if one does not specify both ends of a date range, it will default to one month that begins at since or ends at until. In this example here it would only return incidents in the range 2020-08-01 thru 2020-09-01.

I have submitted an internal issue ticket to document this behavior in the appropriate place.

For all questions specifically pertaining to the API, Customer Support and the PagerDuty forums are the best places to get help.