Repository navigation
Conversation
Add FeatureStatus and FeatureStatuses models, two new client methods (get_feature_statuses, get_feature_status), matching unit tests, BDD integration scenarios, and user-guide coverage.
…vents Introduces CBCEventHandler that parses incoming CBC CloudEvents (using the cloudevents SDK v2.x) and dispatches them to registered callbacks. Adds ConsumptionVersionEvent and FeatureActivationEvent models, CBCEventError exception, and documents event handling in the user guide.
Member
Author
|
Self-review using the repo's PR ReviewPR Review: #422: feat(cbc): add CBCEventHandler and feature status APIAuthor: Soumya Dey Branch: A: Process & Compliance
B: Security & Sensitive Data
C: Code Quality
D: API & Design
E: Tests & Documentation
✅ Things Done Well
Security ReviewSecurity Review: #422: feat(cbc): add CBCEventHandler and feature status APIAuthor: Soumya Dey Branch:
✅ Things Done Well
|
This branch has not been deployed
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
Extends
sap_cloud_sdk.cbcwith two features requested in #412:1. Feature status pull API on
CBCClient—get_feature_statuses()returns aFeatureStatusesobject listing all AI feature activation states for the current app tenant;get_feature_status(feature_id)queries a single feature server-side and returnsFeatureStatus | None.2.
CBCEventHandler— parses incoming CBC CloudEvents (using thecloudeventsSDK v2.x) from a raw HTTP request and dispatches to registered callbacks. Supports three CBC event types:cbc.notification.consumptionversion.created,cbc.notification.consumptionversion.updated, andcbc.notification.feature.activation.v1. RaisesCBCEventError(subclass ofCBCError) on malformed envelopes or structurally invalid event data; unknown event types are silently ignored.New public symbols:
CBCEventHandler,ConsumptionVersionEvent,FeatureActivationEvent,FeatureActivationData,CBCEventError— all exported fromsap_cloud_sdk.cbc.Related Issue
Closes #412
Type of Change
How to Test
Unit tests (no external service required):
Expected result: 101 unit tests pass.
Integration tests (real BTP service, default provisioning path):
8 passed in 41.93s
Checklist
/security-reviewand addressed all ❌ findingsBreaking Changes
None. Additive only — no existing public API is changed.
Additional Notes
Key design decisions:
CBCEventHandlerusescloudevents>=2.2.0(cloudevents.core.*), the ground-up 2.x rewrite of the official CNCF Python SDK, rather than the 1.x compat layer (cloudevents.v1.*). The 2.x deserialization API —from_http_event(HTTPMessage(headers, body))— auto-detects binary vs. structured CloudEvent mode and returns an immutableBaseCloudEventwith explicit getter methods (get_type(),get_data()), so the handler accepts both transport modes without any branching.on_consumption_version_eventandon_feature_activation_eventeach register one callback, replacing any previously registered one. This keeps the dispatch contract simple and predictable; fan-out is the application's responsibility if needed. If no callback is registered for a received event type, the event is silently dropped.ConsumptionVersionEvent,FeatureActivationEvent, andFeatureActivationDataare dedicated plain Python classes. ReusingFeatureStatusfrom the pull API would couple two independently evolving wire formats. Internal wire-format models (_TenantContext,_ConsumptionVersionPayload,_FeatureActivationItem) are Pydantic frozen models with camelCase aliases — same pattern as the rest of_models.py.get_feature_statuses()andget_feature_status(feature_id)mirrorget_configuration/get_entity_datain structure — same error handling, same provisioning path.