diff --git a/boot/__init__.py b/boot/__init__.py index 1bc3432..c9f2b21 100644 --- a/boot/__init__.py +++ b/boot/__init__.py @@ -20,6 +20,7 @@ from .stage1 import init_app as init_stage1 from .stage2 import init_app as init_stage2 from .auth import rebble, init_app as init_auth +from .cobble import init_app as init_cobble from .settings import config app = Flask(__name__) @@ -34,6 +35,7 @@ init_stage1(app) init_stage2(app) init_auth(app) +init_cobble(app) # XXX: upstream this import beeline diff --git a/boot/cobble.py b/boot/cobble.py new file mode 100644 index 0000000..2786451 --- /dev/null +++ b/boot/cobble.py @@ -0,0 +1,33 @@ +from flask import Blueprint, jsonify, request +import requests + +from .settings import config + +cobble = Blueprint('cobble', __name__) + +@cobble.route('/') +def boot_cobble(): + build = request.args.get('build') + platform = request.args.get('platform') + locale = request.args.get('locale', 'en_US') + boot = { + "auth": { + "base": f"{config['REBBLE_AUTH_URL']}/api", + "authorize_url": f"{config['REBBLE_AUTH_URL']}/oauth/authorise", + "refresh_url": f"{config['REBBLE_AUTH_URL']}/oauth/token", + "client_id": config['COBBLE_OAUTH_CLIENT_ID'] + }, + "appstore": { + "base": f"{config['APPSTORE_API_URL']}/api" + }, + "webviews": { + "appstoreApplication": f"{config['APPSTORE_URL']}/{locale}/application/", + "appstoreWatchapps": f"{config['APPSTORE_URL']}/{locale}/watchapps", + "appstoreWatchfaces": f"{config['APPSTORE_URL']}/{locale}/watchfaces", + "manageAccount": config['REBBLE_ACCOUNT_URL'] + } + } + return jsonify(boot) + +def init_app(app, prefix='/api/cobble'): + app.register_blueprint(cobble, url_prefix=prefix) diff --git a/boot/settings.py b/boot/settings.py index 9e263df..ee2b91a 100644 --- a/boot/settings.py +++ b/boot/settings.py @@ -23,4 +23,6 @@ }, 'HONEYCOMB_KEY': environ.get('HONEYCOMB_KEY', None), 'WS_PROXY_URL': environ.get('WS_PROXY_URL', f'ws://dev-ws-proxy.{domain_root}'), + 'COBBLE_OAUTH_CLIENT_ID': environ['COBBLE_OAUTH_CLIENT_ID'], + 'REBBLE_ACCOUNT_URL': environ.get('REBBLE_ACCOUNT_URL', f"{http_protocol}://auth.{domain_root}/account/"), }