本文整理汇总了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))
示例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', {}))
示例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))
示例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)
示例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))
示例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', {}))
示例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))
示例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))
示例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)