-
Notifications
You must be signed in to change notification settings - Fork 186
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
FEAT: parameterised headers rest_api_source #2084
base: devel
Are you sure you want to change the base?
FEAT: parameterised headers rest_api_source #2084
Conversation
✅ Deploy Preview for dlt-hub-docs canceled.
|
Excuse me for the failed checks, I'll have a look at it! |
All checks should pass now, also added an extra test! |
Hey @ArneDePeuter thanks for the PR and for adding tests! I'll review it soon. |
"headers": { | ||
"{token}": "{token}", | ||
"num": "2", | ||
"nested": {"nested": "{token}", "{token}": "other"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArneDePeuter could you elaborate on the use case the nested headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this for the sake of supporting every use case. After some research tough... headers are mostly flat key value pairs. So I also now question wether this is needed. 😬 I'll remove this functionality!
@burnash I removed the recursive parameter resolution for headers, as this was not useful. |
I now have following question. In: Implemented as this for example: # dlt/sources/rest_api/__init__.py:366
if incremental_object:
params = _set_incremental_params(
params,
incremental_object,
incremental_param,
incremental_cursor_transform,
)
resolved_params.extend(params)
for item in items:
formatted_path, formatted_headers, parent_record = process_parent_data_item(
path, item, resolved_params, include_from_parent, headers
) Secondly, I find it confusing that parameter definitions are intertwined with query params. Is this something that has been brought up before? |
Thanks for the update, @ArneDePeuter
I don't see a need to implement incremental in headers. I haven't seen a use case for incremental parametes in headers yet. If such a case exists, I would suggest implementing a dlt source using
Good point. I have already received this feedback from someone. The way the rest_api source defines parameters is loosely based on how parameters are defined in the OpenAPI specification. I don't find the current implementation too confusing, as the end user has control over how path parameters are named and resolved. They are also excluded from the query parameters. However, I'm open to suggestions on how to improve this. If we extend
What do you think? Would you be willing to update this PR to handle the location key? |
Thanks for your response! |
@burnash I’ve added the Personally I think that this feature adds redundant information, I liked the fact that a param was not bound to a specific location. Params are unique by name so if users would want to make it location based they could use name conventions such as |
Description
This pull request addresses the feature request discussed in issue #2071. It introduces dynamic parameter resolution for headers, allowing both keys and values to be resolved dynamically.
Key Features
Usage
The feature is demonstrated with the following example:
Tests
Comprehensive tests have been added to validate the implementation and ensure its correctness.