def proxy_handler(event, context, tasks): statusCode = 500 path = None try: path = event['pathParameters']['proxy'] stage = event['requestContext']['stage'] except Exception as e: logging.error( 'missing path or stage information in event {}'.format(event)) statusCode = 400 response = {'statusCode': statusCode} if path in tasks: (task, args) = tasks[path] api = garminapi.api(stage) if task and hasattr(api, task): logging.info(f'running {task}({args})') response = getattr(api, task)(event, args) if 'statusCode' not in response or response['statusCode'] != 200: logging.error(f'failed {task}') else: logging.info(f"couldn't map {path} to a task") response = {'statusCode': 400} if 'statusCode' not in response: response['statusCode'] = 500 return response
def __init__(self, args): self.args = args self.verbose = args.verbose if self.verbose: logging.getLogger().setLevel(logging.INFO) else: logging.getLogger().setLevel(logging.ERROR) api = garminapi.api(args.stage) config = api.res.config self.consumerKey = config['consumerKey'] self.consumerSecret = config['consumerSecret'] if args.token: api.setup_token_id(args.token) self.userAccessToken = api.userAccessToken self.userAccessTokenSecret = api.userAccessTokenSecret elif args.system and 'serviceKey' in config and 'serviceKeySecret' in config: self.userAccessToken = config['serviceKey'] self.userAccessTokenSecret = config['serviceKeySecret'] self.query = query.query(api.res.config) self.query.verbose = args.verbose
def handler(event, context): api = garminapi.api() api.process_queue_message(event,context)
def handler(event, context): api = garminapi.api() api.process_cache(event, context)
def handler(event, context): api = garminapi.api() api.save_to_cache('cache_fitfiles', event )