2020-07-20 17:09:05 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import models
|
|
|
|
from marshm import ma
|
|
|
|
from marshmallow import fields
|
|
|
|
|
|
|
|
"""
|
|
|
|
Schemas of SQLAlchemy objects
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
__author__ = "@tormakris"
|
|
|
|
__copyright__ = "Copyright 2020, Birbnetes Team"
|
|
|
|
__module_name__ = "schemas"
|
|
|
|
__version__text__ = "1"
|
|
|
|
|
|
|
|
|
|
|
|
class SensorSchema(ma.SQLAlchemyAutoSchema):
|
|
|
|
"""
|
|
|
|
Sensor schema autogenerated
|
|
|
|
"""
|
|
|
|
class Meta:
|
|
|
|
model = models.Sensor
|
|
|
|
include_fk = True
|
2020-07-20 18:19:31 +02:00
|
|
|
exclude = ('id',)
|
2020-07-20 17:09:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
class DeviceSchema(ma.SQLAlchemyAutoSchema):
|
|
|
|
"""
|
|
|
|
Device schema autogenerated
|
|
|
|
"""
|
|
|
|
sensors = fields.Nested(SensorSchema, many=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = models.Device
|
|
|
|
include_relationships = True
|
|
|
|
exclude = ('lastupdate',)
|