summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/app.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-05 12:08:25 +0200
committerGitHub <noreply@github.com>2021-07-05 12:08:25 +0200
commit49fc69c9cf154f9ad727e58f451e4be24dbaaff0 (patch)
tree953ed9998107f46d5892addc7266e39b3484fdfa /opendc-web/opendc-web-api/app.py
parent07958ab26e94d5ab7e0873cc00d7beb9c417975e (diff)
parent6752b6d50faab447b3edc13bddf14f53401392f1 (diff)
web: Migrate web runner to REST API
This pull request updates the web runner to remove its hard dependency on a direct database connection. Instead, it now communicates via the REST API. * Add endpoint for scheduling simulation jobs * Create simple API client for web runner * Remove direct database connection from web runner * Improve validation of API input/output data Implements #144
Diffstat (limited to 'opendc-web/opendc-web-api/app.py')
-rwxr-xr-xopendc-web/opendc-web-api/app.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/opendc-web/opendc-web-api/app.py b/opendc-web/opendc-web-api/app.py
index 5916046b..36c80b7a 100755
--- a/opendc-web/opendc-web-api/app.py
+++ b/opendc-web/opendc-web-api/app.py
@@ -10,6 +10,7 @@ from flask_restful import Api
from flask_swagger_ui import get_swaggerui_blueprint
from marshmallow import ValidationError
+from opendc.api.jobs import JobList, Job
from opendc.api.portfolios import Portfolio, PortfolioScenarios
from opendc.api.prefabs import Prefab, PrefabList
from opendc.api.projects import ProjectList, Project, ProjectTopologies, ProjectPortfolios
@@ -60,6 +61,8 @@ def setup_api(app):
api.add_resource(TraceList, '/traces/')
api.add_resource(Trace, '/traces/<string:trace_id>')
api.add_resource(SchedulerList, '/schedulers/')
+ api.add_resource(JobList, '/jobs/')
+ api.add_resource(Job, '/jobs/<string:job_id>')
@app.errorhandler(AuthError)
def handle_auth_error(ex):
@@ -89,6 +92,7 @@ def setup_swagger(app):
},
oauth_config={
'clientId': os.environ.get("AUTH0_DOCS_CLIENT_ID", ""),
+ 'additionalQueryStringParams': {'audience': os.environ.get("AUTH0_AUDIENCE", "https://api.opendc.org/v2/")},
}
)
app.register_blueprint(swaggerui_blueprint)