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/documents/schemas.py

45 lines
1.6 KiB
Python
Raw Permalink Normal View History

2021-08-10 10:45:03 +00:00
from marshmallow import post_load
2023-03-21 11:08:13 +00:00
from marshmallow.fields import Boolean, DateTime, Float, Integer, validate
2021-08-10 10:45:03 +00:00
from marshmallow.validate import Range
2023-03-21 11:08:13 +00:00
2021-08-10 10:45:03 +00:00
from ereuse_devicehub.marshmallow import NestedOn
2023-03-21 11:08:13 +00:00
from ereuse_devicehub.resources.documents import models as m
2021-07-21 06:35:18 +00:00
from ereuse_devicehub.resources.schemas import Thing
2021-08-10 10:45:03 +00:00
from ereuse_devicehub.resources.tradedocument.models import TradeDocument
2023-03-21 11:08:13 +00:00
from ereuse_devicehub.teal.marshmallow import URL, SanitizedStr
2021-07-21 06:35:18 +00:00
class DataWipeDocument(Thing):
__doc__ = m.DataWipeDocument.__doc__
id = Integer(description=m.DataWipeDocument.id.comment, dump_only=True)
2023-03-21 11:08:13 +00:00
url = URL(required=False, description=m.DataWipeDocument.url.comment)
success = Boolean(
required=False, default=False, description=m.DataWipeDocument.success.comment
)
software = SanitizedStr(description=m.DataWipeDocument.software.comment)
2023-03-21 11:08:13 +00:00
date = DateTime(
data_key='endTime', required=False, description=m.DataWipeDocument.date.comment
)
id_document = SanitizedStr(
data_key='documentId',
required=False,
default='',
description=m.DataWipeDocument.id_document.comment,
)
file_name = SanitizedStr(
data_key='filename',
default='',
description=m.DataWipeDocument.file_name.comment,
validate=validate.Length(max=100),
)
file_hash = SanitizedStr(
data_key='hash',
default='',
description=m.DataWipeDocument.file_hash.comment,
validate=validate.Length(max=64),
)
2021-08-10 10:45:03 +00:00
@post_load
def get_trade_document(self, data):
data['document_type'] = 'DataWipeDocument'