def info(): """Get info about a user based on their api_key""" api_request = apireq.APIRequest(request, 'client_schema') if api_request.is_invalid(): return api_request.error_text, 400 return json.dumps(user_management.info(api_json['api_key']), indent=4, default=json_util.default)
def list_users(): """List recently created users""" api_request = apireq.APIRequest(request, 'client_schema') if api_request.is_invalid(): return api_request.error_text, 400 return json.dumps(user_management.list_new_users(), indent=4, default=json_util.default)
def list_data(): """List recently added data""" api_request = apireq.APIRequest(request, 'client_schema') if api_request.is_invalid(): return api_request.error_text, 400 f = json.dumps(file_management.list_recent(), indent=4, default=json_util.default), 200 return f
def upload(): """Upload new data""" api_request = apireq.APIRequest(request, 'upload_schema') if api_request.is_invalid(): return api_request.error_text, 400 api_data = api_request.api_data try: file_management.add_file(request.files['file'], api_data['datatype'], api_data['ext']) except ValueError as e: return 'Failed: {}'.format(e), 500 return 'Success', 200
def create(): """Create new user and return api key""" api_request = apireq.APIRequest(request, 'client_schema') if api_request.is_invalid(): return api_request.error_text, 400 return user_management.create_user(api_json['username'])