Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASMCMS-9225: Create generic API client class #398

Open
wants to merge 2 commits into
base: casmcms-9225-02-endpoints
Choose a base branch
from

Conversation

mharding-hpe
Copy link
Contributor

CASMCMS-9225 as a whole involves changes to a number of different files in BOS. In order to aid with review, I'm breaking the overall thing up into smaller PRs. Each will be built on top of each other, and will be merging into the casmcms-9225-full branch. Only once each sub-PR has been approved and merged will I merge that branch into develop.

This PR creates a generic API client class, built on top of the API endpoint classes from this PR. The APIClient is a subclass of RequestsRetryManager from bos.common.utils, and that is a subclasss of the RequestsRetryManager class from the requests-retry-session Python package.

Basically, the RetrySessionManager class can be used to turn any other class into a context manager that contains a requests session, one that is only initialized if it is used. And this request session (and its underlying HTTP adapter) will both be closed out automatically by the context manager.

The bos.common.utils subclass just specified the default argument values that BOS uses for its requests sessions.

The APIClient subclass includes a method (get_endpoint) which will be used to retrieve endpoints for specific API endpoints. It initializes them on demand, and passes in its managed request session. When used as a context manager, it clears its record of the endpoints that it initialized (because the session they are using is also cleaned up when the context manager exits).

This will be used as the building block for the API clients coming in the next PRs. Right now, this PR does not modify anything to use this client class.

@mharding-hpe mharding-hpe requested a review from a team as a code owner December 17, 2024 17:22
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-02-endpoints branch from f6b566b to 90aa877 Compare December 17, 2024 18:41
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-03-api-clients branch from 66b20d2 to 3b8b36c Compare December 17, 2024 18:43
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-02-endpoints branch from 90aa877 to 725d4a6 Compare December 17, 2024 21:17
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-03-api-clients branch from 664a1a7 to 6268c27 Compare December 17, 2024 21:18
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-02-endpoints branch from 725d4a6 to fda1560 Compare December 17, 2024 23:23
@mharding-hpe mharding-hpe force-pushed the casmcms-9225-03-api-clients branch from 6268c27 to 36528e1 Compare December 17, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants