This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-04-27 17:16:43 +00:00
|
|
|
from enum import Enum
|
|
|
|
|
2018-05-11 16:58:48 +00:00
|
|
|
from marshmallow import post_load
|
2018-10-05 15:13:23 +00:00
|
|
|
from marshmallow.fields import DateTime, List, String
|
|
|
|
from teal.marshmallow import URL
|
2018-09-07 10:38:02 +00:00
|
|
|
from teal.resource import Schema
|
2018-04-27 17:16:43 +00:00
|
|
|
|
2018-06-12 14:50:05 +00:00
|
|
|
from ereuse_devicehub.resources import models as m
|
2018-04-27 17:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UnitCodes(Enum):
|
|
|
|
mbyte = '4L'
|
|
|
|
mbps = 'E20'
|
|
|
|
mhz = 'MHZ'
|
|
|
|
gbyte = 'E34'
|
|
|
|
ghz = 'A86'
|
|
|
|
bit = 'A99'
|
|
|
|
kgm = 'KGM'
|
|
|
|
m = 'MTR'
|
|
|
|
|
|
|
|
|
|
|
|
class Thing(Schema):
|
|
|
|
type = String(description='Only required when it is nested.')
|
|
|
|
same_as = List(URL(dump_only=True), dump_only=True, data_key='sameAs')
|
2018-06-24 14:57:49 +00:00
|
|
|
updated = DateTime('iso', dump_only=True, description=m.Thing.updated.comment.strip())
|
|
|
|
created = DateTime('iso', dump_only=True, description=m.Thing.created.comment.strip())
|
2018-05-11 16:58:48 +00:00
|
|
|
|
|
|
|
@post_load
|
|
|
|
def remove_type(self, data: dict):
|
|
|
|
data.pop('type', None)
|