All Projects → ettoreleandrotognoli → Python Ami

ettoreleandrotognoli / Python Ami

Licence: bsd-3-clause
Python AMI Client

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python Ami

goami
Asterisk Manager Interface (AMI) client in Go
Stars: ✭ 36 (-48.57%)
Mutual labels:  ami, asterisk
amiws queue
Asterisk Queues Dashboard with amiws
Stars: ✭ 40 (-42.86%)
Mutual labels:  ami, asterisk
Starpy
Mirror of Python twisted library for AMI and FastAGI: No pull requests here please. Use Gerrit: https://gerrit.asterisk.org
Stars: ✭ 77 (+10%)
Mutual labels:  ami, asterisk
Pami
PHP Asterisk Manager Interface ( AMI ) supports synchronous command ( action )/ responses and asynchronous events using the pattern observer-listener. Supports commands with responses with multiple events. Very suitable for development of operator consoles and / or asterisk / channels / peers monitoring through SOA, etc
Stars: ✭ 351 (+401.43%)
Mutual labels:  ami, asterisk
ami
integration asterisk manager interface (AMI) in laravel
Stars: ✭ 25 (-64.29%)
Mutual labels:  ami, asterisk
callme
No description or website provided.
Stars: ✭ 45 (-35.71%)
Mutual labels:  ami, asterisk
Nami
Asterisk manager interface (ami) client for nodejs
Stars: ✭ 94 (+34.29%)
Mutual labels:  ami, asterisk
amiws
Asterisk Management Interface (AMI) to Web-socket proxy
Stars: ✭ 60 (-14.29%)
Mutual labels:  ami, asterisk
ya-node-asterisk
node.js client library for Asterisk Manager Interface
Stars: ✭ 18 (-74.29%)
Mutual labels:  ami, asterisk
Astive
Media controller for Asterisk PBX (FastAGI Server)
Stars: ✭ 37 (-47.14%)
Mutual labels:  ami, asterisk
Soup
☎️ Original open source call flooder using Twilio's API.
Stars: ✭ 267 (+281.43%)
Mutual labels:  asterisk
Ggsignif
Easily add significance brackets to your ggplots
Stars: ✭ 322 (+360%)
Mutual labels:  asterisk
Mikrotik Hotspot Sms
Stars: ✭ 23 (-67.14%)
Mutual labels:  asterisk
Asterisk
Mirror of the official Asterisk (https://www.asterisk.org) Project repository. No pull requests here please. Use Gerrit:
Stars: ✭ 981 (+1301.43%)
Mutual labels:  asterisk
ari
Golang Asterisk REST Interface (ARI) library
Stars: ✭ 121 (+72.86%)
Mutual labels:  asterisk
Cacofonisk
Who's calling?
Stars: ✭ 17 (-75.71%)
Mutual labels:  asterisk
awsm
AWS Automation Tools
Stars: ✭ 18 (-74.29%)
Mutual labels:  ami
suite-crm-click-to-call
SuiteCRM Click to Call (Asterisk)
Stars: ✭ 17 (-75.71%)
Mutual labels:  asterisk
aleph
Aleph is a 3D object viewer and annotation/measurement tool built with A-Frame, AMI, StencilJS, and Ionic
Stars: ✭ 64 (-8.57%)
Mutual labels:  ami
Taupage
THIS PROJECT IS NOT LONGER ACTIVELY MAINTAINED - The base Amazon Machine Image (AMI) allowing dockerized applications to run with STUPS
Stars: ✭ 44 (-37.14%)
Mutual labels:  ami

================= Python AMI Client

.. image:: https://travis-ci.org/ettoreleandrotognoli/python-ami.svg?branch=master :target: https://travis-ci.org/ettoreleandrotognoli/python-ami

.. image:: https://codecov.io/gh/ettoreleandrotognoli/python-ami/branch/master/graph/badge.svg :target: https://codecov.io/gh/ettoreleandrotognoli/python-ami

.. image:: https://badge.fury.io/py/asterisk-ami.svg :target: https://badge.fury.io/py/asterisk-ami

.. image:: https://img.shields.io/pypi/dm/asterisk-ami.svg :target: https://pypi.python.org/pypi/asterisk-ami#downloads

.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/maintainability :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/maintainability :alt: Maintainability

.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/test_coverage :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/test_coverage :alt: Test Coverage

.. image:: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami/badge :target: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami :alt: CodeFactor

A simple Python AMI client http://programandonoaquario.blogspot.com.br

See the code of conduct <CODE_OF_CONDUCT.md>_.

Install

Install asterisk-ami

.. code-block:: shell

pip install asterisk-ami

Install latest asterisk-ami

.. code-block:: shell

pip install git+https://github.com/ettoreleandrotognoli/python-ami

Usage

Connect


.. code-block:: python

    from asterisk.ami import AMIClient
    
    client = AMIClient(address='127.0.0.1',port=5038)
    client.login(username='username',secret='password')
    
Disconnect

.. code-block:: python

client.logoff()

Send an action


.. code-block:: python

    from asterisk.ami import SimpleAction
    
    action = SimpleAction(
        'Originate',
        Channel='SIP/2010',
        Exten='2010',
        Priority=1,
        Context='default',
        CallerID='python',
    )
    client.send_action(action)


Send an action with adapter

.. code-block:: python

from asterisk.ami import AMIClientAdapter

adapter = AMIClientAdapter(client)
adapter.Originate(
    Channel='SIP/2010',
    Exten='2010',
    Priority=1,
    Context='default',
    CallerID='python',
)

Synchronous Response


.. code-block:: python

    #without adapter
    future = client.send_action(action)
    response = future.response
    
    #with adapter
    future = adapter.Originate(...)
    response = future.response
    

Asynchronous Response

.. code-block:: python

def callback_response(response):
    print(response)

#without adapter
future = client.send_action(action,callback=callback_response)

#with adapter
future = adapter.Originate(...,_callback=callback_response)

#you can use the future to wait the callback execute
reponse = future.response

Listen Events


.. code-block:: python

    def event_listener(event,**kwargs):
        print(event)

    client.add_event_listener(event_listener)
    

Filter Events

With a custom class

.. code-block:: python

from asterisk.ami import EventListener

class RegistryEventListener(EventListener):

    def on_Registry(event,**kwargs):
        print('Registry Event',event)
        
client.add_event_listener(RegistryEventListener())

class AllEventListener(EventListener):

    def on_event(event,**kwargs):
        print('Event',event)

client.add_event_listener(AllEventListener())

With black or white list

.. code-block:: python

def event_listener(event,**kwargs):
    print(event)
    
client.add_event_listener(
    event_listener, white_list=['Registry','PeerStatus']
)

client.add_event_listener(
    event_listener, black_list=['VarSet']
)

Like a custom class

.. code-block:: python

def event_listener(event,**kwargs):
    print(event)
    
client.add_event_listener(
    on_VarSet=event_listener,
    on_ExtensionStatus=event_listener
)

client.add_event_listener(
    on_event=event_listener
)

Filter Event Value


.. code-block:: python

    def event_listener(event,**kwargs):
        print('Ringing',event)
        
    
    client.add_event_listener(
        event_listener,
        white_list='Newstate',
        ChannelStateDesc='Ringing',
        ConnectedLineNum='2004',
    )
    
Filter with regex
~~~~~~~~~~~~~~~~~

.. code-block:: python

    import re
    
    def event_listener(event,**kwargs):
        print(event)
        
    client.add_event_listener(
        on_Newstate=event_listener,
        white_list=re.compile('.*'),
        ChannelStateDesc=re.compile('^Ring.*'),
    )
    
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].