ari.client module

ARI client library.

class ari.client.Client(base_url, http_client)[source]

Bases: object

ARI Client object.

Parameters
  • base_url – Base URL for accessing Asterisk.

  • http_client – HTTP client interface.

close()[source]

Close this ARI client.

This method will close any currently open WebSockets, and close the underlying Swaggerclient.

get_repo(name)[source]

Get a specific repo by name.

Parameters

name – Name of the repo to get

Returns

Repository, or None if not found.

Return type

ari.model.Repository

on_application_deregistered(application_name, fn, *args, **kwargs)[source]

Register callback for application deregistered events

Parameters
  • application_name – String name of the stasis application

  • fn ((*args, **kwargs) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_application_registered(application_name, fn, *args, **kwargs)[source]

Register callback for application registered events

Parameters
  • application_name – String name of the stasis application

  • fn ((*args, **kwargs) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_bridge_event(event_type, fn, *args, **kwargs)[source]

Register callback for Bridge related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((Bridge, dict) -> None or (list[Bridge], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_channel_event(event_type, fn, *args, **kwargs)[source]

Register callback for Channel related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((Channel, dict) -> None or (list[Channel], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_device_state_event(event_type, fn, *args, **kwargs)[source]

Register callback for DeviceState related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((DeviceState, dict) -> None or (list[DeviceState], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_endpoint_event(event_type, fn, *args, **kwargs)[source]

Register callback for Endpoint related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((Endpoint, dict) -> None or (list[Endpoint], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_event(event_type, event_cb, *args, **kwargs)[source]

Register callback for events with given type.

Parameters
  • event_type – String name of the event to register for.

  • event_cb ((dict) -> None) – Callback function

  • args – Arguments to pass to event_cb

  • kwargs – Keyword arguments to pass to event_cb

on_live_recording_event(event_type, fn, *args, **kwargs)[source]

Register callback for LiveRecording related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((LiveRecording, dict) -> None or (list[LiveRecording], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_object_event(event_type, event_cb, factory_fn, model_id, *args, **kwargs)[source]

Register callback for events with the given type. Event fields of the given model_id type are passed along to event_cb.

If multiple fields of the event have the type model_id, a dict is passed mapping the field name to the model object.

Parameters
  • event_type – String name of the event to register for.

  • event_cb ((Obj, dict) -> None or (dict[str, Obj], dict) ->) – Callback function

  • factory_fn – Function for creating Obj from JSON

  • model_id – String id for Obj from Swagger models.

  • args – Arguments to pass to event_cb

  • kwargs – Keyword arguments to pass to event_cb

on_playback_event(event_type, fn, *args, **kwargs)[source]

Register callback for Playback related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((Playback, dict) -> None or (list[Playback], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_sound_event(event_type, fn, *args, **kwargs)[source]

Register callback for Sound related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((Sound, dict) -> None or (list[Sound], dict) -> None) – Sound function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

on_stasis_event(event)[source]
on_stored_recording_event(event_type, fn, *args, **kwargs)[source]

Register callback for StoredRecording related events

Parameters
  • event_type – String name of the event to register for.

  • fn ((StoredRecording, dict) -> None or (list[StoredRecording], dict) -> None) – Callback function

  • args – Arguments to pass to fn

  • kwargs – Keyword arguments to pass to fn

run(apps)[source]

Connect to the WebSocket and begin processing messages.

This method will block until all messages have been received from the WebSocket, or until this client has been closed.

Parameters

apps (str or list of str) – Application (or list of applications) to connect for