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 API client: include parent fields in child resource #355

Conversation

willi-mueller
Copy link
Collaborator

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

Tell us what you do here

  • implementing verified source (please link a relevant issue labeled as verified source)
  • fixing a bug (please link a relevant bug report)
  • improving, documenting, or customizing an existing source (please link an issue or describe below)
  • anything else (please link an issue or describe below)

Relevant issue

issue #313

More PR info

This PR allows adding arbitrary fields from the parent resource in the child resource. Example: In Workable, jobs/{shortcode}/recruiters does not include the jobs shortcode. Thus, the response does not tell to which job a recruiter belongs.

For example, a child resource can be specified as follows in order to include confidential and id from the jobs resource in the jobs_id_approval_flows resource:

"jobs/{id}/approval_flows": {
  "params": {
      "id": ResolveConfig("jobs", "id"),
  },
  "resource": {**default_resource_config, "include_from_parent": ["confidential", "id"]},
}

The resulting fields in the child resource are _jobs_confidential and _jobs_id.

Validation

Marked yellow: The parent's resource name is the prefix for its field in the child. This is to avoid name collisions.
Marked green & blue: the field names of the parent are the field names in the child:
Screenshot_2024-02-15_at_18_35_47

Data is loaded. Note that id and _jobs_id are identical which proves that the correct values are taken from the parent record:
Screenshot_2024-02-15_at_18_36_44

Example: In Workable, jobs/{shortcode}/recruiters does not include the jobs shortcode
@willi-mueller willi-mueller marked this pull request as ready for review February 15, 2024 13:15
@burnash burnash merged commit be01033 into dlt-hub:enh/api_helper Feb 16, 2024
@willi-mueller willi-mueller deleted the enh/include-parent-fields-in-child-resource branch February 16, 2024 10:13
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