feat: add DestinationHttpClient to simplify calls to target systems#119
Open
jplbrun wants to merge 7 commits into
Open
feat: add DestinationHttpClient to simplify calls to target systems#119jplbrun wants to merge 7 commits into
jplbrun wants to merge 7 commits into
Conversation
Contributor
|
Update user-guide |
…ion in favor of get_destination
…estination user guide
| Pre-bakes headers derived from the destination — ERP headers (sap-client, | ||
| sap-language), URL.headers.* properties, and auth tokens. | ||
|
|
||
| Usage:: |
Contributor
There was a problem hiding this comment.
Suggested change
| Usage:: | |
| Usage: |
| """ | ||
|
|
||
| def __init__(self, destination: Destination) -> None: | ||
| if destination.type not in (DestinationType.HTTP, "HTTP"): |
Contributor
There was a problem hiding this comment.
Why both DestinationType.HTTP and actual value are validated? Is this needed?
|
|
||
| self._destination = destination | ||
| self._session = requests.Session() | ||
| self._session.headers.update(destination.get_headers()) |
Contributor
There was a problem hiding this comment.
I believe we should also validate if authentication header is present
|
|
||
| assert "missing required fields" in str(exc_info.value) | ||
|
|
||
| def test_get_erp_headers_returns_sap_client(self): |
Contributor
There was a problem hiding this comment.
Can we also include one integration test at least? I can show you how to run locally
| [project] | ||
| name = "sap-cloud-sdk" | ||
| version = "0.18.2" | ||
| version = "0.18.3" |
Contributor
There was a problem hiding this comment.
Increate minor version, since it's a new feature.
Suggested change
| version = "0.18.3" | |
| version = "0.19.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
DestinationHttpClient, arequestswrapper that makes calling a target system from a destination straightforward. Previously, users had to manually fetch an auth token from destination properties and build theAuthorizationheader themselves, and also manually set thesap-clientheader for OnPremise destinations. With this change:The client pre-bakes auth headers from
dest.auth_tokens(populated by the v2 API) and SAP ERP headers (sap-client,sap-language) into the session at construction time.Type of Change
How to Test
dest = client.get_destination("my-destination")http = DestinationHttpClient(dest)response = http.get("/api/resource")uv run pytest tests/destination/unit/test_destination_http_client.py -vRelated Issue
Closes #35
Checklist