Example #1
0
def health_check():
    """Health check for application

    Return:
        response.Response, a health message
    """
    return flaskify(response.Response('all is well that begins well'))
Example #2
0
def hello_world_username(username):
    """Hello World on /<username>.

    Args:
        username (str): the user's username.
    """
    return flaskify(hello.say_hello(username))
Example #3
0
def remove_node(nodeid):
    """Remove node with nodeid.

    Args:
        nodeid (int): Node ID
    """
    return flaskify(crud_logic.remove_nodeid(nodeid))
Example #4
0
def read_a_node(nodeid):
    """Read only node with node id passed.

    Args:
        nodeid (int): Node ID
    """
    return flaskify(crud_logic.read_nodeid(nodeid))
Example #5
0
def read_allnodes():
    """Read all Nodes.

    Args:
        No Args
    """
    return flaskify(crud_logic.read_all_nodes())
Example #6
0
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))
Example #7
0
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)
Example #9
0
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
Example #10
0
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
Example #11
0
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'}
Example #12
0
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))
Example #13
0
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))
Example #14
0
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))
Example #15
0
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))
Example #16
0
def update_vectorapi_users(user_id):
    localize_data = vectorapi_users_logic.update_user(user_id,
                                                      request.get_json())

    return flaskify(localize_data)
Example #17
0
def create_vectorapi_users():
    response_obj = vectorapi_users_logic.create_user(request.get_json())
    return flaskify(response_obj)
Example #18
0
def create_book():
    """Create a new book."""
    book_data = request.get_json()
    return flaskify(book_model.create_book(book_data))
Example #19
0
def add_node():
    """Update <nodeid> with param values for right keys."""
    paramdict = request.get_json()
    return flaskify(crud_logic.add_node(paramdict))
Example #20
0
def get_books():
    """Return all books in database."""
    return flaskify(book_model.get_books())
Example #21
0
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))
Example #22
0
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))
Example #23
0
def delete_book(book_id):
    """Delete a book."""
    return flaskify(book_model.delete_book(book_id))
Example #24
0
def hello_world():
    """Hello World with an optional GET param "name"."""
    name = request.args.get('name', '')
    return flaskify(hello.say_hello(name))
Example #25
0
def get_vectorapi_users(user_id):
    response_obj = vectorapi_users_logic.get_vectorapi_user_by_id(user_id)
    return flaskify(response_obj)
Example #26
0
def health():
    """Check the health of the application."""

    return flaskify(hello.health_check())
Example #27
0
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))