def health_check(): """Health check for application Return: response.Response, a health message """ return flaskify(response.Response('all is well that begins well'))
def hello_world_username(username): """Hello World on /<username>. Args: username (str): the user's username. """ return flaskify(hello.say_hello(username))
def remove_node(nodeid): """Remove node with nodeid. Args: nodeid (int): Node ID """ return flaskify(crud_logic.remove_nodeid(nodeid))
def read_a_node(nodeid): """Read only node with node id passed. Args: nodeid (int): Node ID """ return flaskify(crud_logic.read_nodeid(nodeid))
def read_allnodes(): """Read all Nodes. Args: No Args """ return flaskify(crud_logic.read_all_nodes())
def update_node(nodeid): """Update <nodeid> with param values for right keys. Args: nodeid (int): Node ID """ paramdict = request.get_json() return flaskify(crud_logic.update_nodeid(nodeid, paramdict))
def test_flaskify_string_response(): """Test flaskifying a response. """ resp = flask.flaskify(response.Response(message='value1')) assert resp.data == b'value1' assert resp.mimetype == 'text/plain' assert resp.status_code == 200
def authenticate_and_call(*args, **kwargs): if not is_authenticated(request.headers): return flaskify( response.create_error_response( code=constants.ERROR_CODE_UNAUTHORIZED_REQUEST, message=constants.ERROR_MESSAGE_UNAUTHORIZED_ACCESS, status=oto_status.UNAUTHORIZED)) return func(*args, **kwargs)
def test_flaskify_list_response(): """Test flaskifying a response. """ resp = flask.flaskify(response.Response(message=['value1', 'value2'])) assert resp.data == b'["value1", "value2"]' assert resp.mimetype == 'application/json' assert resp.status_code == 200
def test_flaskify_dict_response(): """Test flaskifying a response. """ resp = flask.flaskify(response.Response(message=dict(key='value'))) assert resp.data == b'{"key": "value"}' assert resp.mimetype == 'application/json' assert resp.status_code == 200
def test_flaskify_error_response(): """Flaskify an error response. """ resp = flask.flaskify(response.create_fatal_response('Fatal Error')) assert resp.status_code == 500 data = json.loads(resp.data.decode('utf8')) assert data == {'message': 'Fatal Error', 'code': 'internal_error'}
def delete_product_live_details(product_id): """Delete product live time details by product id. Args: product_id (str): Product id to delete product live time details. Returns: flask.Response: Response containing delete success message or error response message. """ return flaskify(product_live_time.delete_product_live_time_details( product_id))
def get_product_live_detail_by_id(product_id): """Get product live time details for given product id. Args: product_id (str): Product id to fetch Spotify product live time. Returns: flask.response: Response contains dict describing product live time details, or validation message. """ return flaskify(product_live_time.get_product_live_time_details( product_id))
def exception_handler(error): """Default handler when uncaught exception is raised. Note: Exception will also be sent to Sentry if config.SENTRY is set. Returns: flask.Response: A 500 response with JSON 'code' & 'message' payload. """ message = ('The server encountered an internal error ' 'and was unable to complete your request.') g.log.exception(error) return flaskify(response.create_fatal_response(message))
def create_product_live_time_detail(): """Save info about product live time detail. Returns: flask.Response: Response contains dict describing product live time details, or validation message. """ valid_request_json = True try: timed_release_data = request.get_json() if not isinstance(timed_release_data, dict): valid_request_json = False except BadRequest: valid_request_json = False if not valid_request_json: return flaskify(response.create_error_response( code=error.ERROR_CODE_BAD_REQUEST, message=error.ERROR_MESSAGE_INVALID_REQUEST_BODY)) return flaskify(product_live_time.create_product_live_time_detail( timed_release_data))
def update_vectorapi_users(user_id): localize_data = vectorapi_users_logic.update_user(user_id, request.get_json()) return flaskify(localize_data)
def create_vectorapi_users(): response_obj = vectorapi_users_logic.create_user(request.get_json()) return flaskify(response_obj)
def create_book(): """Create a new book.""" book_data = request.get_json() return flaskify(book_model.create_book(book_data))
def add_node(): """Update <nodeid> with param values for right keys.""" paramdict = request.get_json() return flaskify(crud_logic.add_node(paramdict))
def get_books(): """Return all books in database.""" return flaskify(book_model.get_books())
def search_for_books(): """Fetch a book from the book library by id.""" search_term = request.args.get('term') search_category = request.args.get('category').lower() return flaskify( library_book_model.search_for_books(search_term, search_category))
def get_book_from_library(book_id): """Fetch a book from the book library by id.""" return flaskify(library_book_model.get_book_by_id(book_id))
def delete_book(book_id): """Delete a book.""" return flaskify(book_model.delete_book(book_id))
def hello_world(): """Hello World with an optional GET param "name".""" name = request.args.get('name', '') return flaskify(hello.say_hello(name))
def get_vectorapi_users(user_id): response_obj = vectorapi_users_logic.get_vectorapi_user_by_id(user_id) return flaskify(response_obj)
def health(): """Check the health of the application.""" return flaskify(hello.health_check())
def update_book_by_id(book_id): """Update a book.""" book_data = request.get_json() # dict of key value pairs return flaskify(book_model.update_book(book_id, book_data))