Skip to content

feat: add DestinationHttpClient to simplify calls to target systems#119

Open
jplbrun wants to merge 7 commits into
mainfrom
feat/special-header-providers
Open

feat: add DestinationHttpClient to simplify calls to target systems#119
jplbrun wants to merge 7 commits into
mainfrom
feat/special-header-providers

Conversation

@jplbrun
Copy link
Copy Markdown
Contributor

@jplbrun jplbrun commented May 13, 2026

Description

Adds DestinationHttpClient, a requests wrapper that makes calling a target system from a destination straightforward. Previously, users had to manually fetch an auth token from destination properties and build the Authorization header themselves, and also manually set the sap-client header for OnPremise destinations. With this change:

dest = client.get_destination("my-destination")
http = DestinationHttpClient(dest)
response = http.get("/api/resource")

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

  1. Get a destination using the v2 API: dest = client.get_destination("my-destination")
  2. Instantiate the client: http = DestinationHttpClient(dest)
  3. Call the target system: response = http.get("/api/resource")
  4. Verify that headers are sent automatically without manual setup
  5. Run unit tests: uv run pytest tests/destination/unit/test_destination_http_client.py -v

Related Issue

Closes #35

Checklist

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

@jplbrun jplbrun marked this pull request as ready for review May 13, 2026 16:49
@jplbrun jplbrun requested a review from a team as a code owner May 13, 2026 16:49
Comment thread src/sap_cloud_sdk/destination/_destination_http_client.py
Comment thread src/sap_cloud_sdk/destination/_destination_http_client.py Outdated
@NicoleMGomes
Copy link
Copy Markdown
Contributor

Update user-guide

Comment thread src/sap_cloud_sdk/destination/_destination_http_client.py Outdated
Pre-bakes headers derived from the destination — ERP headers (sap-client,
sap-language), URL.headers.* properties, and auth tokens.

Usage::
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Usage::
Usage:

"""

def __init__(self, destination: Destination) -> None:
if destination.type not in (DestinationType.HTTP, "HTTP"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we also include one integration test at least? I can show you how to run locally

Comment thread pyproject.toml
[project]
name = "sap-cloud-sdk"
version = "0.18.2"
version = "0.18.3"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Increate minor version, since it's a new feature.

Suggested change
version = "0.18.3"
version = "0.19.0"

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.

Provide Special Header Providers from Java SDK for OnPremise Destinations

3 participants