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

generic requests using the api client #330

Merged
merged 6 commits into from
Mar 13, 2025
Merged

Conversation

brandon-groundlight
Copy link
Collaborator

@brandon-groundlight brandon-groundlight commented Mar 13, 2025

Provides a way to custom construct your own requests to groundlight. There's potential to clean it up when we deprecate the GroundlightApiClient class

Copy link
Member

@robotrapta robotrapta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is certainly helpful for what I'm trying to do. The architecture here still feels wonky in that this stuff which feels like "standard way to format a request" is happening all over the place, and not in a single method like this which everything else is relying on. I guess that's the price we pay for relying on the openapi generator, which has a bunch of other benefits.

headers["Accept"] = "application/json"
return headers

def make_raw_rest_request(self, method: str, endpoint: str, body: Union[dict, None] = None) -> dict:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave this out unless we have a really good reason to include it. One of these feels helpful, two starts to sound confusing.

return response.json()

def make_generic_api_request( # noqa: PLR0913 # pylint: disable=too-many-arguments
self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self,
self,
*,

We could require the arguments to be named, not positionally-ordered. Feels like a good practice for these methods with tons of arguments, although this one is mercifully more succinct than the openapi provided ones.

Is this the right syntax for that?

@brandon-groundlight brandon-groundlight changed the title Two ways to make generic requests using the api client generic requests using the api client Mar 13, 2025
@brandon-groundlight brandon-groundlight merged commit cb3fd95 into main Mar 13, 2025
8 checks passed
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