def __init__(self, subscription_ids, timeout_minutes=30): """ Initialize the request. :param principal: Principal email to impersonate :param subscription_id: Subscription ID to get rid of """ self.timeout_minutes = timeout_minutes root = M.GetStreamingEvents( M.SubscriptionIds(*[T.SubscriptionId(x) for x in subscription_ids]), M.ConnectionTimeout(str(timeout_minutes)), ) super(GetStreamingEventsRequest, self).__init__(root)
def handle_get_events(self, request): if not request.xpath('//m:GetStreamingEvents', namespaces=NAMESPACES): # pragma: no cover return sub_id = request.xpath('//t:SubscriptionId', namespaces=NAMESPACES)[0].text # This would be a long-polling operation, # but ain't nobody got time for that return M.GetStreamingEventsResponse( M.ResponseMessages( M.GetStreamingEventsResponseMessage( M.ResponseCode('NoError'), M.Notifications( M.Notification( T.SubscriptionId(sub_id), self._generate_event('NewMailEvent'), ), ), ResponseClass='Success', ), ), )