2018-05-30 10:49:40 +00:00
|
|
|
from typing import Callable, Iterable, Tuple
|
|
|
|
|
|
|
|
from ereuse_devicehub.resources.device.sync import Sync
|
2018-05-13 13:13:12 +00:00
|
|
|
from ereuse_devicehub.resources.event.schemas import Add, Event, Remove, Snapshot, Test, \
|
|
|
|
TestHardDrive
|
2018-04-27 17:16:43 +00:00
|
|
|
from ereuse_devicehub.resources.event.views import EventView, SnapshotView
|
|
|
|
from teal.resource import Converters, Resource
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EventDef(Resource):
|
2018-04-27 17:16:43 +00:00
|
|
|
SCHEMA = Event
|
2018-04-10 15:06:39 +00:00
|
|
|
VIEW = EventView
|
2018-04-27 17:16:43 +00:00
|
|
|
AUTH = True
|
|
|
|
ID_CONVERTER = Converters.int
|
|
|
|
|
|
|
|
|
2018-05-13 13:13:12 +00:00
|
|
|
class AddDef(EventDef):
|
|
|
|
SCHEMA = Add
|
|
|
|
|
|
|
|
|
|
|
|
class RemoveDef(EventDef):
|
|
|
|
SCHEMA = Remove
|
|
|
|
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
class SnapshotDef(EventDef):
|
|
|
|
SCHEMA = Snapshot
|
|
|
|
VIEW = SnapshotView
|
2018-05-13 13:13:12 +00:00
|
|
|
|
2018-05-30 10:49:40 +00:00
|
|
|
def __init__(self, app, import_name=__package__, static_folder=None, static_url_path=None,
|
|
|
|
template_folder=None, url_prefix=None, subdomain=None, url_defaults=None,
|
|
|
|
root_path=None, cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()):
|
|
|
|
super().__init__(app, import_name, static_folder, static_url_path, template_folder,
|
|
|
|
url_prefix, subdomain, url_defaults, root_path, cli_commands)
|
|
|
|
self.sync = Sync()
|
|
|
|
|
2018-05-13 13:13:12 +00:00
|
|
|
|
|
|
|
class TestDef(EventDef):
|
|
|
|
SCHEMA = Test
|
|
|
|
|
|
|
|
|
|
|
|
class TestHardDriveDef(TestDef):
|
|
|
|
SCHEMA = TestHardDrive
|