2018-06-20 21:18:15 +00:00
|
|
|
from flask import current_app as app
|
2018-11-17 17:24:34 +00:00
|
|
|
from marshmallow import Schema as MarshmallowSchema, ValidationError, fields as f, validates_schema
|
2019-05-11 14:27:22 +00:00
|
|
|
from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, Nested, String, \
|
2018-10-05 15:13:23 +00:00
|
|
|
TimeDelta, UUID
|
2018-11-26 12:11:07 +00:00
|
|
|
from marshmallow.validate import Length, OneOf, Range
|
2018-08-03 16:15:08 +00:00
|
|
|
from sqlalchemy.util import OrderedSet
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal.enums import Country, Currency, Subdivision
|
2018-10-08 08:37:32 +00:00
|
|
|
from teal.marshmallow import EnumField, IP, SanitizedStr, URL, Version
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal.resource import Schema
|
2018-06-20 21:18:15 +00:00
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
from ereuse_devicehub.marshmallow import NestedOn
|
2018-11-17 17:24:34 +00:00
|
|
|
from ereuse_devicehub.resources import enums
|
2019-05-11 14:27:22 +00:00
|
|
|
from ereuse_devicehub.resources.action import models as m
|
2019-02-03 16:12:53 +00:00
|
|
|
from ereuse_devicehub.resources.agent import schemas as s_agent
|
|
|
|
from ereuse_devicehub.resources.device import schemas as s_device
|
2019-04-16 15:47:28 +00:00
|
|
|
from ereuse_devicehub.resources.enums import AppearanceRange, BiosAccessRange, FunctionalityRange, \
|
2019-05-08 17:12:05 +00:00
|
|
|
PhysicalErasureMethod, R_POSITIVE, RatingRange, ReceiverRole, \
|
2019-05-11 14:27:22 +00:00
|
|
|
Severity, SnapshotSoftware, TestDataStorageLength
|
2018-04-27 17:16:43 +00:00
|
|
|
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
|
|
|
|
from ereuse_devicehub.resources.schemas import Thing
|
2019-02-03 16:12:53 +00:00
|
|
|
from ereuse_devicehub.resources.user import schemas as s_user
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Action(Thing):
|
|
|
|
__doc__ = m.Action.__doc__
|
2018-06-15 13:31:03 +00:00
|
|
|
id = UUID(dump_only=True)
|
2018-09-30 10:29:33 +00:00
|
|
|
name = SanitizedStr(default='',
|
|
|
|
validate=Length(max=STR_BIG_SIZE),
|
2019-05-11 14:27:22 +00:00
|
|
|
description=m.Action.name.comment)
|
|
|
|
closed = Boolean(missing=True, description=m.Action.closed.comment)
|
|
|
|
severity = EnumField(Severity, description=m.Action.severity.comment)
|
|
|
|
description = SanitizedStr(default='', description=m.Action.description.comment)
|
|
|
|
start_time = DateTime(data_key='startTime', description=m.Action.start_time.comment)
|
|
|
|
end_time = DateTime(data_key='endTime', description=m.Action.end_time.comment)
|
2018-08-03 16:15:08 +00:00
|
|
|
snapshot = NestedOn('Snapshot', dump_only=True)
|
2019-05-11 14:27:22 +00:00
|
|
|
agent = NestedOn(s_agent.Agent, description=m.Action.agent_id.comment)
|
2019-02-03 16:12:53 +00:00
|
|
|
author = NestedOn(s_user.User, dump_only=True, exclude=('token',))
|
|
|
|
components = NestedOn(s_device.Component, dump_only=True, many=True)
|
2019-05-11 14:27:22 +00:00
|
|
|
parent = NestedOn(s_device.Computer, dump_only=True, description=m.Action.parent_id.comment)
|
|
|
|
url = URL(dump_only=True, description=m.Action.url.__doc__)
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ActionWithOneDevice(Action):
|
|
|
|
__doc__ = m.ActionWithOneDevice.__doc__
|
2019-02-03 16:12:53 +00:00
|
|
|
device = NestedOn(s_device.Device, only_query='id')
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ActionWithMultipleDevices(Action):
|
|
|
|
__doc__ = m.ActionWithMultipleDevices.__doc__
|
2019-07-07 19:36:09 +00:00
|
|
|
devices = NestedOn(s_device.Device,
|
|
|
|
many=True,
|
|
|
|
required=True, # todo test ensuring len(devices) >= 1
|
|
|
|
only_query='id',
|
|
|
|
collection_class=OrderedSet)
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Add(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Add.__doc__
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Remove(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Remove.__doc__
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Allocate(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Allocate.__doc__
|
2020-11-18 17:13:13 +00:00
|
|
|
agent = NestedOn(s_agent.Agent, only_query='id', required=False, comment=m.Trade.to_comment)
|
|
|
|
description = SanitizedStr(default='', description=m.Action.description.comment)
|
|
|
|
start_time = DateTime(data_key='start_time', description=m.Action.start_time.comment)
|
|
|
|
end_time = DateTime(data_key='end_time', description=m.Action.end_time.comment)
|
|
|
|
code = SanitizedStr(validate=Length(min=1, max=STR_BIG_SIZE),
|
|
|
|
required=False,
|
|
|
|
description='The code of the agent to assigned.')
|
|
|
|
end_users = Integer(validate=[Range(min=1, error="Value must be greater than 0")],
|
|
|
|
required=True)
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class EraseBasic(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.EraseBasic.__doc__
|
2018-11-17 17:24:34 +00:00
|
|
|
steps = NestedOn('Step', many=True)
|
|
|
|
standards = f.List(EnumField(enums.ErasureStandards), dump_only=True)
|
2018-12-30 11:43:29 +00:00
|
|
|
certificate = URL(dump_only=True)
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EraseSectors(EraseBasic):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.EraseSectors.__doc__
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2018-11-17 17:24:34 +00:00
|
|
|
class ErasePhysical(EraseBasic):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.ErasePhysical.__doc__
|
2018-11-17 17:24:34 +00:00
|
|
|
method = EnumField(PhysicalErasureMethod, description=PhysicalErasureMethod.__doc__)
|
|
|
|
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
class Step(Schema):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Step.__doc__
|
2018-06-10 16:47:49 +00:00
|
|
|
type = String(description='Only required when it is nested.')
|
|
|
|
start_time = DateTime(required=True, data_key='startTime')
|
|
|
|
end_time = DateTime(required=True, data_key='endTime')
|
2019-05-11 14:27:22 +00:00
|
|
|
severity = EnumField(Severity, description=m.Action.severity.comment)
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StepZero(Step):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.StepZero.__doc__
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StepRandom(Step):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.StepRandom.__doc__
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Benchmark(ActionWithOneDevice):
|
2019-03-10 19:41:10 +00:00
|
|
|
__doc__ = m.Benchmark.__doc__
|
|
|
|
elapsed = TimeDelta(precision=TimeDelta.SECONDS, required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkDataStorage(Benchmark):
|
|
|
|
__doc__ = m.BenchmarkDataStorage.__doc__
|
|
|
|
read_speed = Float(required=True, data_key='readSpeed')
|
|
|
|
write_speed = Float(required=True, data_key='writeSpeed')
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkWithRate(Benchmark):
|
|
|
|
__doc__ = m.BenchmarkWithRate.__doc__
|
|
|
|
rate = Float(required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkProcessor(BenchmarkWithRate):
|
|
|
|
__doc__ = m.BenchmarkProcessor.__doc__
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkProcessorSysbench(BenchmarkProcessor):
|
|
|
|
__doc__ = m.BenchmarkProcessorSysbench.__doc__
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkRamSysbench(BenchmarkWithRate):
|
|
|
|
__doc__ = m.BenchmarkRamSysbench.__doc__
|
|
|
|
|
|
|
|
|
|
|
|
class BenchmarkGraphicCard(BenchmarkWithRate):
|
|
|
|
__doc__ = m.BenchmarkGraphicCard.__doc__
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Test(ActionWithOneDevice):
|
2019-03-10 19:41:10 +00:00
|
|
|
__doc__ = m.Test.__doc__
|
|
|
|
|
|
|
|
|
2019-05-03 13:02:09 +00:00
|
|
|
class MeasureBattery(Test):
|
|
|
|
__doc__ = m.MeasureBattery.__doc__
|
|
|
|
size = Integer(required=True, description=m.MeasureBattery.size.comment)
|
|
|
|
voltage = Integer(required=True, description=m.MeasureBattery.voltage.comment)
|
2019-06-29 14:26:14 +00:00
|
|
|
cycle_count = Integer(data_key='cycleCount', description=m.MeasureBattery.cycle_count.comment)
|
2019-05-03 13:02:09 +00:00
|
|
|
health = EnumField(enums.BatteryHealth, description=m.MeasureBattery.health.comment)
|
|
|
|
|
|
|
|
|
2019-03-10 19:41:10 +00:00
|
|
|
class TestDataStorage(Test):
|
|
|
|
__doc__ = m.TestDataStorage.__doc__
|
2019-04-23 19:27:31 +00:00
|
|
|
elapsed = TimeDelta(precision=TimeDelta.SECONDS, required=True)
|
2019-03-10 19:41:10 +00:00
|
|
|
length = EnumField(TestDataStorageLength, required=True)
|
|
|
|
status = SanitizedStr(lower=True, validate=Length(max=STR_SIZE), required=True)
|
|
|
|
lifetime = TimeDelta(precision=TimeDelta.HOURS)
|
|
|
|
assessment = Boolean()
|
|
|
|
reallocated_sector_count = Integer(data_key='reallocatedSectorCount')
|
|
|
|
power_cycle_count = Integer(data_key='powerCycleCount')
|
|
|
|
reported_uncorrectable_errors = Integer(data_key='reportedUncorrectableErrors')
|
|
|
|
command_timeout = Integer(data_key='commandTimeout')
|
|
|
|
current_pending_sector_count = Integer(data_key='currentPendingSectorCount')
|
|
|
|
offline_uncorrectable = Integer(data_key='offlineUncorrectable')
|
|
|
|
remaining_lifetime_percentage = Integer(data_key='remainingLifetimePercentage')
|
|
|
|
|
|
|
|
|
|
|
|
class StressTest(Test):
|
|
|
|
__doc__ = m.StressTest.__doc__
|
2019-04-23 19:27:31 +00:00
|
|
|
elapsed = TimeDelta(precision=TimeDelta.SECONDS, required=True)
|
2019-03-10 19:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestAudio(Test):
|
|
|
|
__doc__ = m.TestAudio.__doc__
|
2019-05-08 17:12:05 +00:00
|
|
|
speaker = Boolean(description=m.TestAudio._speaker.comment)
|
|
|
|
microphone = Boolean(description=m.TestAudio._microphone.comment)
|
2019-03-10 19:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestConnectivity(Test):
|
|
|
|
__doc__ = m.TestConnectivity.__doc__
|
|
|
|
|
|
|
|
|
2019-04-23 19:27:31 +00:00
|
|
|
class TestCamera(Test):
|
|
|
|
__doc__ = m.TestCamera.__doc__
|
|
|
|
|
2019-03-13 15:32:59 +00:00
|
|
|
|
2019-04-23 19:27:31 +00:00
|
|
|
class TestKeyboard(Test):
|
|
|
|
__doc__ = m.TestKeyboard.__doc__
|
2019-03-13 15:32:59 +00:00
|
|
|
|
2019-04-23 19:27:31 +00:00
|
|
|
|
|
|
|
class TestTrackpad(Test):
|
|
|
|
__doc__ = m.TestTrackpad.__doc__
|
|
|
|
|
|
|
|
|
|
|
|
class TestBios(Test):
|
|
|
|
__doc__ = m.TestBios.__doc__
|
|
|
|
bios_power_on = Boolean()
|
2019-04-30 00:02:23 +00:00
|
|
|
access_range = EnumField(BiosAccessRange, data_key='accessRange')
|
2019-03-13 15:32:59 +00:00
|
|
|
|
|
|
|
|
2019-05-08 17:12:05 +00:00
|
|
|
class VisualTest(Test):
|
|
|
|
__doc__ = m.VisualTest.__doc__
|
2019-05-10 09:58:38 +00:00
|
|
|
appearance_range = EnumField(AppearanceRange, required=True, data_key='appearanceRange')
|
|
|
|
functionality_range = EnumField(FunctionalityRange,
|
|
|
|
required=True,
|
|
|
|
data_key='functionalityRange')
|
2019-04-30 00:02:23 +00:00
|
|
|
labelling = Boolean()
|
2019-03-10 19:41:10 +00:00
|
|
|
|
2019-02-27 22:36:26 +00:00
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Rate(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Rate.__doc__
|
2019-05-08 17:12:05 +00:00
|
|
|
rating = Integer(validate=Range(*R_POSITIVE),
|
2018-06-10 16:47:49 +00:00
|
|
|
dump_only=True,
|
2019-05-08 17:12:05 +00:00
|
|
|
description=m.Rate._rating.comment)
|
2018-07-14 14:41:22 +00:00
|
|
|
version = Version(dump_only=True,
|
2018-10-14 18:10:52 +00:00
|
|
|
description=m.Rate.version.comment)
|
2019-05-08 17:12:05 +00:00
|
|
|
appearance = Integer(validate=Range(enums.R_NEGATIVE),
|
|
|
|
dump_only=True,
|
|
|
|
description=m.Rate._appearance.comment)
|
|
|
|
functionality = Integer(validate=Range(enums.R_NEGATIVE),
|
|
|
|
dump_only=True,
|
|
|
|
description=m.Rate._functionality.comment)
|
|
|
|
rating_range = EnumField(RatingRange,
|
|
|
|
dump_only=True,
|
|
|
|
data_key='ratingRange',
|
|
|
|
description=m.Rate.rating_range.__doc__)
|
2018-06-10 16:47:49 +00:00
|
|
|
|
|
|
|
|
2019-04-16 15:47:28 +00:00
|
|
|
class RateComputer(Rate):
|
|
|
|
__doc__ = m.RateComputer.__doc__
|
2019-04-30 00:02:23 +00:00
|
|
|
processor = Float(dump_only=True)
|
|
|
|
ram = Float(dump_only=True)
|
|
|
|
data_storage = Float(dump_only=True, data_key='dataStorage')
|
|
|
|
graphic_card = Float(dump_only=True, data_key='graphicCard')
|
2019-02-27 22:36:26 +00:00
|
|
|
|
|
|
|
data_storage_range = EnumField(RatingRange, dump_only=True, data_key='dataStorageRange')
|
|
|
|
ram_range = EnumField(RatingRange, dump_only=True, data_key='ramRange')
|
|
|
|
processor_range = EnumField(RatingRange, dump_only=True, data_key='processorRange')
|
|
|
|
graphic_card_range = EnumField(RatingRange, dump_only=True, data_key='graphicCardRange')
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Price(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Price.__doc__
|
2018-10-14 18:10:52 +00:00
|
|
|
currency = EnumField(Currency, required=True, description=m.Price.currency.comment)
|
2018-10-15 09:21:21 +00:00
|
|
|
price = Decimal(places=m.Price.SCALE,
|
|
|
|
rounding=m.Price.ROUND,
|
2018-10-14 18:10:52 +00:00
|
|
|
required=True,
|
|
|
|
description=m.Price.price.comment)
|
|
|
|
version = Version(dump_only=True, description=m.Price.version.comment)
|
2019-04-16 15:47:28 +00:00
|
|
|
rating = NestedOn(Rate, dump_only=True, description=m.Price.rating_id.comment)
|
2018-07-14 14:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EreusePrice(Price):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.EreusePrice.__doc__
|
|
|
|
|
2018-07-14 14:41:22 +00:00
|
|
|
class Service(MarshmallowSchema):
|
|
|
|
class Type(MarshmallowSchema):
|
|
|
|
amount = Float()
|
|
|
|
percentage = Float()
|
|
|
|
|
|
|
|
standard = Nested(Type)
|
|
|
|
warranty2 = Nested(Type)
|
|
|
|
|
|
|
|
warranty2 = Float()
|
|
|
|
refurbisher = Nested(Service)
|
|
|
|
retailer = Nested(Service)
|
|
|
|
platform = Nested(Service)
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Install(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Install.__doc__
|
2018-09-30 10:29:33 +00:00
|
|
|
name = SanitizedStr(validate=Length(min=4, max=STR_BIG_SIZE),
|
|
|
|
required=True,
|
|
|
|
description='The name of the OS installed.')
|
2018-04-27 17:16:43 +00:00
|
|
|
elapsed = TimeDelta(precision=TimeDelta.SECONDS, required=True)
|
2018-11-26 12:11:07 +00:00
|
|
|
address = Integer(validate=OneOf({8, 16, 32, 64, 128, 256}))
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Snapshot(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Snapshot.__doc__
|
2018-05-13 13:13:12 +00:00
|
|
|
"""
|
|
|
|
The Snapshot updates the state of the device with information about
|
2019-05-11 14:27:22 +00:00
|
|
|
its components and actions performed at them.
|
2018-05-13 13:13:12 +00:00
|
|
|
|
|
|
|
See docs for more info.
|
|
|
|
"""
|
2018-06-20 21:18:15 +00:00
|
|
|
uuid = UUID()
|
2018-06-10 16:47:49 +00:00
|
|
|
software = EnumField(SnapshotSoftware,
|
|
|
|
required=True,
|
|
|
|
description='The software that generated this Snapshot.')
|
|
|
|
version = Version(required=True, description='The version of the software.')
|
2019-05-11 14:27:22 +00:00
|
|
|
actions = NestedOn(Action, many=True, dump_only=True)
|
2018-06-20 21:18:15 +00:00
|
|
|
elapsed = TimeDelta(precision=TimeDelta.SECONDS)
|
2019-02-03 16:12:53 +00:00
|
|
|
components = NestedOn(s_device.Component,
|
2018-05-13 13:13:12 +00:00
|
|
|
many=True,
|
|
|
|
description='A list of components that are inside of the device'
|
|
|
|
'at the moment of this Snapshot.'
|
|
|
|
'Order is preserved, so the component num 0 when'
|
|
|
|
'submitting is the component num 0 when returning it back.')
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
@validates_schema
|
|
|
|
def validate_workbench_version(self, data: dict):
|
2018-06-10 16:47:49 +00:00
|
|
|
if data['software'] == SnapshotSoftware.Workbench:
|
2018-04-27 17:16:43 +00:00
|
|
|
if data['version'] < app.config['MIN_WORKBENCH']:
|
|
|
|
raise ValidationError(
|
2018-07-14 14:41:22 +00:00
|
|
|
'Min. supported Workbench version is '
|
2018-09-08 14:46:39 +00:00
|
|
|
'{} but yours is {}.'.format(app.config['MIN_WORKBENCH'], data['version']),
|
2018-04-27 17:16:43 +00:00
|
|
|
field_names=['version']
|
|
|
|
)
|
|
|
|
|
|
|
|
@validates_schema
|
|
|
|
def validate_components_only_workbench(self, data: dict):
|
2020-03-03 11:03:09 +00:00
|
|
|
if (data['software'] != SnapshotSoftware.Workbench) and (data['software'] != SnapshotSoftware.WorkbenchAndroid):
|
2018-06-20 21:18:15 +00:00
|
|
|
if data.get('components', None) is not None:
|
2018-04-27 17:16:43 +00:00
|
|
|
raise ValidationError('Only Workbench can add component info',
|
|
|
|
field_names=['components'])
|
|
|
|
|
2018-06-20 21:18:15 +00:00
|
|
|
@validates_schema
|
|
|
|
def validate_only_workbench_fields(self, data: dict):
|
|
|
|
"""Ensures workbench has ``elapsed`` and ``uuid`` and no others."""
|
|
|
|
# todo test
|
|
|
|
if data['software'] == SnapshotSoftware.Workbench:
|
|
|
|
if not data.get('uuid', None):
|
2020-03-03 11:03:09 +00:00
|
|
|
raise ValidationError('Snapshots from Workbench and WorkbenchAndroid must have uuid',
|
2018-06-20 21:18:15 +00:00
|
|
|
field_names=['uuid'])
|
2018-09-08 14:46:39 +00:00
|
|
|
if data.get('elapsed', None) is None:
|
2018-06-20 21:18:15 +00:00
|
|
|
raise ValidationError('Snapshots from Workbench must have elapsed',
|
|
|
|
field_names=['elapsed'])
|
2020-03-03 11:03:09 +00:00
|
|
|
elif data['software'] == SnapshotSoftware.WorkbenchAndroid:
|
|
|
|
if not data.get('uuid', None):
|
|
|
|
raise ValidationError('Snapshots from Workbench and WorkbenchAndroid must have uuid',
|
|
|
|
field_names=['uuid'])
|
2018-06-20 21:18:15 +00:00
|
|
|
else:
|
|
|
|
if data.get('uuid', None):
|
2020-03-03 11:03:09 +00:00
|
|
|
raise ValidationError('Only Snapshots from Workbench or WorkbenchAndroid can have uuid',
|
2018-06-20 21:18:15 +00:00
|
|
|
field_names=['uuid'])
|
|
|
|
if data.get('elapsed', None):
|
|
|
|
raise ValidationError('Only Snapshots from Workbench can have elapsed',
|
|
|
|
field_names=['elapsed'])
|
|
|
|
|
2018-04-27 17:16:43 +00:00
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ToRepair(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.ToRepair.__doc__
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Repair(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Repair.__doc__
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2019-07-07 19:36:09 +00:00
|
|
|
class Ready(ActionWithMultipleDevices):
|
|
|
|
__doc__ = m.Ready.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class ToPrepare(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.ToPrepare.__doc__
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Prepare(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Prepare.__doc__
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Live(ActionWithOneDevice):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Live.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
ip = IP(dump_only=True)
|
|
|
|
subdivision_confidence = Integer(dump_only=True, data_key='subdivisionConfidence')
|
|
|
|
subdivision = EnumField(Subdivision, dump_only=True)
|
|
|
|
country = EnumField(Country, dump_only=True)
|
2018-09-30 10:29:33 +00:00
|
|
|
city = SanitizedStr(lower=True, dump_only=True)
|
2018-08-03 16:15:08 +00:00
|
|
|
city_confidence = Integer(dump_only=True, data_key='cityConfidence')
|
2018-09-30 10:29:33 +00:00
|
|
|
isp = SanitizedStr(lower=True, dump_only=True)
|
|
|
|
organization = SanitizedStr(lower=True, dump_only=True)
|
|
|
|
organization_type = SanitizedStr(lower=True, dump_only=True, data_key='organizationType')
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Organize(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Organize.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Reserve(Organize):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Reserve.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CancelReservation(Organize):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.CancelReservation.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Trade(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Trade.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
shipping_date = DateTime(data_key='shippingDate')
|
2018-09-30 10:29:33 +00:00
|
|
|
invoice_number = SanitizedStr(validate=Length(max=STR_SIZE), data_key='invoiceNumber')
|
2018-08-03 16:15:08 +00:00
|
|
|
price = NestedOn(Price)
|
2019-02-03 16:12:53 +00:00
|
|
|
to = NestedOn(s_agent.Agent, only_query='id', required=True, comment=m.Trade.to_comment)
|
2018-08-03 16:15:08 +00:00
|
|
|
confirms = NestedOn(Organize)
|
|
|
|
|
|
|
|
|
2019-12-12 20:17:35 +00:00
|
|
|
class InitTransfer(Trade):
|
|
|
|
__doc__ = m.InitTransfer.__doc__
|
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class Sell(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Sell.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Donate(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Donate.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Rent(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Rent.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-07-07 19:36:09 +00:00
|
|
|
class MakeAvailable(ActionWithMultipleDevices):
|
|
|
|
__doc__ = m.MakeAvailable.__doc__
|
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class CancelTrade(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.CancelTrade.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToDisposeProduct(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.ToDisposeProduct.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DisposeProduct(Trade):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.DisposeProduct.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
|
|
|
|
|
2019-12-21 15:41:23 +00:00
|
|
|
class TransferOwnershipBlockchain(Trade):
|
|
|
|
__doc__ = m.TransferOwnershipBlockchain.__doc__
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Receive(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Receive.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
role = EnumField(ReceiverRole)
|
|
|
|
|
|
|
|
|
2019-05-11 14:27:22 +00:00
|
|
|
class Migrate(ActionWithMultipleDevices):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.Migrate.__doc__
|
2018-08-03 16:15:08 +00:00
|
|
|
other = URL()
|
|
|
|
|
|
|
|
|
|
|
|
class MigrateTo(Migrate):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.MigrateTo.__doc__
|
2018-07-22 20:42:49 +00:00
|
|
|
|
|
|
|
|
2018-08-03 16:15:08 +00:00
|
|
|
class MigrateFrom(Migrate):
|
2019-02-03 16:12:53 +00:00
|
|
|
__doc__ = m.MigrateFrom.__doc__
|
2019-12-23 12:31:54 +00:00
|
|
|
|
2020-08-17 14:45:18 +00:00
|
|
|
|
2019-12-23 12:31:54 +00:00
|
|
|
class Transferred(ActionWithMultipleDevices):
|
|
|
|
__doc__ = m.Transferred.__doc__
|