epyt_flow.rest_api.scenario

epyt_flow.rest_api.scenario.handlers

This module provides REST API handlers for some requests concerning scenarios.

class epyt_flow.rest_api.scenario.handlers.ScenarioBaseHandler(scenario_mgr: ScenarioManager)[source]

Bases: BaseHandler

Base class for all handlers concerning scenarios.

Parameters:

scenario_mgr (ScenarioManager) – Instance for managing all scenarios.

class epyt_flow.rest_api.scenario.handlers.ScenarioConfigHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling a GET request for getting the scenario configuration of a given scenario.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the scenario configuration of a given scenario.

Parameters:
  • resp (falcon.Response) – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioExportHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET requests for exporting a given scenario to EPANET files – i.e. .inp and (otpionally) .msx files.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Exports a given scenario to an .inp and (optionally) .msx file.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioGeneralParamsHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests for the general parameters of a given scenario.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the general parameters (e.g. simulation duration, etc.) of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Sets the general parameters of a given scenario.

Parameters:
  • req (falcon.Request) – Request instance.

  • resp – Request instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioManager[source]

Bases: ResourceManager

Class for managing all scenarios that are currently used by the REST API.

close_item(item: ScenarioSimulator) None[source]

Closes a given resource item – i.e. all clean-up logic for an item should be called here.

Parameters:

item (Any) – Resource item.

create(**kwds) str[source]

Creates a new scenario – e.g. loading a given .inp file or using a given scenario configuration.

Returns:

UUID of the new scenario.

Return type:

str

class epyt_flow.rest_api.scenario.handlers.ScenarioNewHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling POST requests for creating a new scenario.

on_post(req: falcon.Request, resp: falcon.Response) None[source]

Creates/Loads a new scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioNodeDemandPatternHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling POST requests for node demand patterns of a given scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str, node_id: str) None[source]

Sets the demand pattern of a specific node in a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

  • node_id (str) – ID of the node.

class epyt_flow.rest_api.scenario.handlers.ScenarioQualityParamsHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling POST requests for specifying (EPANET) quality parameters of a given scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Specifies the (EPANET) quality parameters of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Request instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioRemoveHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling a DELETE request for a given scenario.

on_delete(_, resp: falcon.Response, scenario_id: str) None[source]

Deletes a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioSensorConfigHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests for the sensor configuration of a given scenario.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the sensor configuration of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Sets the sensor configuration of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Request instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.handlers.ScenarioTopologyHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET requests for getting the topology of a given scenario.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the topology of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

epyt_flow.rest_api.scenario.simulation_handlers

This module provides REST API handlers concerning the simulation of scenarios.

class epyt_flow.rest_api.scenario.simulation_handlers.ScenarioAdvancedQualitySimulationHandler(scada_data_mgr: ScadaDataManager, **kwds)[source]

Bases: ScenarioBaseHandler

Class for handling POST requests for runing an advanced quality simulation of a given scenario.

Parameters:

scada_data_mgr (ScadaDataManager) – SCADA data manager.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Runs the advanced quality simulation of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.simulation_handlers.ScenarioBasicQualitySimulationHandler(scada_data_mgr: ScadaDataManager, **kwds)[source]

Bases: ScenarioBaseHandler

Class for handling POST requests for runing a basic quality simulation of a given scenario.

Parameters:

scada_data_mgr (ScadaDataManager) – SCADA data manager.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Runs the basic quality simulation of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.simulation_handlers.ScenarioSimulationHandler(scada_data_mgr: ScadaDataManager, **kwds)[source]

Bases: ScenarioBaseHandler

Class for handling GET requests for simulating a given scenario.

Parameters:

scada_data_mgr (ScadaDataManager) – SCADA data manager.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Runs the simulation of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Runs the simulation of a given scenario.

Note that in contrat to the GET request (on_get()), the POST request allows to specify additional arguments passed to run_simulation().

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

epyt_flow.rest_api.scenario.control_handlers

This module provides REST API handlers for complex and simple control modules of scenarios.

class epyt_flow.rest_api.scenario.control_handlers.ScenarioComplexControlHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning complex control modules.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all complex control modules of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new complex control module to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.control_handlers.ScenarioSimpleControlHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning simple control modules.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all simple control modules of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new simple control module to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

epyt_flow.rest_api.scenario.event_handlers

This module provides REST API handlers for scenario events.

class epyt_flow.rest_api.scenario.event_handlers.ScenarioLeakageHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning leakages.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all leakages of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new leakage to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.event_handlers.ScenarioQualityEventHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning quality events.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all quality events of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new quality event to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.event_handlers.ScenarioSensorFaultHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning sensor faults.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all sensor faults of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new sensor fault to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.event_handlers.ScenarioSensorReadingAttackHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning sensor reading attacks.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets all sensor reading attack events of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Adds a new sensor reading attack event to a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

epyt_flow.rest_api.scenario.uncertainty_handlers

This module provides REST API handlers for model and sensor uncertainties of scenarios.

class epyt_flow.rest_api.scenario.uncertainty_handlers.ScenarioModelUncertaintyHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning model uncertainty.

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the model uncertainties of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Sets the model uncertainties of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

class epyt_flow.rest_api.scenario.uncertainty_handlers.ScenarioSensorUncertaintyHandler(scenario_mgr: ScenarioManager)[source]

Bases: ScenarioBaseHandler

Class for handling GET and POST requests concerning sensor uncertainty (i.e. noise).

on_get(_, resp: falcon.Response, scenario_id: str) None[source]

Gets the sensor uncertainty (i.e. noise) of a given scenario.

Parameters:
  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.

on_post(req: falcon.Request, resp: falcon.Response, scenario_id: str) None[source]

Sets the sensor uncertainty (i.e. noise) of a given scenario.

Parameters:
  • req – Request instance.

  • resp – Response instance.

  • scenario_id (str) – UUID of the scenario.