Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Source code for parseur.schemas.export_config
from enum import Enum
from marshmallow import RAISE , fields , validate
from parseur.schemas import BaseSchema
[docs] class ExportType ( str , Enum ):
"""
Type of an export configuration.
- ``PARSER``: export the document-level result (one row per document).
- ``PARSER_FIELD``: export the rows of a table field.
"""
[docs] PARSER_FIELD = "PARSER_FIELD"
[docs] class ExportConfigReadSchema ( BaseSchema ):
"""Read schema for a mailbox export configuration."""
[docs] id = fields . Int ( required = True )
[docs] name = fields . String ( required = True )
[docs] type = fields . String ( required = True )
[docs] parser_id = fields . Int ( required = True )
# Present only for a PARSER_FIELD (table) export config.
[docs] parser_field_id = fields . String ( allow_none = True )
[docs] parser_field_name = fields . String ( allow_none = True )
# Columns included in the export.
[docs] items = fields . List ( fields . String (), required = True )
# Download URLs for the configured export (resolved to absolute URLs).
[docs] csv_download = fields . String ( allow_none = True )
[docs] xls_download = fields . String ( allow_none = True )
[docs] class ExportConfigWriteSchema ( BaseSchema ):
"""
Validate/serialize the body sent when creating or updating an export config.
Unknown fields are rejected so read-only properties and typos never reach
the API silently.
"""
[docs] type = fields . String (
validate = validate . OneOf (
[ e . value for e in ExportType ],
error = "Must be one of: " + ", " . join ( e . value for e in ExportType ) + "." ,
)
)
# Required when ``type`` is PARSER_FIELD; must be a table field id (e.g. "PF1").
[docs] parser_field_id = fields . String ( allow_none = True )
[docs] items = fields . List (
fields . String (),
validate = validate . Length ( min = 1 , error = "items cannot be empty." ),
)