2018-05-30 10:49:40 +00:00
|
|
|
from typing import Callable, Iterable, Tuple
|
|
|
|
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal.resource import Converters, Resource
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
from ereuse_devicehub.resources.action import schemas
|
2021-05-10 09:52:10 +00:00
|
|
|
from ereuse_devicehub.resources.action.views.views import (ActionView, AllocateView, DeallocateView,
|
2021-04-21 12:37:32 +00:00
|
|
|
LiveView)
|
2018-05-30 10:49:40 +00:00
|
|
|
from ereuse_devicehub.resources.device.sync import Sync
|
2018-04-10 15:06:39 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ActionDef(Resource):
|
|
|
|
SCHEMA = schemas.Action
|
|
|
|
VIEW = ActionView
|
2018-04-27 17:16:43 +00:00
|
|
|
AUTH = True
|
2018-06-15 13:31:03 +00:00
|
|
|
ID_CONVERTER = Converters.uuid
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class AddDef(ActionDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Add
|
2018-05-13 13:13:12 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class RemoveDef(ActionDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Remove
|
2018-05-13 13:13:12 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class EraseBasicDef(ActionDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.EraseBasic
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EraseSectorsDef(EraseBasicDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.EraseSectors
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2018-11-17 17:24:34 +00:00
|
|
|
class ErasePhysicalDef(EraseBasicDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ErasePhysical
|
|
|
|
|
|
|
|
|
2018-06-10 16:47:49 +00:00
|
|
|
class StepDef(Resource):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Step
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StepZeroDef(StepDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.StepZero
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StepRandomDef(StepDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.StepRandom
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class BenchmarkDef(ActionDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2019-04-16 15:47:28 +00:00
|
|
|
SCHEMA = schemas.Benchmark
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkDataStorageDef(BenchmarkDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.BenchmarkDataStorage
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkWithRateDef(BenchmarkDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.BenchmarkWithRate
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkProcessorDef(BenchmarkWithRateDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.BenchmarkProcessor
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-04-16 15:47:28 +00:00
|
|
|
class BenchmarkProcessorSysbenchDef(BenchmarkProcessorDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2019-04-16 15:47:28 +00:00
|
|
|
SCHEMA = schemas.BenchmarkProcessorSysbench
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-04-16 15:47:28 +00:00
|
|
|
class BenchmarkRamSysbenchDef(BenchmarkWithRateDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2019-04-16 15:47:28 +00:00
|
|
|
SCHEMA = schemas.BenchmarkRamSysbench
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class TestDef(ActionDef):
|
2019-04-23 19:27:31 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Test
|
|
|
|
|
|
|
|
|
2019-06-29 14:26:14 +00:00
|
|
|
class MeasureBattery(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.MeasureBattery
|
|
|
|
|
|
|
|
|
2019-04-23 19:27:31 +00:00
|
|
|
class TestDataStorageDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestDataStorage
|
|
|
|
|
|
|
|
|
|
|
|
class StressTestDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.StressTest
|
|
|
|
|
|
|
|
|
|
|
|
class TestAudioDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestAudio
|
|
|
|
|
|
|
|
|
|
|
|
class TestConnectivityDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestConnectivity
|
|
|
|
|
|
|
|
|
|
|
|
class TestCameraDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestCamera
|
|
|
|
|
|
|
|
|
|
|
|
class TestKeyboardDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestKeyboard
|
|
|
|
|
|
|
|
|
|
|
|
class TestTrackpadDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestTrackpad
|
|
|
|
|
|
|
|
|
|
|
|
class TestBiosDef(TestDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.TestBios
|
|
|
|
|
|
|
|
|
2019-05-08 17:12:05 +00:00
|
|
|
class VisualTestDef(TestDef):
|
2019-04-23 19:27:31 +00:00
|
|
|
VIEW = None
|
2019-05-08 17:12:05 +00:00
|
|
|
SCHEMA = schemas.VisualTest
|
2019-04-16 15:47:28 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class RateDef(ActionDef):
|
2019-04-16 15:47:28 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Rate
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-04-16 15:47:28 +00:00
|
|
|
class RateComputerDef(RateDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2019-04-16 15:47:28 +00:00
|
|
|
SCHEMA = schemas.RateComputer
|
2018-06-20 21:18:15 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class PriceDef(ActionDef):
|
2018-07-14 14:41:22 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Price
|
2018-07-14 14:41:22 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class EreusePriceDef(ActionDef):
|
2018-07-14 14:41:22 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.EreusePrice
|
2018-07-14 14:41:22 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class InstallDef(ActionDef):
|
2018-06-24 14:57:49 +00:00
|
|
|
VIEW = None
|
2018-07-22 20:42:49 +00:00
|
|
|
SCHEMA = schemas.Install
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class SnapshotDef(ActionDef):
|
2019-02-18 11:43:50 +00:00
|
|
|
VIEW = None
|
2018-08-03 16:15:08 +00:00
|
|
|
SCHEMA = schemas.Snapshot
|
2018-05-13 13:13:12 +00:00
|
|
|
|
2018-10-13 12:53:46 +00:00
|
|
|
def __init__(self, app, import_name=__name__.split('.')[0], static_folder=None,
|
|
|
|
static_url_path=None,
|
2018-05-30 10:49:40 +00:00
|
|
|
template_folder=None, url_prefix=None, subdomain=None, url_defaults=None,
|
|
|
|
root_path=None, cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()):
|
2019-05-11 14:27:22 +00:00
|
|
|
url_prefix = '/{}'.format(ActionDef.resource)
|
2018-05-30 10:49:40 +00:00
|
|
|
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
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ToRepairDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ToRepair
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class RepairDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Repair
|
|
|
|
|
|
|
|
|
2019-07-07 19:36:09 +00:00
|
|
|
class ReadyDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
2019-07-07 19:36:09 +00:00
|
|
|
SCHEMA = schemas.Ready
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ToPrepareDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ToPrepare
|
|
|
|
|
|
|
|
|
2021-07-29 10:45:43 +00:00
|
|
|
class DataWipeDef(ActionDef):
|
2021-07-21 06:46:09 +00:00
|
|
|
VIEW = None
|
2021-07-29 10:45:43 +00:00
|
|
|
SCHEMA = schemas.DataWipe
|
2021-07-21 06:46:09 +00:00
|
|
|
|
|
|
|
|
2020-11-27 17:10:51 +00:00
|
|
|
class AllocateDef(ActionDef):
|
|
|
|
VIEW = AllocateView
|
|
|
|
SCHEMA = schemas.Allocate
|
|
|
|
|
|
|
|
|
|
|
|
class DeallocateDef(ActionDef):
|
|
|
|
VIEW = DeallocateView
|
|
|
|
SCHEMA = schemas.Deallocate
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class PrepareDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Prepare
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class LiveDef(ActionDef):
|
2020-12-28 14:31:57 +00:00
|
|
|
VIEW = LiveView
|
2018-08-03 16:15:08 +00:00
|
|
|
SCHEMA = schemas.Live
|
2020-12-29 16:36:28 +00:00
|
|
|
AUTH = False
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ReserveDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Reserve
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class CancelReservationDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.CancelReservation
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class SellDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Sell
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class DonateDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Donate
|
|
|
|
|
|
|
|
|
2020-11-23 10:43:30 +00:00
|
|
|
class RentDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Rent
|
|
|
|
|
|
|
|
|
2019-07-07 19:36:09 +00:00
|
|
|
class MakeAvailable(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.MakeAvailable
|
|
|
|
|
2021-04-30 15:54:03 +00:00
|
|
|
|
2021-10-05 09:56:19 +00:00
|
|
|
class Delete(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Delete
|
|
|
|
|
|
|
|
|
2021-04-22 09:10:13 +00:00
|
|
|
class ConfirmDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Confirm
|
|
|
|
|
2019-07-07 19:36:09 +00:00
|
|
|
|
2021-04-30 10:44:32 +00:00
|
|
|
class ConfirmRevokeDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ConfirmRevoke
|
|
|
|
|
|
|
|
|
2021-04-30 15:54:03 +00:00
|
|
|
class RevokeDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Revoke
|
|
|
|
|
|
|
|
|
2021-03-25 10:26:30 +00:00
|
|
|
class TradeDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.Trade
|
|
|
|
|
|
|
|
|
2021-06-24 17:09:12 +00:00
|
|
|
class ConfirmDocumentDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ConfirmDocument
|
|
|
|
|
|
|
|
|
|
|
|
class RevokeDocumentDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.RevokeDocument
|
|
|
|
|
|
|
|
|
2021-06-28 14:06:07 +00:00
|
|
|
class ConfirmRevokeDocumentDef(ActionDef):
|
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ConfirmRevokeDocument
|
2021-06-24 17:09:12 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class CancelTradeDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.CancelTrade
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ToDisposeProductDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.ToDisposeProduct
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class DisposeProductDef(ActionDef):
|
2018-08-03 16:15:08 +00:00
|
|
|
VIEW = None
|
|
|
|
SCHEMA = schemas.DisposeProduct
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class MigrateToDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
2018-08-03 16:15:08 +00:00
|
|
|
SCHEMA = schemas.MigrateTo
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class MigrateFromDef(ActionDef):
|
2018-07-22 20:42:49 +00:00
|
|
|
VIEW = None
|
2018-08-03 16:15:08 +00:00
|
|
|
SCHEMA = schemas.MigrateFrom
|
2021-09-06 10:45:47 +00:00
|
|
|
|
|
|
|
|
2021-09-08 11:54:10 +00:00
|
|
|
class MoveOnDocumentDef(ActionDef):
|
2021-09-06 10:45:47 +00:00
|
|
|
VIEW = None
|
2021-09-08 11:54:10 +00:00
|
|
|
SCHEMA = schemas.MoveOnDocument
|