feat(ami): add register_event_class API and 12 built-in CALL-class events#69
Open
itg-karthicr wants to merge 1 commit into
Open
feat(ami): add register_event_class API and 12 built-in CALL-class events#69itg-karthicr wants to merge 1 commit into
itg-karthicr wants to merge 1 commit into
Conversation
…ents Expose register_event_class() and unregister_event_class() so callers can map a custom Python class to an AMI wire-event name and then wire typed class callbacks without hitting the ValueError that previously blocked that path. The registry build in __init__.py is tightened to filter out non-class symbols (previously re and generic_transforms leaked in), keeping all _Event and _Aggregate subclasses. Twelve EVENT_FLAG_CALL core-signaling events are added as docstring-only _Event subclasses, closing the gap between the 13 events pystrix already typed and the 25 emitted by manager_channels.c / manager_bridges.c: BridgeCreate, BridgeDestroy, BridgeEnter, BridgeLeave, DialBegin, DialEnd, Hold, Unhold, MusicOnHoldStart, MusicOnHoldStop, NewCallerid, NewConnectedLine. The four Bridge classes get a process() override to coerce BridgeNumChannels to int. Docs extend the events section to cover the full callback model (exact-string, catch-all, None orphaned, generic _Event fallback) and add a register_event_class usage example. 122 tests added; 122 pass. Closes #18. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
register_event_class(event_class, name=None)andunregister_event_class(event_class_or_name)as public module-level functions. Users can now map a custom_Eventsubclass to an AMI wire-event name and wire typed class callbacks without hitting theValueErrorthat previously blocked that path (_compile_callback_definitionalready resolves through_EVENT_REGISTRY_REV, so no dispatch changes were needed).__init__.pyto skip non-class symbols (reandgeneric_transformspreviously leaked in; 60 event classes + aggregates remain).EVENT_FLAG_CALLcore-signaling events as docstring-only_Eventsubclasses:BridgeCreate,BridgeDestroy,BridgeEnter,BridgeLeave,DialBegin,DialEnd,Hold,Unhold,MusicOnHoldStart,MusicOnHoldStop,NewCallerid,NewConnectedLine. Wire names verified against Asterisk 13 source.BridgeCreate,BridgeDestroy,BridgeEnter,BridgeLeave) get aprocess()override that coercesBridgeNumChannelsto int (orNoneon failure).doc/examples/ami.rstto cover the full callback model and adds aregister_event_classusage example.Test plan
PYTHONPATH=<worktree> python -m pytest -q— 122 tests, all passruff check . && ruff format --check .— cleantests/test_ami_events.pycovers:register_event_class/unregister_event_classAPI, registry build quality (no junk symbols, aggregates preserved, bidirectional consistency), all 12 new built-in event classes (present incore_eventsand in registry), andBridgeNumChannelsint coercion (numeric, non-numeric, missing-header paths)Closes #18.
🤖 Generated with Claude Code