1 ##############################################################################
2 # Copyright (c) 2015 Orange
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
15 We can launch the API with this file
18 - json args validation with schemes
19 - count cases for GET on test_projects
20 - count results for GET on cases
21 - add meta object to json response
22 - provide filtering on requests
30 from resources.handlers import VersionHandler, PodHandler, \
31 TestProjectHandler, TestCasesHandler, TestResultsHandler
32 from common.constants import API_LISTENING_PORT, MONGO_URL
34 # connecting to MongoDB server, and choosing database
35 db = motor.MotorClient(MONGO_URL).test_results_collection
39 return tornado.web.Application(
41 # GET /version => GET API version
42 (r"/version", VersionHandler),
45 # GET /pods => Get all pods
46 # GET /pods/1 => Get details on POD 1
47 (r"/pods", PodHandler),
48 (r"/pods/(\d*)", PodHandler),
52 # GET /test_projects/yardstick
53 (r"/test_projects", TestProjectHandler),
54 (r"/test_projects/([^/]+)", TestProjectHandler),
57 # GET /test_projects/qtip/cases => Get cases for qtip
59 (r"/test_projects/([^/]+)/cases", TestCasesHandler),
60 (r"/test_projects/([^/]+)/cases/([^/]+)", TestCasesHandler),
61 # (r"/test_cases/([^/]+)", TestCasesHandler),
63 # new path to avoid a long depth
64 # GET /results?project=functest&case=keystone.catalog&pod=1
65 # => get results with optional filters
67 # Push results with mandatory request payload parameters
68 # (project, case, and pod_id)
69 (r"/results([^/]*)", TestResultsHandler),
70 (r"/results/([^/]*)", TestResultsHandler),
78 application = make_app()
79 application.listen(API_LISTENING_PORT)
80 tornado.ioloop.IOLoop.current().start()
82 if __name__ == "__main__":