def upload_file_auth():
    res = HandlerBuilder() \
      .add_handler(AuthenticationHandler,
                   authentication_strategy=basic_auth) \
      .build() \
      .execute(upload_file, bound_request=request,
               user_id=basic_auth.get_user_id(request.authorization))
    return jsonify(image_id=res), 201
def list_stories_afte(after_id):
  story_list = HandlerBuilder() \
    .add_handler(AuthenticationHandler, authentication_strategy=basic_auth) \
    .build() \
    .execute(fn=Story.list_for_user_wpic_after, bound_request=request,
             user_id=basic_auth.get_user_id(request.authorization),
             after_id=after_id)
  return jsonify(stories=story_list), 200
def list_stories_since(timestamp):
  story_list = HandlerBuilder() \
    .add_handler(AuthenticationHandler, authentication_strategy=basic_auth) \
    .build() \
    .execute(fn=Story.list_for_user_wpic_since, bound_request=request,
             user_id=basic_auth.get_user_id(request.authorization),
             since=datetime.datetime.fromtimestamp(float(timestamp)))
  return jsonify(stories=story_list), 200
def list_stories():
  # Implement proper Auth here
  story_list = HandlerBuilder() \
    .add_handler(AuthenticationHandler, authentication_strategy=basic_auth) \
    .build() \
    .execute(fn=Story.list_for_user_wpic, bound_request=request,
             user_id=basic_auth.get_user_id(request.authorization))
  return jsonify(stories=story_list), 200
def generate_story_auth(image_id):
    res = HandlerBuilder() \
      .add_handler(AuthorizationHandler,
                   authorization_strategy=FileAuthorizationStrategy(image_id)) \
      .add_handler(AuthenticationHandler,
                   authentication_strategy=basic_auth) \
      .build() \
      .execute(generate_story, bound_request=request, image_id=image_id,
               user_id=basic_auth.get_user_id(request.authorization))
    return jsonify(text=res), 200
def download_file_auth(image_id):
    res = HandlerBuilder() \
      .add_handler(AuthorizationHandler,
                   authorization_strategy=FileAuthorizationStrategy(image_id)) \
      .add_handler(AuthenticationHandler,
                   authentication_strategy=basic_auth) \
      .build() \
      .execute(download_file, bound_request=request, image_id=image_id,
               user_id=basic_auth.get_user_id(request.authorization))
    return res, 200
def upload_file_demo():
    res = HandlerBuilder() \
      .add_handler(AuthenticationDemoHandler, authentication_strategy=basic_auth) \
      .build() \
      .execute(upload_demo_file, bound_request=request)
    return jsonify(image_id=res), 201