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.
devicehub-teal/ereuse_devicehub/resources/schemas.py

31 lines
800 B
Python

from enum import Enum
from marshmallow import post_load
from marshmallow.fields import DateTime, List, String
from teal.marshmallow import URL
from teal.resource import Schema
from ereuse_devicehub.resources import models as m
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')
updated = DateTime('iso', dump_only=True, description=m.Thing.updated.comment)
created = DateTime('iso', dump_only=True, description=m.Thing.created.comment)
@post_load
def remove_type(self, data: dict):
data.pop('type', None)