def get(self): auth_util.get_bot(flask.request) sub_events_query = ds_util.client.query(kind='SubscriptionEvent') for sub_event in sub_events_query.fetch(): task_util.process_event(sub_event.key) return responses.OK
def get(self): auth_util.get_bot(flask.request) redirect_uri = config.frontend_url + '/services/strava/echo' client = stravalib.client.Client() url = client.authorization_url( client_id=config.strava_creds['client_id'], redirect_uri=redirect_uri, approval_prompt='force', scope=['activity:read_all', 'profile:read_all'], ) return {'auth_url': url}
def post(self): auth_util.get_bot(flask.request) key = ds_util.key_from_path(api.payload.get('path')) if key is None or ds_util.client.get(key) is None: logging.debug('No entity with key: %s', key) return key children_query = ds_util.client.query(ancestor=key) children_query.keys_only() ds_util.client.delete_multi(child.key for child in children_query.fetch()) return key
def post(self, name): bot = auth_util.get_bot(flask.request) service = Service.get(name, parent=bot.key) Service.clear_credentials(service) ds_util.client.put(service) return WrapEntity(service)
def post(self, name): bot = auth_util.get_bot(flask.request) force = api.payload.get('force', False) service = Service.get(name, parent=bot.key) task_util.sync_service(service, force=force) return WrapEntity(service)
def get(self): bot = auth_util.get_bot(flask.request) service = Service.get('slack', parent=bot.key) query = ds_util.client.query(kind='SlackWorkspace', ancestor=service.key) workspaces = [e for e in query.fetch()] return {'service': WrapEntity(service), 'workspaces': workspaces}
def get(self, club_id): bot = auth_util.get_bot(flask.request) service = Service.get('strava', parent=bot.key) club = StravaClubWorker(club_id, service).sync_club() return WrapEntity(club)
def get(self): bot = auth_util.get_bot(flask.request) service = Service.get('strava', parent=bot.key) club_query = ds_util.client.query(kind='Club', ancestor=service.key) return [WrapEntity(club) for club in club_query.fetch()]
def get(self, club_id): bot = auth_util.get_bot(flask.request) service = Service.get('strava', parent=bot.key) club = Club.get(club_id, parent=service.key) if club is not None: ds_util.client.delete(club.key) return None
def post(self): auth_util.get_bot(flask.request) callbackurl = flask.request.form.get('callbackurl', None) logging.info('Unsubscribing: %s', callbackurl) if callbackurl is None or 'withings' not in callbackurl: return responses.BAD_REQUEST services_query = ds_util.client.query(kind='Service') services_query.add_filter('sync_enabled', '=', True) services = [ service for service in services_query.fetch() if service.key.name == 'withings' and service.get('credentials') is not None ] for service in services: logging.info('Unsubscribing: %s from %s', callbackurl, service.key) client = withings_create_client(service) results = [] try: result = client.unsubscribe(callbackurl) logging.info('Unsubscribed %s from %s (%s)', callbackurl, service.key, result) results.append({ 'callbackurl': callbackurl, 'result': str(result), 'service': str(service.key), }) except Exception as e: logging.exception('Unable to unsubscribe %s from %s', callbackurl, service.key) results.append({ 'callbackurl': callbackurl, 'error': str(e), 'service': str(service.key), }) return results
def get(self): bot = auth_util.get_bot(flask.request) user_entities = [bot] user_entities += ds_util.client.query(kind='User').fetch() users = [] for user_entity in user_entities: users.append({ 'user': WrapEntity(user_entity), 'google': Service.get('google', parent=user_entity.key), 'strava': Service.get('strava', parent=user_entity.key), 'withings': Service.get('withings', parent=user_entity.key), 'fitbit': Service.get('fitbit', parent=user_entity.key), }) return users
def get(self, name): bot = auth_util.get_bot(flask.request) service = Service.get(name, parent=bot.key) task_util.sync_service(service, force=True) return responses.OK
def get(self, name): bot = auth_util.get_bot(flask.request) service = Service.get(name, parent=bot.key) return WrapEntity(service)