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

add request/response hooks to adapter utility #114

Merged
merged 5 commits into from
May 11, 2022
Merged

Conversation

fmigneault
Copy link
Contributor

Changes

  • Add request and response hooks operations to adapter allowing derived implementations to modify OWS proxied requests and returned responses from the service. The default adapter applies no modifications to the original definitions.

I propose to bump to 0.7.0 version after merge. This will help keep track of the new feature separately.

Purpose

For birdhouse-deploy / PAVICS / DACCS project, there is a requirement to inject some headers with user-specific details for specific requests when a service is proxy-requested. Using the MagpieAdapter (see PR Ouranosinc/Magpie#517), it is possible to do so.

This can be used as well by adapters/platforms to filter some specific contents. For example, one could filter listed processes in WPS GetCapabilities response based on different user-access policies, since WPS itself returns all the processes otherwise.

@cehbrecht
Copy link
Member

@fmigneault this PR introduces the "hook". Would you like to add an example/test for the usage?

@fmigneault
Copy link
Contributor Author

Yes good idea.

@fmigneault
Copy link
Contributor Author

@cehbrecht You can have a look at the added test in 2372274. Hooks are used to modify request headers and response body.

@codecov-commenter
Copy link

codecov-commenter commented May 6, 2022

Codecov Report

Merging #114 (7cfe3a1) into master (c9bf424) will increase coverage by 2.03%.
The diff coverage is 79.81%.

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   72.16%   74.20%   +2.03%     
==========================================
  Files          40       41       +1     
  Lines        1703     1795      +92     
==========================================
+ Hits         1229     1332     +103     
+ Misses        474      463      -11     
Impacted Files Coverage Δ
tests/functional/test_api.py 35.71% <0.00%> (-35.72%) ⬇️
tests/functional/test_owsproxy_app.py 25.92% <0.00%> (-18.52%) ⬇️
twitcher/adapter/base.py 53.57% <25.00%> (-5.52%) ⬇️
twitcher/typedefs.py 9.09% <25.00%> (+2.19%) ⬆️
twitcher/adapter/default.py 79.31% <50.00%> (-0.69%) ⬇️
twitcher/owsproxy.py 64.46% <61.11%> (+30.51%) ⬆️
twitcher/models/service.py 85.71% <66.66%> (-5.96%) ⬇️
tests/common.py 100.00% <100.00%> (ø)
tests/functional/base.py 72.72% <100.00%> (-27.28%) ⬇️
tests/functional/test_adapter.py 100.00% <100.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9bf424...7cfe3a1. Read the comment docs.

Copy link
Collaborator

@dbyrns dbyrns left a comment

Choose a reason for hiding this comment

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

Great addition! Thanks.

@fmigneault fmigneault merged commit 348fc74 into master May 11, 2022
@fmigneault fmigneault deleted the request-hooks branch May 11, 2022 21:43
fmigneault added a commit to bird-house/birdhouse-deploy that referenced this pull request May 12, 2022
@fmigneault
Copy link
Contributor Author

@cehbrecht
Is it possible to obtain the release v0.7.0 on PyPI?
I was able to generate the one on Github (https://github.com/bird-house/twitcher/releases/tag/v0.7.0) but I don't have maintainer access for the PyPI project.

I can do the release if you left me know how to do so. I will probably have another 0.7.1 in a near future with more additions.
Thanks

@cehbrecht
Copy link
Member

@fmigneault I have added you as maintainer. You should have received an invite.
https://pypi.org/project/pyramid-twitcher/

@fmigneault
Copy link
Contributor Author

@cehbrecht Thanks a lot. I will look into automating the release procedure on PyPi from a tagged run of Github action/workflow.

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.

5 participants