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

[REST API source] adds function to check connection #357

Merged

Conversation

willi-mueller
Copy link
Collaborator

@willi-mueller willi-mueller commented Feb 16, 2024

Tell us what you do here

  • improving, documenting, or customizing an existing source (please link an issue or describe below)

Relevant issue

issue #313

More PR info

This PR adds a convenience function to test whether a configuration can connect to the API endpoint.

Possible usages

  1. allows easy checking if credentials are correct. Especially when dlt is embedded and used as a fivetran-type data platform where pipeline users enter their credentials in some UI or config file.
  2. provides a clear way to test authentication, especially in the absence of an auth verification endpoint

See demo in rest_api_pipeline.py for ways of using this function.

Disadvantages of current implementation strategy

Requires awareness of the developer that it yields from the source. If a call to check_connection() is part of a pipeline run, it must be used with a separate source object to avoid losing data.

I tried calling copy.deepcopy on the source argument, but it crashed with RecursionError: maximum recursion depth exceeded

Alternatives

Implement check_connection as a method on a subclass of DltSource, e.g. GenericApiSource

@willi-mueller willi-mueller changed the title adds function to check the connection of a REST API source. Adds demo… [REST API source] adds function to check connection Feb 16, 2024
@willi-mueller willi-mueller marked this pull request as ready for review February 16, 2024 12:59
@willi-mueller willi-mueller force-pushed the enh/check-rest-connection branch from f70a2b3 to 6c4e311 Compare February 27, 2024 12:44
@burnash burnash merged commit 06a054e into dlt-hub:enh/api_helper Feb 27, 2024
burnash added a commit that referenced this pull request Mar 22, 2024
* REST API: support all authentication methods (#354)
* Generic API client: include parent fields in child resource (#355)
* Rest API: Ends pagination if next page path is not in response.json() (#361)
* Allow specification of SinglePagePaginator and refactors redundancy (#364)
* [REST Source] renames default_paginator argument to paginator (#367)
* [REST Source] completes renaming of default_paginator to paginator (#370)
* [REST source] test case for dependent resource (#371)
* [REST API source] adds function to check connection (#357)
* [REST Source] allow skipping http errors (#365)
* added the possibility to pass HTTPBasicAuth objects (#377)
* [REST] Detailed error handler logging (#383)
* [REST source] header_links can extract from responses without a records_path (#382)
* [REST source] fixes deprecation warning (#380)
* [REST CLIENT] alt response extractor (#396)
* Makes openapi friendly auth (#397)
* [REST CLIENT] yields data pages with requests context (#399)

---------

Co-authored-by: Anton Burnashev <[email protected]>
Co-authored-by: Willi Müller <[email protected]>
Co-authored-by: mucio <[email protected]>
Co-authored-by: rudolfix <[email protected]>
Co-authored-by: Steinthor Palsson <[email protected]>
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