summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/models/project.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/opendc/models/project.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/opendc/models/project.py')
-rw-r--r--opendc-web/opendc-web-api/opendc/models/project.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/opendc-web/opendc-web-api/opendc/models/project.py b/opendc-web/opendc-web-api/opendc/models/project.py
index ee84c73e..f2b3b564 100644
--- a/opendc-web/opendc-web-api/opendc/models/project.py
+++ b/opendc-web/opendc-web-api/opendc/models/project.py
@@ -1,20 +1,29 @@
-from marshmallow import Schema, fields
+from marshmallow import Schema, fields, validate
from werkzeug.exceptions import Forbidden
from opendc.models.model import Model
from opendc.exts import db
+class ProjectAuthorizations(Schema):
+ """
+ Schema representing a project authorization.
+ """
+ userId = fields.String(required=True)
+ level = fields.String(required=True, validate=validate.OneOf(["VIEW", "EDIT", "OWN"]))
+
+
class ProjectSchema(Schema):
"""
Schema representing a Project.
"""
- _id = fields.String()
+ _id = fields.String(dump_only=True)
name = fields.String(required=True)
datetimeCreated = fields.DateTime()
datetimeLastEdited = fields.DateTime()
topologyIds = fields.List(fields.String())
portfolioIds = fields.List(fields.String())
+ authorizations = fields.List(fields.Nested(ProjectAuthorizations))
class Project(Model):