-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): add retries to aws boto calls (#88)
* feat(auth): add retries to aws boto calls the standard boto client defaults to 'legacy' which retries certain HTTP status codes and a limited set of service errors. update retry config to 'standard' which has a broader set of errors/exceptions. in particular it will retry 'TooManyRequestsException' which can be throttled in high burst situations. max retries can be configured by setting the 'STAX_API_AUTH_MAX_RETRIES' environment var. * feat(api): add default retry configuration to stax api calls add default retries for stax api calls. allow these configuration to be modified by consumers. amended prior boto3 configuration to opt for storing in the Stax config object. marked existing token threshold ENV configuration as deprecated. * chore(sdk): update comment with deprecated notice
- Loading branch information
1 parent
344f761
commit 96fd9ce
Showing
11 changed files
with
214 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
import os | ||
|
||
from staxapp.config import Config, StaxAPIRetryConfig, StaxAuthRetryConfig | ||
from staxapp.openapi import StaxClient | ||
|
||
Config.access_key = os.getenv("STAX_ACCESS_KEY") | ||
Config.secret_key = os.getenv("STAX_SECRET_KEY") | ||
|
||
# Retry Config for Stax API calls | ||
retry_config = StaxAPIRetryConfig | ||
retry_config.retry_methods = ('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS') | ||
retry_config.status_codes = (429, 500) | ||
|
||
Config.api_retry_config = retry_config | ||
|
||
# Retry config for Stax Authentication calls | ||
auth_retry_config = StaxAuthRetryConfig | ||
auth_retry_config.max_attempts = 3 | ||
|
||
Config.api_auth_retry_config = auth_retry_config | ||
|
||
# Read all accounts within your Stax Organisation | ||
accounts = StaxClient("accounts") | ||
response = accounts.ReadAccounts() | ||
print(json.dumps(response, indent=4, sort_keys=True)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ pylint | |
pytest | ||
pytest-cov | ||
responses | ||
requests | ||
pyjwt==2.4.0 | ||
boto3 | ||
aws_requests_auth | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.