Skip to content

feat(ami): add register_event_class API and 12 built-in CALL-class events#69

Open
itg-karthicr wants to merge 1 commit into
masterfrom
investigate/issue-18-ami-events
Open

feat(ami): add register_event_class API and 12 built-in CALL-class events#69
itg-karthicr wants to merge 1 commit into
masterfrom
investigate/issue-18-ami-events

Conversation

@itg-karthicr

Copy link
Copy Markdown
Contributor

Summary

  • Adds register_event_class(event_class, name=None) and unregister_event_class(event_class_or_name) as public module-level functions. Users can now map a custom _Event subclass to an AMI wire-event name and wire typed class callbacks without hitting the ValueError that previously blocked that path (_compile_callback_definition already resolves through _EVENT_REGISTRY_REV, so no dispatch changes were needed).
  • Tightens the registry build in __init__.py to skip non-class symbols (re and generic_transforms previously leaked in; 60 event classes + aggregates remain).
  • Adds 12 EVENT_FLAG_CALL core-signaling events as docstring-only _Event subclasses: BridgeCreate, BridgeDestroy, BridgeEnter, BridgeLeave, DialBegin, DialEnd, Hold, Unhold, MusicOnHoldStart, MusicOnHoldStop, NewCallerid, NewConnectedLine. Wire names verified against Asterisk 13 source.
  • Bridge classes (BridgeCreate, BridgeDestroy, BridgeEnter, BridgeLeave) get a process() override that coerces BridgeNumChannels to int (or None on failure).
  • Extends doc/examples/ami.rst to cover the full callback model and adds a register_event_class usage example.

Test plan

  • PYTHONPATH=<worktree> python -m pytest -q — 122 tests, all pass
  • ruff check . && ruff format --check . — clean
  • New test file tests/test_ami_events.py covers: register_event_class / unregister_event_class API, registry build quality (no junk symbols, aggregates preserved, bidirectional consistency), all 12 new built-in event classes (present in core_events and in registry), and BridgeNumChannels int coercion (numeric, non-numeric, missing-header paths)

Closes #18.

🤖 Generated with Claude Code

…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>
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.

Not all AMI events are treated

1 participant