Skip to main content

Producer Events Asterisk Manager Interface (AMI) for RabbitMQ Broker

Project description

AMI2RabbitMQ

Overview

Is a consumer of events produced by the Asterisk Manager Interface, where it organizes endpoints, bridges and queues into entities, persisting the last state on a redis server and producing an event for a queue on a RabbitMQ server.

The generated data is persisted on the Redis Server with keys starting with the prefix Online:< SUFIX >.

Dependencies

It is necessary to have Redis, RabbitMQ, Asterisk installed and configured to use the lib.

Installing AMI2RabbitMQ and Supported Versions

AMI2RabbitMQ is available on PyPI:

$ python -m pip install ami2rabbitmq

AMI2RabbitMQ officially supports Python 3.8+.

Cloning the repository

https://github.com/tatianno/ami2rabbitmq.git

Examples

Simple producer application

from ami2rabbitmq import AMI2RabbitMQ


AMI_SETTINGS = {
    'host' : 'localhost',
    'user' : 'user',
    'password' : 'password'
}

RABBITMQ_SETTINGS = RABBITMQ_SETTINGS = {
    'host' : 'localhost',
    'user' : 'user',
    'password' : 'password',
    'queuename' : 'online'
}

producer = AMI2RabbitMQ(
    ami_settings = AMI_SETTINGS,
    rabbitmq_settings = RABBITMQ_SETTINGS,
)

producer.run()

Advanced producer application

from ami2rabbitmq import AMI2RabbitMQ


AMI_SETTINGS = {
    'host' : 'localhost',
    'user' : 'user',
    'password' : 'password'
}

RABBITMQ_SETTINGS = RABBITMQ_SETTINGS = {
    'host' : 'localhost',
    'user' : 'user',
    'password' : 'password',
    'queuename' : 'online'
}


class CustomProducerApp(AMI2RabbitMQ):

    def update_events(self):
        '''
        The change_entities variable receives a list containing the entities that received state change events.

        Entities can be of the type:

        - Bridge : Call established between two endpoints
        - QueueCaller : Call waiting in a queue
        - Endpoint : Can be an extension or trunk
        - QueueMember : Member of a queue
        - Queue : Service queue

        Entities are available for import:

        import from ami2rabbitmq.entities import Bridge, Endpoint, QueueCaller, QueueMember, Queue
        '''
        change_entities = self._pabx.update(self.last_events)
        self._send_change_to_broker(change_entities)


custom_producer = CustomProducerApp(
    ami_settings = AMI_SETTINGS,
    rabbitmq_settings = RABBITMQ_SETTINGS,
)

custom_producer.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ami2rabbitmq-0.2.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file ami2rabbitmq-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ami2rabbitmq-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d286ad8466abf9e104294dd06e15cef4ffb3a8f676a48290b0b991356ee62d21
MD5 7051d86cc4efe326b579e6c4f2b4c70e
BLAKE2b-256 93f009755c18d574df43f73a3f60a26a522c0861947416aaa832872417fb38a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page