Skip to content

feat: new methods to return destination instance id and client id for agw#198

Merged
NicoleMGomes merged 7 commits into
mainfrom
feat/improvements-internal-lib
Jul 6, 2026
Merged

feat: new methods to return destination instance id and client id for agw#198
NicoleMGomes merged 7 commits into
mainfrom
feat/improvements-internal-lib

Conversation

@NicoleMGomes

@NicoleMGomes NicoleMGomes commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Disclaimer: Do not include SAP-internal or customer-specific information in this PR (e.g. internal system URLs, customer names, tenant IDs, or confidential configurations). This is a public repository.

Description

Adds two new public methods and supporting infrastructure for resolving runtime identity credentials:

  • DestinationClient.get_service_instance_id(): reads the destination service instance ID from mounted secrets via the standard mount/env-var fallback resolver. Raises DestinationOperationError on failure.
  • AgentGatewayClient.get_ias_client_id(): returns the IAS client ID, auto-detecting agent type (Customer vs LoB). Customer agents read client_id from the mounted credentials file; LoB agents fetch the sap-managed-runtime-ias-{landscape} destination at provider subaccount level using the new skip_token_retrieval option. Raises AgentGatewaySDKError on failure.
  • ConsumptionOptions.skip_token_retrieval: new field that passes $skipTokenRetrieval=true to the Destination Service v2 API, skipping OAuth2 token exchange when only destination properties are needed.

Both methods are instrumented with telemetry (record_metrics) and covered by unit and integration tests.

Related Issue

Closes #

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. Unit tests: uv run pytest tests/destination/unit/test_client.py::TestGetServiceInstanceId tests/agentgateway/unit/test_agw_client.py::TestGetIasClientId tests/agentgateway/unit/test_lob.py::TestGetIasClientIdLob -v
  2. For get_service_instance_id: set CLOUD_SDK_CFG_DESTINATION_DEFAULT_INSTANCEID=<your-id> and call DestinationClient(...).get_service_instance_id() — expect the value back; unset the env var and call again — expect DestinationOperationError.
  3. For get_ias_client_id (LoB): with a bound destination service and APPFND_CONHOS_LANDSCAPE set, call AgentGatewayClient(tenant_subdomain="...").get_ias_client_id() — expect the IAS clientId from the sap-managed-runtime-ias-{landscape} destination.
  4. For get_ias_client_id (Customer): with a credentials file mounted at the standard path, call AgentGatewayClient().get_ias_client_id() — expect client_id from the credentials file.
  5. Integration tests (requires BTP binding): uv run pytest tests/destination/integration/ tests/agentgateway/integration/ -k "instance_id or ias_client_id"

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 updated documentation (if applicable)
  • 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

Additional Notes

The skip_token_retrieval option is used internally by the LoB flow of get_ias_client_id() to avoid an unnecessary OAuth2 token exchange when fetching the IAS destination — only the destination properties (clientId) are needed. The $skipTokenRetrieval query parameter is a supported Destination Service v2 API feature.

@NicoleMGomes NicoleMGomes changed the title Feat/improvements internal lib feat: new methods to return destination instance id and client id for agw Jul 3, 2026
@NicoleMGomes NicoleMGomes marked this pull request as ready for review July 3, 2026 22:34
@NicoleMGomes NicoleMGomes requested a review from a team as a code owner July 3, 2026 22:34
@NicoleMGomes NicoleMGomes force-pushed the feat/improvements-internal-lib branch from d816255 to de19d4e Compare July 6, 2026 15:36
@NicoleMGomes NicoleMGomes merged commit d19427f into main Jul 6, 2026
11 checks passed
@NicoleMGomes NicoleMGomes deleted the feat/improvements-internal-lib branch July 6, 2026 16:07
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