当前位置: 首页>>代码示例>>Python>>正文


Python Channel.from_id方法代码示例

本文整理汇总了Python中junebug.channel.Channel.from_id方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.from_id方法的具体用法?Python Channel.from_id怎么用?Python Channel.from_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junebug.channel.Channel的用法示例。


在下文中一共展示了Channel.from_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: modify_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def modify_channel(self, request, body, channel_id):
     '''Mondify the channel configuration'''
     channel = yield Channel.from_id(
         self.redis, self.config, channel_id, self.service)
     resp = yield channel.update(body)
     returnValue(response(
         request, 'channel updated', resp))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:9,代码来源:api.py

示例2: restart_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def restart_channel(self, request, channel_id):
     '''Restart a channel.'''
     channel = yield Channel.from_id(
         self.redis, self.config, channel_id, self.service, self.plugins)
     yield channel.stop()
     yield channel.start(self.service)
     returnValue(response(request, 'channel restarted', {}))
开发者ID:praekelt,项目名称:junebug,代码行数:9,代码来源:api.py

示例3: get_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def get_channel(self, request, channel_id):
     '''Return the channel configuration and a nested status object'''
     channel = yield Channel.from_id(
         self.redis, self.config, channel_id, self.service)
     resp = yield channel.status()
     returnValue(response(
         request, 'channel found', resp))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:9,代码来源:api.py

示例4: validate_router_config

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
    def validate_router_config(cls, api, config):
        try:
            config = FromAddressRouterConfig(config)
        except ConfigError as e:
            raise InvalidRouterConfig(e.message)

        channel_id = str(config.channel)
        try:
            channel = yield Channel.from_id(
                api.redis, api.config, channel_id, api.service, api.plugins)
        except ChannelNotFound:
            raise InvalidRouterConfig(
                "Channel {} does not exist".format(channel_id))
        if channel.has_destination:
            raise InvalidRouterConfig(
                "Channel {} already has a destination specified".format(
                    channel_id))

        # Check that no other routers are listening to this channel
        def check_router_channel(router):
            channel = router.get('config', {}).get('channel', None)
            if channel == channel_id:
                raise InvalidRouterConfig(
                    "Router {} is already routing channel {}".format(
                        router['id'], channel_id))

        routers = yield api.router_store.get_router_list()
        routers = yield gatherResults([
            api.router_store.get_router_config(r) for r in routers])
        for router in routers:
            check_router_channel(router)
开发者ID:praekelt,项目名称:junebug,代码行数:33,代码来源:from_address.py

示例5: send_message

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
    def send_message(self, request, body, channel_id):
        '''Send an outbound (mobile terminated) message'''
        if 'to' not in body and 'reply_to' not in body:
            raise ApiUsageError(
                'Either "to" or "reply_to" must be specified')

        if 'to' in body and 'reply_to' in body:
            raise ApiUsageError(
                'Only one of "to" and "reply_to" may be specified')

        if 'from' in body and 'reply_to' in body:
            raise ApiUsageError(
                'Only one of "from" and "reply_to" may be specified')

        channel = yield Channel.from_id(
            self.redis, self.config, channel_id, self.service, self.plugins)

        if 'to' in body:
            msg = yield channel.send_message(
                self.message_sender, self.outbounds, body)
        else:
            msg = yield channel.send_reply_message(
                self.message_sender, self.outbounds, self.inbounds, body)

        yield self.message_rate.increment(
            channel_id, 'outbound', self.config.metric_window)

        returnValue(response(request, 'message sent', msg))
开发者ID:BantouTelecom,项目名称:junebug,代码行数:30,代码来源:api.py

示例6: delete_channel

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def delete_channel(self, request, channel_id):
     '''Delete the channel'''
     channel = yield Channel.from_id(
         self.redis, self.config, channel_id, self.service)
     yield channel.stop()
     yield channel.delete()
     returnValue(response(
         request, 'channel deleted', {}))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:10,代码来源:api.py

示例7: get_logs

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def get_logs(self, request, channel_id):
     '''Get the last N logs for a channel, sorted reverse
     chronologically.'''
     n = request.args.get('n', None)
     if n is not None:
         n = int(n[0])
     channel = yield Channel.from_id(
         self.redis, self.config, channel_id, self.service, self.plugins)
     logs = yield channel.get_logs(n)
     returnValue(response(request, 'logs retrieved', logs))
开发者ID:praekelt,项目名称:junebug,代码行数:12,代码来源:api.py

示例8: send_message

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
    def send_message(self, request, body, channel_id):
        '''Send an outbound (mobile terminated) message'''
        if 'to' not in body and 'reply_to' not in body:
            raise ApiUsageError(
                'Either "to" or "reply_to" must be specified')

        channel = yield Channel.from_id(
            self.redis, self.config, channel_id, self.service, self.plugins)

        if 'reply_to' in body:
            msg = yield channel.send_reply_message(
                self.message_sender, self.outbounds, self.inbounds, body,
                allow_expired_replies=self.config.allow_expired_replies)
        else:
            msg = yield channel.send_message(
                self.message_sender, self.outbounds, body)

        yield self.message_rate.increment(
            channel_id, 'outbound', self.config.metric_window)

        returnValue(response(
            request, 'message submitted', msg, code=http.CREATED))
开发者ID:praekelt,项目名称:junebug,代码行数:24,代码来源:api.py

示例9: create_channel_from_id

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import from_id [as 别名]
 def create_channel_from_id(self, redis, config, id, service):
     '''Creates an existing channel given the channel id'''
     config = yield self.create_channel_config(**config)
     channel = yield Channel.from_id(redis, config, id, service)
     returnValue(channel)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:7,代码来源:helpers.py


注:本文中的junebug.channel.Channel.from_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。