Repository navigation
feat(cbc): add CBC (Central Business Configuration) client module #333
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
Open
soumyadey
wants to merge
19
commits into
SAP:main
Choose a base branch
from
soumyadey:feat/cbc-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,044
−4
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c211dde
feat(cbc): add CBC (Central Business Configuration) client module
soumyadey a88e841
feat(cbc): support PEM cert values via env vars and cert_path/key_pat…
soumyadey e240597
fix(cbc): address CI failures — ruff format, ty errors, telemetry cou…
soumyadey dfe418e
fix(cbc): clean up DefaultClient docstring and gitignore
soumyadey dd784da
refactor(cbc): remove local-mode auto-detection
soumyadey 006aefd
fix(cbc): bump telemetry module count to 17 after upstream addition
soumyadey dff43ae
feat(cbc): move tenant_context to client level
soumyadey 3902ada
refactor(cbc): two-layer client contract — thin core + platform adapter
soumyadey a684ad1
perf(cbc): resolve base_url once per get_configuration call
soumyadey ef6832d
fix(cbc): wrap destination errors as CBCConfigError in adapter
soumyadey a615ed2
feat(cbc): reload rotated mTLS certificate on TLS handshake failure
soumyadey 520864f
test(cbc): fix ty type errors in rotation and adapter tests
soumyadey 3c6688a
feat(cbc): add CBCDestinationConfig for the platform adapter
soumyadey 3254907
refactor(cbc): rename EntityContent/EntityData → EntityData/ConfigEntity
soumyadey 12ff0de
fix(cbc): align with confirmed API contract for entity data response
soumyadey cf446e4
chore(cbc): fix ty annotation after ConfigEntity rename; bump version…
soumyadey 86a8c2c
feat(cbc): add get_entity_data for targeted single-entity fetch
soumyadey 0546be7
test(cbc): fix GUIDELINES violations found in code review
soumyadey 07e74c2
feat(cbc): adapt resolve_base_url to direct fragment lookup after PR #82
soumyadey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ env.bak/ | |
| venv.bak/ | ||
| piperBuild-env/ | ||
|
|
||
| # Local scratch | ||
| tmp/ | ||
|
|
||
| # IDEs | ||
| .vscode/ | ||
| .idea/ | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """SAP Cloud SDK for Python — CBC (Central Business Configuration) module. | ||
|
|
||
| Provides a typed Python client for reading tenant-specific business configuration | ||
| from SAP Central Business Configuration (CBC). | ||
|
|
||
| CBC is an SAP service that manages tenant-specific business configuration for | ||
| SAP cloud applications and AI agents. | ||
|
|
||
| Quick start:: | ||
|
|
||
| from sap_cloud_sdk import cbc | ||
|
|
||
| cbc_client = cbc.create_client( | ||
| base_url=lambda: resolve_cbc_url(), | ||
| app_tenant_id=lambda: resolve_app_tenant_id(), | ||
| ssl_context=lambda: build_ssl_ctx(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually just require the user_token on function level. We already have methods to facilitate the retrieve of it using runtime context module. |
||
| ) | ||
| config = cbc_client.get_configuration() | ||
|
|
||
| # Access entity data | ||
| payment = config.get_config_object("payment-config") | ||
| if payment: | ||
| for row in payment.get_entity_data("payment-mode").as_list(): | ||
| print(row) | ||
|
|
||
| Apps running on the SAP application platform can use | ||
| :func:`~sap_cloud_sdk.cbc.client_adapter.create_agent_client` instead, which supplies the | ||
| two resolvers and the mTLS context from the platform's provisioning conventions | ||
| — see the CBC user guide. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from sap_cloud_sdk.cbc.client import ( | ||
| CBCClient, | ||
| DefaultClient, | ||
| create_client, | ||
| ) | ||
| from sap_cloud_sdk.cbc.client_adapter import ( | ||
| CBC_FRAGMENT_PREFIX, | ||
| app_tenant_id_var, | ||
| create_agent_client, | ||
| load_ssl_context, | ||
| resolve_app_tenant_id, | ||
| resolve_base_url, | ||
| tenant_subdomain_var, | ||
| ) | ||
| from sap_cloud_sdk.cbc.config import ( | ||
| CBCDestinationConfig, | ||
| ) | ||
| from sap_cloud_sdk.cbc.exceptions import ( | ||
| CBCError, | ||
| CBCClientError, | ||
| CBCConfigError, | ||
| CBCHttpError, | ||
| CBCNetworkError, | ||
| CBCServerError, | ||
| HttpContext, | ||
| ) | ||
| from sap_cloud_sdk.cbc._models import ( | ||
| ApiError, | ||
| ConfigData, | ||
| ConfigEntity, | ||
| ConfigObject, | ||
| ConsumptionVersion, | ||
| ConsumptionVersions, | ||
| EntityData, | ||
| NNV, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| # factories | ||
| "create_client", | ||
| "create_agent_client", | ||
| # clients | ||
| "CBCClient", | ||
| "DefaultClient", | ||
| # platform adapter | ||
| "app_tenant_id_var", | ||
| "tenant_subdomain_var", | ||
| "CBC_FRAGMENT_PREFIX", | ||
| "CBCDestinationConfig", | ||
| # platform resolvers (compose with create_client to override one axis) | ||
| "resolve_base_url", | ||
| "resolve_app_tenant_id", | ||
| "load_ssl_context", | ||
| # exceptions | ||
| "CBCError", | ||
| "CBCClientError", | ||
| "CBCConfigError", | ||
| "CBCHttpError", | ||
| "CBCNetworkError", | ||
| "CBCServerError", | ||
| "HttpContext", | ||
| # models — consumption versions | ||
| "ConsumptionVersion", | ||
| "ConsumptionVersions", | ||
| "NNV", | ||
| # models — entities | ||
| "EntityData", | ||
| "ConfigEntity", | ||
| "ConfigObject", | ||
| # models — configuration | ||
| "ConfigData", | ||
| # models — api error | ||
| "ApiError", | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be optional and based on SPII? Where user should get this url from?