Skip to content

Commit

Permalink
Set defaults for retry logic on instantiation of events API clients; f…
Browse files Browse the repository at this point in the history
…ixes #115
  • Loading branch information
Deconstrained committed Sep 8, 2023
1 parent f1622f7 commit 96c0716
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pdpyras.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,13 @@ class EventsAPISession(PDSession):

url = "https://events.pagerduty.com"

def __init__(self, api_key: str, debug=False):
super(EventsAPISession, self).__init__(api_key, debug)
# See: https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview#response-codes--retry-logic
self.retry[500] = 2 # internal server error, 3 requests total
self.retry[502] = 4 # bad gateway, 5 requests total
self.retry[503] = 6 # service unavailable, 7 requests total

@property
def auth_header(self):
return {}
Expand Down Expand Up @@ -1411,6 +1418,13 @@ class ChangeEventsAPISession(PDSession):

url = "https://events.pagerduty.com"

def __init__(self, api_key: str, debug=False):
super(ChangeEventsAPISession, self).__init__(api_key, debug)
# See: https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview#response-codes--retry-logic
self.retry[500] = 2 # internal server error, 3 requests total
self.retry[502] = 4 # bad gateway, 5 requests total
self.retry[503] = 6 # service unavailable, 7 requests total

@property
def auth_header(self):
return {}
Expand Down

0 comments on commit 96c0716

Please sign in to comment.