Merge "Reporting docker deployment improvement"
[releng.git] / utils / test / reporting / api / api / handlers / projects.py
1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
3 #
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.apaiche.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import requests
10
11 from tornado.escape import json_encode
12
13 from api.handlers import BaseHandler
14 from api import conf
15
16
17 class Projects(BaseHandler):
18     def get(self):
19         self._set_header()
20
21         url = '{}/projects'.format(conf.base_url)
22         projects = requests.get(url).json().get('projects', {})
23
24         project_url = 'https://wiki.opnfv.org/display/{}'
25         data = {p['name']: project_url.format(p['name']) for p in projects}
26
27         return self.write(json_encode(data))