Skip to content
Nameko Asterisk Manager Interface client
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
nameko_ami
.gitignore
README.md
config.yml
setup.py

README.md

Nameko AMI client

Example of usage

from nameko.events import EventDispatcher
from nameko.dependency_providers import Config
from nameko.rpc import rpc
from nameko_ami import AmiClientExtension, ami

logger = logging.getLogger(__name__)

class AmiBroker:
    name = 'asterisk_ami'
    config = Config()
    ami_client = AmiClientExtension()
    dispatch = EventDispatcher()

    @rpc
    def send_action(self, action):
        result = self.ami_client.manager.send_action(action)        
        return {
            'headers': result.headers,
            'data': result.data,            
        }

    @ami('*')
    def on_ami_event(self, event, manager):
        if self.config.get('ASTERISK_AMI_TRACE_EVENTS'):
            logger.debug('AMI Event: %s', event.headers)
        self.dispatch(event.headers['Event'], {'headers': event.headers,
                                               'data': event.data})

You can’t perform that action at this time.