def get(self): """ Returns a collection of HAR tests based on filters. **Example request**: .. sourcecode:: http GET /tests/?hostname=humanssuck.net HTTP/1.1 Host: har-api.com Accept: application/json, text/javascript **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: accept Content-Type: text/javascript :query hostname: Hostname of the test :query name: Custom name for the tests :statuscode 200: You've got tests! :statuscode 500: internal error """ parser = reqparse.RequestParser() # TODO - date range support parser.add_argument('hostname', help='hostname filter') parser.add_argument('name', help='test name filter') kwargs = parser.parse_args() search_query = filter_args(kwargs) # TODO - pagination son! if search_query: test_query = Test.query.filter_by(**search_query) tests = test_query.all() else: tests = Test.query.all() return (tests, 200)
def get(self): """ Retrieve a collection of pages based on filter critieria **Example request**: .. sourcecode:: http GET /pages/?hostname=humanssuck.net HTTP/1.1 Host: har-api.com Accept: application/json, text/javascript **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: accept Content-Type: text/javascript :query hostname: Hostname of the page :query name: Custom name for the test containing this page :statuscode 200: You've got tests! :statuscode 500: internal error """ parser = reqparse.RequestParser() parser.add_argument('hostname', help='hostname filter') parser.add_argument('test_name', help='test name filter') kwargs = parser.parse_args() search_query = filter_args(kwargs) # TODO - pagination son! if search_query: page_query = Page.query.filter_by(**search_query) pages = page_query.all() else: pages = Page.query.all() return (pages, 200)