def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] bus_publisher = dependencies['bus_publisher'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] amid_client = AmidClient(**config['amid']) token_changed_subscribe(amid_client.set_token) notifier = AdhocConferencesNotifier(bus_publisher) adhoc_conferences_service = AdhocConferencesService(amid_client, ari.client, notifier) startup_callback_collector = CallbackCollector() adhoc_conferences_stasis = AdhocConferencesStasis(ari, notifier) ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(adhoc_conferences_stasis.initialize) api.add_resource( UserAdhocConferencesResource, '/users/me/conferences/adhoc', resource_class_args=[adhoc_conferences_service], ) api.add_resource( UserAdhocConferenceResource, '/users/me/conferences/adhoc/<adhoc_conference_id>', resource_class_args=[adhoc_conferences_service], ) api.add_resource( UserAdhocConferenceParticipantResource, '/users/me/conferences/adhoc/<adhoc_conference_id>/participants/<call_id>', resource_class_args=[adhoc_conferences_service], )
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] bus_publisher = dependencies['bus_publisher'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] amid_client = AmidClient(**config['amid']) confd_client = ConfdClient(**config['confd']) token_changed_subscribe(amid_client.set_token) token_changed_subscribe(confd_client.set_token) state_persistor = StatePersistor(ari.client) transfer_lock = TransferLock() transfers_service = TransfersService(amid_client, ari.client, confd_client, state_factory, state_persistor, transfer_lock) transfers_stasis = TransfersStasis(amid_client, ari, transfers_service, state_factory, state_persistor, config['uuid']) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(transfers_stasis.initialize) notifier = TransferNotifier(bus_publisher) state_factory.set_dependencies(amid_client, ari.client, notifier, transfers_service, state_persistor, transfer_lock) kwargs = {'resource_class_args': [transfers_service]} api.add_resource(TransfersResource, '/transfers', **kwargs) api.add_resource(TransferResource, '/transfers/<transfer_id>', **kwargs) api.add_resource(TransferCompleteResource, '/transfers/<transfer_id>/complete', **kwargs) api.add_resource(UserTransfersResource, '/users/me/transfers', **kwargs) api.add_resource(UserTransferResource, '/users/me/transfers/<transfer_id>', **kwargs) api.add_resource(UserTransferCompleteResource, '/users/me/transfers/<transfer_id>/complete', **kwargs)
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] bus_consumer = dependencies['bus_consumer'] bus_publisher = dependencies['bus_publisher'] amid_client = AmidClient(**config['amid']) token_changed_subscribe(amid_client.set_token) conferences_service = ConferenceService(amid_client, ari.client) conferences_bus_event_handler = ConferencesBusEventHandler(bus_publisher) conferences_bus_event_handler.subscribe(bus_consumer) stasis = ConferenceAdhocStasis(ari, conferences_service) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(stasis.initialize) api.add_resource(ConferencesResource, '/conferences', resource_class_args=[conferences_service]) api.add_resource(ConferenceResource, '/conferences/<conference_id>', resource_class_args=[conferences_service]) api.add_resource(ConferenceResourceVerify, '/conferences/verify/<conference_id>', resource_class_args=[conferences_service]) api.add_resource(ConferencesAdhocResource, '/conferences/adhoc', resource_class_args=[conferences_service]) api.add_resource(ConferenceAdhocResource, '/conferences/adhoc/<conference_id>', resource_class_args=[conferences_service]) api.add_resource(ConferenceParticipantAdhocResource, '/conferences/adhoc/<conference_id>/calls/<call_id>', resource_class_args=[conferences_service])
def load(self, dependencies): ari = dependencies['ari'] api = dependencies['api'] config = dependencies['config'] bus_publisher = dependencies['bus_publisher'] notifier = SttNotifier(bus_publisher) stt_service = SttService(config, ari.client, notifier) stasis = SttStasis(config, ari, stt_service) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe( startup_callback_collector.new_source()) startup_callback_collector.subscribe(stasis.initialize) api.add_resource(SttCreateResource, '/stt', resource_class_args=[stt_service]) api.add_resource(SttResource, '/stt/<call_id>', resource_class_args=[stt_service])
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] bus_consumer = dependencies['bus_consumer'] bus_publisher = dependencies['bus_publisher'] confd_client = ConfdClient(**config['confd']) token_changed_subscribe(confd_client.set_token) confd_cache = ConfdCache(confd_client) notifier = EndpointStatusNotifier(bus_publisher, confd_cache) status_cache = NotifyingStatusCache(notifier.endpoint_updated, ari.client) endpoints_service = EndpointsService(confd_cache, status_cache) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(status_cache.initialize) event_handler = EventHandler(status_cache, confd_cache) event_handler.subscribe(bus_consumer) api.add_resource( TrunkEndpoints, '/trunks', resource_class_args=[ endpoints_service, ], ) api.add_resource( LineEndpoints, '/lines', resource_class_args=[ endpoints_service, ], )
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] bus_publisher = dependencies['bus_publisher'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] amid_client = AmidClient(**config['amid']) confd_client = ConfdClient(**config['confd']) token_changed_subscribe(amid_client.set_token) token_changed_subscribe(confd_client.set_token) relocates = RelocateCollection() state_factory = StateFactory(state_index, amid_client, ari.client) notifier = RelocatesNotifier(bus_publisher) relocates_service = RelocatesService(amid_client, ari.client, confd_client, notifier, relocates, state_factory) relocates_stasis = RelocatesStasis(ari, relocates) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe( startup_callback_collector.new_source()) startup_callback_collector.subscribe(relocates_stasis.initialize) kwargs = {'resource_class_args': [relocates_service]} api.add_resource(UserRelocatesResource, '/users/me/relocates', **kwargs) api.add_resource(UserRelocateResource, '/users/me/relocates/<relocate_uuid>', **kwargs) api.add_resource(UserRelocateCompleteResource, '/users/me/relocates/<relocate_uuid>/complete', **kwargs) api.add_resource(UserRelocateCancelResource, '/users/me/relocates/<relocate_uuid>/cancel', **kwargs)
def load(self, dependencies): ari = dependencies['ari'] pubsub = dependencies['pubsub'] bus_consumer = dependencies['bus_consumer'] token_changed_subscribe = dependencies['token_changed_subscribe'] config = dependencies['config'] bus_publisher = dependencies['bus_publisher'] amid_client = AmidClient(**config['amid']) token_changed_subscribe(amid_client.set_token) auth_client = AuthClient(**config['auth']) token_changed_subscribe(auth_client.set_token) notifier = Notifier(bus_publisher) service = DialMobileService(ari, notifier, amid_client, auth_client) stasis = DialMobileStasis(ari, service) event_handler = EventHandler(service) event_handler.subscribe(bus_consumer) pubsub.subscribe('stopping', lambda _: service.on_calld_stopping()) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(stasis.initialize)
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] asyncio = dependencies['asyncio'] bus_publisher = dependencies['bus_publisher'] bus_consumer = dependencies['bus_consumer'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] next_token_changed_subscribe = dependencies['next_token_changed_subscribe'] confd_client = ConfdClient(**config['confd']) switchboard_get_cache = ConfdClientGetUUIDCacheDecorator( confd_client.switchboards.get, resource_name='switchboard' ) confd_client.switchboards.get = switchboard_get_cache line_get_cache = ConfdClientGetIDCacheDecorator( confd_client.lines.get, resource_name='line' ) confd_client.lines.get = line_get_cache user_line_get_cache = ConfdClientUserLineGetCacheDecorator( confd_client.users.get, resource_name='user' ) confd_client.users.get = user_line_get_cache token_changed_subscribe(confd_client.set_token) switchboards_notifier = SwitchboardsNotifier(bus_publisher) switchboards_service = SwitchboardsService( ari.client, asyncio, confd_client, switchboards_notifier ) switchboards_stasis = SwitchboardsStasis( ari, confd_client, switchboards_notifier, switchboards_service ) switchboard_get_cache.subscribe( bus_consumer, events=['switchboard_edited', 'switchboard_deleted'] ) # line-endpoint association emits line_edited too line_get_cache.subscribe(bus_consumer, events=['line_edited', 'line_deleted']) user_line_get_cache.subscribe(bus_consumer) startup_callback_collector = CallbackCollector() next_token_changed_subscribe(startup_callback_collector.new_source()) ari.client_initialized_subscribe(startup_callback_collector.new_source()) startup_callback_collector.subscribe(switchboards_stasis.initialize) api.add_resource( SwitchboardCallsQueuedResource, '/switchboards/<switchboard_uuid>/calls/queued', resource_class_args=[switchboards_service], ) api.add_resource( SwitchboardCallQueuedAnswerResource, '/switchboards/<switchboard_uuid>/calls/queued/<call_id>/answer', resource_class_args=[switchboards_service], ) api.add_resource( SwitchboardCallsHeldResource, '/switchboards/<switchboard_uuid>/calls/held', resource_class_args=[switchboards_service], ) api.add_resource( SwitchboardCallHeldResource, '/switchboards/<switchboard_uuid>/calls/held/<call_id>', resource_class_args=[switchboards_service], ) api.add_resource( SwitchboardCallHeldAnswerResource, '/switchboards/<switchboard_uuid>/calls/held/<call_id>/answer', resource_class_args=[switchboards_service], )
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] config = dependencies['config'] bus_consumer = dependencies['bus_consumer'] bus_publisher = dependencies['bus_publisher'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] next_token_changed_subscribe = dependencies[ 'next_token_changed_subscribe'] pubsub = dependencies['pubsub'] auth_client = AuthClient(**config['auth']) confd_client = ConfdClient(**config['confd']) amid_client = AmidClient(**config['amid']) token_changed_subscribe(amid_client.set_token) token_changed_subscribe(auth_client.set_token) token_changed_subscribe(confd_client.set_token) confd_apps_cache = ConfdApplicationsCache(confd_client) confd_apps_cache.subscribe(bus_consumer) moh_cache = MohCache(confd_client) moh_cache.subscribe(bus_consumer) notifier = ApplicationNotifier(bus_publisher) service = ApplicationService( ari.client, confd_client, amid_client, notifier, confd_apps_cache, moh_cache, ) stasis = ApplicationStasis( ari, service, notifier, confd_apps_cache, moh_cache, ) confd_is_ready_thread = ConfdIsReadyThread(confd_client) startup_callback_collector = CallbackCollector() next_token_changed_subscribe(startup_callback_collector.new_source()) ari.client_initialized_subscribe( startup_callback_collector.new_source()) confd_is_ready_thread.subscribe( startup_callback_collector.new_source()) startup_callback_collector.subscribe(stasis.initialize) confd_apps_cache.created_subscribe(stasis.add_ari_application) confd_apps_cache.updated_subscribe(service.update_destination_node) confd_apps_cache.deleted_subscribe(stasis.remove_ari_application) confd_is_ready_thread.start() pubsub.subscribe('stopping', lambda _: confd_is_ready_thread.stop()) api.add_resource( ApplicationItem, '/applications/<uuid:application_uuid>', resource_class_args=[service], ) api.add_resource( ApplicationCallList, '/applications/<uuid:application_uuid>/calls', resource_class_args=[service], ) api.add_resource( ApplicationCallItem, '/applications/<uuid:application_uuid>/calls/<call_id>', resource_class_args=[service], ) api.add_resource( ApplicationCallHoldStartList, '/applications/<uuid:application_uuid>/calls/<call_id>/hold/start', resource_class_args=[service], ) api.add_resource( ApplicationCallHoldStopList, '/applications/<uuid:application_uuid>/calls/<call_id>/hold/stop', resource_class_args=[service], ) api.add_resource( ApplicationCallMohStopList, '/applications/<uuid:application_uuid>/calls/<call_id>/moh/stop', resource_class_args=[service], ) api.add_resource( ApplicationCallMohStartList, '/applications/<uuid:application_uuid>/calls/<call_id>/moh/<uuid:moh_uuid>/start', resource_class_args=[service], ) api.add_resource( ApplicationCallMuteStartList, '/applications/<uuid:application_uuid>/calls/<call_id>/mute/start', resource_class_args=[service], ) api.add_resource( ApplicationCallMuteStopList, '/applications/<uuid:application_uuid>/calls/<call_id>/mute/stop', resource_class_args=[service], ) api.add_resource( ApplicationCallPlaybackList, '/applications/<uuid:application_uuid>/calls/<call_id>/playbacks', resource_class_args=[service], ) api.add_resource( ApplicationCallSnoopList, '/applications/<uuid:application_uuid>/calls/<call_id>/snoops', resource_class_args=[service], ) api.add_resource( ApplicationCallAnswer, '/applications/<uuid:application_uuid>/calls/<call_id>/answer', resource_class_args=[service], ) api.add_resource( ApplicationCallProgressStart, '/applications/<uuid:application_uuid>/calls/<call_id>/progress/start', resource_class_args=[service], ) api.add_resource( ApplicationCallProgressStop, '/applications/<uuid:application_uuid>/calls/<call_id>/progress/stop', resource_class_args=[service], ) api.add_resource( ApplicationNodeList, '/applications/<uuid:application_uuid>/nodes', resource_class_args=[service], ) api.add_resource( ApplicationNodeItem, '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>', resource_class_args=[service], ) api.add_resource( ApplicationNodeCallList, '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls', resource_class_args=[service], ) api.add_resource( ApplicationNodeCallUserList, '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls/user', resource_class_args=[service], ) api.add_resource( ApplicationNodeCallItem, '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls/<call_id>', resource_class_args=[service], ) api.add_resource( ApplicationPlaybackItem, '/applications/<uuid:application_uuid>/playbacks/<uuid:playback_uuid>', resource_class_args=[service], ) api.add_resource( ApplicationSnoopList, '/applications/<uuid:application_uuid>/snoops', resource_class_args=[service], ) api.add_resource( ApplicationSnoopItem, '/applications/<uuid:application_uuid>/snoops/<uuid:snoop_uuid>', resource_class_args=[service], ) api.add_resource( ApplicationDTMFList, '/applications/<uuid:application_uuid>/calls/<call_id>/dtmf', resource_class_args=[service], )
def load(self, dependencies): api = dependencies['api'] ari = dependencies['ari'] config = dependencies['config'] token_changed_subscribe = dependencies['token_changed_subscribe'] bus_consumer = dependencies['bus_consumer'] bus_publisher = dependencies['bus_publisher'] amid_client = AmidClient(**config['amid']) token_changed_subscribe(amid_client.set_token) notifier = ConferenceAdhocNotifier(bus_publisher) confd_client = ConfdClient(**config['confd']) phoned_client = PhonedClient(**config['phoned']) token_changed_subscribe(confd_client.set_token) dial_echo_manager = DialEchoManager() calls_notifier = CallNotifier(bus_publisher) calls_service = CallsService(amid_client, config['ari']['connection'], ari.client, confd_client, dial_echo_manager, phoned_client, calls_notifier) conferences_service = ConferenceService(amid_client, ari.client, notifier) conferences_bus_event_handler = ConferencesBusEventHandler( ari.client, bus_publisher, calls_service, calls_notifier) conferences_bus_event_handler.subscribe(bus_consumer) stasis = ConferenceAdhocStasis(ari, conferences_service, notifier) startup_callback_collector = CallbackCollector() ari.client_initialized_subscribe( startup_callback_collector.new_source()) startup_callback_collector.subscribe(stasis.initialize) api.add_resource(ConferencesResource, '/conferences', resource_class_args=[conferences_service]) api.add_resource(ConferenceResource, '/conferences/<conference_id>', resource_class_args=[conferences_service]) api.add_resource(ConferenceResourceVerify, '/conferences/verify/<conference_id>', resource_class_args=[conferences_service]) api.add_resource(ConferencesAdhocResource, '/users/me/conferences/adhoc', resource_class_args=[conferences_service]) api.add_resource(ConferenceAdhocResource, '/users/me/conferences/adhoc/<conference_id>', resource_class_args=[conferences_service]) api.add_resource( ConferenceParticipantAdhocResource, '/users/me/conferences/adhoc/<conference_id>/participants/<call_id>', resource_class_args=[conferences_service])