summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/models/scenario.py
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/models/scenario.py')
-rw-r--r--opendc-web/opendc-web-api/opendc/models/scenario.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/opendc-web/opendc-web-api/opendc/models/scenario.py b/opendc-web/opendc-web-api/opendc/models/scenario.py
index 3dfde012..2911b1ae 100644
--- a/opendc-web/opendc-web-api/opendc/models/scenario.py
+++ b/opendc-web/opendc-web-api/opendc/models/scenario.py
@@ -1,7 +1,52 @@
+from marshmallow import Schema, fields
from opendc.models.model import Model
from opendc.models.portfolio import Portfolio
+class SimulationSchema(Schema):
+ """
+ Simulation details.
+ """
+ state = fields.String()
+
+
+class TraceSchema(Schema):
+ """
+ Schema for specifying the trace of a scenario.
+ """
+ traceId = fields.String()
+ loadSamplingFraction = fields.Float()
+
+
+class TopologySchema(Schema):
+ """
+ Schema for topology specification for a scenario.
+ """
+ topologyId = fields.String()
+
+
+class OperationalSchema(Schema):
+ """
+ Schema for the operational phenomena for a scenario.
+ """
+ failuresEnabled = fields.Boolean()
+ performanceInterferenceEnabled = fields.Boolean()
+ schedulerName = fields.String()
+
+
+class ScenarioSchema(Schema):
+ """
+ Schema representing a scenario.
+ """
+ _id = fields.String()
+ portfolioId = fields.String()
+ name = fields.String(required=True)
+ simulation = fields.Nested(SimulationSchema)
+ trace = fields.Nested(TraceSchema)
+ topology = fields.Nested(TopologySchema)
+ operational = fields.Nested(OperationalSchema)
+
+
class Scenario(Model):
"""Model representing a Scenario."""
@@ -16,5 +61,4 @@ class Scenario(Model):
:param edit_access: True when edit access should be checked, otherwise view access.
"""
portfolio = Portfolio.from_id(self.obj['portfolioId'])
- print(portfolio.obj)
portfolio.check_user_access(user_id, edit_access)