model-service/model_service/schemas/info_schema.py

16 lines
461 B
Python
Raw Normal View History

2020-04-14 17:03:15 +02:00
#!/usr/bin/env python3
from marshmallow import fields, Schema
from marshmallow.utils import get_value, missing
from marshmallow.validate import OneOf
import uuid
class InfoSchema(Schema):
id = fields.UUID(default=uuid.uuid4, missing=uuid.uuid4)
2020-10-01 19:38:34 +02:00
target_class_name = fields.String()
2020-04-14 17:03:15 +02:00
@classmethod # This threats none values as missing
def get_attribute(cls, attr, obj, default):
return get_value(attr, obj, default=default) or missing