api.v1.serializers package¶
api.v1.serializers package containing serializers for the Eonvelope API version 1.
- class api.v1.serializers.AccountSerializer(*args, **kwargs)[source]¶
Bases:
BaseAccountSerializerThe standard serializer for a
core.models.Account.Includes a nested serializer for the related field mailboxes.
- _declared_fields = {'mailboxes': BaseMailboxSerializer(many=True, read_only=True): id = BigIntegerField(label='ID', read_only=True) is_favorite = BooleanField(label='Favorite status', required=False) is_healthy = BooleanField(allow_null=True, label='Health status', read_only=True) last_error = CharField(read_only=True, style={'base_template': 'textarea.html'}) last_error_occurred_at = DateTimeField(allow_null=True, label='Time of last error occurrence', read_only=True) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) name = CharField(read_only=True) type = ChoiceField(choices=[('INBOX', 'Inbox'), ('OUTBOX', 'Outbox'), ('SENT', 'Sent'), ('JUNK', 'Junk'), ('DRAFTS', 'Drafts'), ('TRASH', 'Trash'), ('', '')], read_only=True) save_attachments = BooleanField(help_text='Whether the attachments from the emails in this mailbox will be saved.', required=False) save_to_eml = BooleanField(help_text='Whether the emails in this mailbox will be stored in .eml files.', label='Save as .eml', required=False) account = PrimaryKeyRelatedField(read_only=True), 'user': HiddenField(default=CurrentUserDefault())}¶
- mailboxes¶
The mailboxes of the account are serialized by
core.models.MailboxSerializers.BaseMailboxSerializer.BaseMailboxSerializer.
- class api.v1.serializers.BaseAccountSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Account.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Accountshould inherit from this.- user¶
The
core.models.Account.Account.userfield is included but hidden.
- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsandexcludemust not be shortened in subclasses.- fields = '__all__'¶
Include all fields.
- read_only_fields: Final[list[str]] = ['is_healthy', 'last_error', 'last_error_occurred_at', 'created', 'updated']¶
The
core.models.Account.Account.is_healthy,core.models.Account.Account.createdandcore.models.Account.Account.updatedfields are read-only.
- extra_kwargs = {'password': {'write_only': True}}¶
The
core.models.Account.Account.passwordfield is set to write-only for security reasons.
- _declared_fields = {'user': HiddenField(default=CurrentUserDefault())}¶
- class api.v1.serializers.BaseAttachmentSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Attachment.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Attachmentshould inherit from this.- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsandexcludemust not be shortened in subclasses.- model¶
alias of
Attachment
- exclude: ClassVar[list[str]] = ['file_path']¶
Exclude the
core.models.Attachment.Attachment.file_pathfield.
- read_only_fields: Final[list[str]] = ['file_name', 'content_disposition', 'content_id', 'content_maintype', 'content_subtype', 'datasize', 'email', 'created', 'updated']¶
The
core.models.Attachment.Attachment.is_healthy,core.models.Attachment.Attachment.datasize,core.models.Attachment.Attachment.email,core.models.Attachment.Attachment.createdandcore.models.Attachment.Attachment.updatedfields are read-only.
- _declared_fields = {}¶
- class api.v1.serializers.BaseCorrespondentSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Correspondent.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Correspondentshould inherit from this.- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsmust not be shortened in subclasses.- model¶
alias of
Correspondent
- exclude: Final[list[str]] = ['user']¶
Exclude only the
core.models.Correspondent.Correspondent.userfield.
- read_only_fields: Final[list[str]] = ['email_address', 'email_name', 'list_id', 'list_owner', 'list_subscribe', 'list_unsubscribe', 'list_unsubscribe_post', 'list_post', 'list_help', 'list_archive', 'created', 'updated']¶
The
core.models.Correspondent.Correspondent.email_address,core.models.Correspondent.Correspondent.createdandcore.models.Correspondent.Correspondent.updatedfields are read-only.
- _declared_fields = {}¶
- class api.v1.serializers.BaseDaemonSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Daemon.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Daemonshould inherit from this.- interval¶
The interval is serialized by
api.v1.serializers.django_celery_beat_serializers.IntervalScheduleSerializer. It can be altered.
- celery_task¶
The celery_task is serialized by
api.v1.serializers.django_celery_beat_serializers.PeriodicTaskSerializer.
- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsandexcludemust not be shortened in subclasses.- read_only_fields: Final[list[str]] = ['uuid', 'is_healthy', 'last_error', 'last_error_occurred_at', 'created', 'updated']¶
The
core.models.Daemon.Daemon.uuid,core.models.Daemon.Daemon.is_healthy,core.models.Daemon.Daemon.createdandcore.models.Daemon.Daemon.updatedfields are read-only.
- _declared_fields = {'celery_task': PeriodicTaskSerializer(read_only=True): enabled = BooleanField(help_text='Set to False to disable the schedule', read_only=True) last_run_at = DateTimeField(allow_null=True, help_text='Datetime that the schedule last triggered the task to run. Reset to None if enabled is set to False.', label='Last Run Datetime', read_only=True) total_run_count = IntegerField(help_text='Running count of how many times the schedule has triggered the task', label='Total Run Count', read_only=True), 'interval': IntervalScheduleSerializer(): id = IntegerField(label='ID', read_only=True) every = IntegerField(help_text='Number of interval periods to wait before running the task again', label='Number of Periods', max_value=2147483647, min_value=1) period = ChoiceField(choices=[('days', 'Days'), ('hours', 'Hours'), ('minutes', 'Minutes'), ('seconds', 'Seconds'), ('microseconds', 'Microseconds')], help_text='The type of period between task runs (Example: days)', label='Interval Period')}¶
- validate(attrs)[source]¶
Include full model-side validation to allow testing of account on submission.
- update(instance, validated_data)[source]¶
Extended to add the intervaldata to the instance.
Important
The nested intervaldata must be popped as update does not support nested dicts! There should not be duplicate IntervalSchedules. https://django-celery-beat.readthedocs.io/en/latest/index.html#example-creating-interval-based-periodic-task
- create(validated_data)[source]¶
Extended to add the intervaldata to the instance.
Important
The nested intervaldata must be popped as create does not support nested dicts! There should not be duplicate IntervalSchedules. https://django-celery-beat.readthedocs.io/en/latest/index.html#example-creating-interval-based-periodic-task
- class api.v1.serializers.BaseEmailCorrespondentSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.EmailCorrespondent.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.EmailCorrespondentshould inherit from this.- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsmust not be shortened in subclasses.- model¶
alias of
EmailCorrespondent
- _declared_fields = {}¶
- class api.v1.serializers.BaseEmailSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Email.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Emailshould inherit from this.- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsandexcludemust not be shortened in subclasses.- exclude: ClassVar[list[str]] = ['file_path']¶
Exclude the
core.models.Email.Email.file_pathfield.
- read_only_fields: Final[list[str]] = ['message_id', 'datetime', 'subject', 'plain_bodytext', 'html_bodytext', 'in_reply_to', 'references', 'datasize', 'correspondents', 'mailbox', 'headers', 'x_spam_flag', 'created', 'updated']¶
All fields except for
core.models.Email.Email.is_favoriteare read-only.
- _declared_fields = {}¶
- class api.v1.serializers.BaseMailboxSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe base serializer for
core.models.Mailbox.Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for
core.models.Mailboxshould inherit from this.- class Meta[source]¶
Bases:
objectMetadata class for the base serializer.
Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this.
read_only_fieldsmust not be shortened in subclasses.- fields = '__all__'¶
Includes all fields.
- read_only_fields: Final[list[str]] = ['name', 'type', 'account', 'is_healthy', 'last_error', 'last_error_occurred_at', 'created', 'updated']¶
The
core.models.Mailbox.Mailbox.name,core.models.Mailbox.Mailbox.type,core.models.Mailbox.Mailbox.account,core.models.Mailbox.Mailbox.is_healthy,core.models.Mailbox.Mailbox.createdandcore.models.Mailbox.Mailbox.updatedfields are read-only.
- _declared_fields = {}¶
- class api.v1.serializers.CorrespondentEmailSerializer(*args, **kwargs)[source]¶
Bases:
BaseEmailCorrespondentSerializerThe serializer for emails from
core.models.EmailCorrespondent.Used to serialize the emails belonging to a correspondent. Does not include this correspondent.
- email¶
The email is serialized by
api.v1.serializers.SimpleEmailSerializer.
- class Meta[source]¶
Bases:
MetaMetadata class for the serializer.
- fields: ClassVar[list[str]] = ['email', 'mention']¶
Includes only
core.models.EmailCorrespondent.EmailCorrespondent.emailandcore.models.EmailCorrespondent.EmailCorrespondent.mention.
- _declared_fields = {'email': BaseEmailSerializer(read_only=True): id = BigIntegerField(label='ID', read_only=True) is_favorite = BooleanField(label='Favorite status', required=False) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) message_id = CharField(label='Message-ID', read_only=True) datetime = DateTimeField(label='Time received', read_only=True) subject = CharField(read_only=True, style={'base_template': 'textarea.html'}) plain_bodytext = CharField(read_only=True, style={'base_template': 'textarea.html'}) html_bodytext = CharField(label='HTML bodytext', read_only=True, style={'base_template': 'textarea.html'}) datasize = IntegerField(read_only=True) headers = JSONField(allow_null=True, decoder=None, encoder=None, read_only=True, style={'base_template': 'textarea.html'}) x_spam_flag = BooleanField(allow_null=True, label='X-Spam Flag', read_only=True) mailbox = PrimaryKeyRelatedField(read_only=True) in_reply_to = PrimaryKeyRelatedField(allow_empty=False, label='In reply to email', many=True, read_only=True) references = PrimaryKeyRelatedField(allow_empty=False, label='Referencing emails', many=True, read_only=True) correspondents = PrimaryKeyRelatedField(many=True, read_only=True)}¶
- class api.v1.serializers.CorrespondentSerializer(*args, **kwargs)[source]¶
Bases:
BaseCorrespondentSerializerThe standard serializer for a
core.models.Correspondent.Correspondent.Includes a nested serializer for the
core.models.Correspondent.Correspondent.emailsfield.- emails¶
The emails are set from the
core.models.EmailCorrespondent.EmailCorrespondentvia :fu`core.models.EmailCorrespondent`
- _declared_fields = {'emails': SerializerMethodField(read_only=True)}¶
- get_emails(instance)[source]¶
Serializes the emails connected to the instance to be serialized.
- Parameters:
instance (
Correspondent) – The instance being serialized.- Return type:
- Returns:
The serialized emails connected to the instance to be serialized. An empty list if the the user is not authenticated.
- class api.v1.serializers.DatabaseStatsSerializer(*args, **kwargs)[source]¶
Bases:
SerializerSerializer for the stats of the database.
- _declared_fields = {'account_count': SerializerMethodField(read_only=True), 'attachment_count': SerializerMethodField(read_only=True), 'correspondent_count': SerializerMethodField(read_only=True), 'daemon_count': SerializerMethodField(read_only=True), 'email_count': SerializerMethodField(read_only=True), 'mailbox_count': SerializerMethodField(read_only=True)}¶
- class api.v1.serializers.EmailCorrespondentSerializer(*args, **kwargs)[source]¶
Bases:
BaseEmailCorrespondentSerializerThe serializer for correspondents from
core.models.EmailCorrespondent.Used to serialize the correspondent belonging to an email. Does not include that email.
- correspondent¶
The correspondent is serialized by
api.v1.serializers.SimpleCorrespondentSerializer.
- class Meta[source]¶
Bases:
MetaMetadata class for the serializer.
- fields: ClassVar[list[str]] = ['correspondent', 'mention']¶
Includes only
core.models.EmailCorrespondent.EmailCorrespondent.correspondentandcore.models.EmailCorrespondent.EmailCorrespondent.mention.
- _declared_fields = {'correspondent': BaseCorrespondentSerializer(read_only=True): id = BigIntegerField(label='ID', read_only=True) is_favorite = BooleanField(label='Favorite status', required=False) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) email_address = CharField(read_only=True) email_name = CharField(help_text='The mailer name of the correspondent.', label='Mailer name', read_only=True, style={'base_template': 'textarea.html'}) real_name = CharField(allow_blank=True, help_text='The real name of the correspondent.', max_length=255, required=False) list_id = CharField(label='List ID', read_only=True, style={'base_template': 'textarea.html'}) list_owner = CharField(read_only=True, style={'base_template': 'textarea.html'}) list_subscribe = CharField(label='List-subscribe', read_only=True, style={'base_template': 'textarea.html'}) list_unsubscribe = CharField(label='List-unsubscribe', read_only=True, style={'base_template': 'textarea.html'}) list_unsubscribe_post = CharField(label='List-unsubscribe method', read_only=True) list_post = CharField(read_only=True, style={'base_template': 'textarea.html'}) list_help = CharField(read_only=True, style={'base_template': 'textarea.html'}) list_archive = CharField(read_only=True, style={'base_template': 'textarea.html'})}¶
- class api.v1.serializers.EmailSerializer(*args, **kwargs)[source]¶
Bases:
BaseEmailSerializerThe standard serializer for a
core.models.Email.Includes only the most relevant model fields. Includes nested serializers for the
core.models.Email.Email.replies,core.models.Email.Email.attachments`and :attr:`core.models.Email.Email.correspondentsforeign key and related fields.- replies: PrimaryKeyRelatedField¶
The replies mails are included by id only to prevent recursion.
- referenced_by: PrimaryKeyRelatedField¶
The referencing mails are included by id only to prevent recursion.
- attachments¶
The attachments are serialized by
eonvelope.AttachmentSerializers.BaseAttachmentSerializer.BaseAttachmentSerializer.
- _declared_fields = {'attachments': BaseAttachmentSerializer(many=True, read_only=True): id = BigIntegerField(label='ID', read_only=True) is_favorite = BooleanField(label='Favorite status', required=False) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) file_name = CharField(label='Filename', read_only=True) content_disposition = CharField(read_only=True) content_id = CharField(label='Content ID', read_only=True) content_maintype = CharField(read_only=True) content_subtype = CharField(read_only=True) datasize = IntegerField(read_only=True) email = PrimaryKeyRelatedField(read_only=True), 'correspondents': SerializerMethodField(read_only=True), 'referenced_by': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True), 'replies': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True)}¶
- correspondents¶
The emails are set from the
core.models.EmailCorrespondentviaget_correspondents().
- class api.v1.serializers.FullEmailSerializer(*args, **kwargs)[source]¶
Bases:
BaseEmailSerializerA complete serializer for a
core.models.Email.Includes nested serializers for the
core.models.Email.Email.replies,core.models.Email.Email.attachmentsandcore.models.Email.Email.correspondentsforeign key and related fields.- replies: PrimaryKeyRelatedField¶
The replies mails are included by id only to prevent recursion.
- referenced_by: PrimaryKeyRelatedField¶
The referencing mails are included by id only to prevent recursion.
- _declared_fields = {'attachments': BaseAttachmentSerializer(many=True, read_only=True): id = BigIntegerField(label='ID', read_only=True) is_favorite = BooleanField(label='Favorite status', required=False) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) file_name = CharField(label='Filename', read_only=True) content_disposition = CharField(read_only=True) content_id = CharField(label='Content ID', read_only=True) content_maintype = CharField(read_only=True) content_subtype = CharField(read_only=True) datasize = IntegerField(read_only=True) email = PrimaryKeyRelatedField(read_only=True), 'correspondents': SerializerMethodField(read_only=True), 'referenced_by': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True), 'replies': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True)}¶
- attachments¶
The attachments are serialized by
eonvelope.AttachmentSerializers.BaseAttachmentSerializer.BaseAttachmentSerializer.
- correspondents¶
The emails are set from the
core.models.EmailCorrespondentviaget_correspondents().
- class api.v1.serializers.MailboxWithDaemonSerializer(*args, **kwargs)[source]¶
Bases:
BaseMailboxSerializerThe standard serializer for a
core.models.Daemon.Includes a nested serializer for the
core.models.Daemon.Daemon.daemonsrelated field.- _declared_fields = {'daemons': BaseDaemonSerializer(many=True, read_only=True): id = BigIntegerField(label='ID', read_only=True) interval = IntervalScheduleSerializer(): id = IntegerField(label='ID', read_only=True) every = IntegerField(help_text='Number of interval periods to wait before running the task again', label='Number of Periods', max_value=2147483647, min_value=1) period = ChoiceField(choices=[('days', 'Days'), ('hours', 'Hours'), ('minutes', 'Minutes'), ('seconds', 'Seconds'), ('microseconds', 'Microseconds')], help_text='The type of period between task runs (Example: days)', label='Interval Period') celery_task = PeriodicTaskSerializer(read_only=True): enabled = BooleanField(help_text='Set to False to disable the schedule', read_only=True) last_run_at = DateTimeField(allow_null=True, help_text='Datetime that the schedule last triggered the task to run. Reset to None if enabled is set to False.', label='Last Run Datetime', read_only=True) total_run_count = IntegerField(help_text='Running count of how many times the schedule has triggered the task', label='Total Run Count', read_only=True) is_healthy = BooleanField(allow_null=True, label='Health status', read_only=True) last_error = CharField(read_only=True, style={'base_template': 'textarea.html'}) last_error_occurred_at = DateTimeField(allow_null=True, label='Time of last error occurrence', read_only=True) created = DateTimeField(label='Time of creation', read_only=True) updated = DateTimeField(label='Time of last update', read_only=True) uuid = UUIDField(label='UUID', read_only=True) fetching_criterion = ChoiceField(choices=[('DAILY', 'All emails received the last DAY'), ('WEEKLY', 'All emails received the last WEEK'), ('MONTHLY', 'All emails received the last MONTH'), ('ANNUALLY', 'All emails received the last YEAR'), ('RECENT', 'All RECENT emails'), ('UNSEEN', 'All UNSEEN emails'), ('SEEN', 'All SEEN emails'), ('ALL', 'All emails'), ('NEW', 'All RECENT and UNSEEN emails'), ('OLD', 'All emails that are not RECENT'), ('FLAGGED', 'FLAGGED emails'), ('UNFLAGGED', 'All emails that are not FLAGGED'), ('DRAFT', 'All email DRAFTs'), ('UNDRAFT', 'All emails that are not DRAFTs'), ('ANSWERED', 'All ANSWERED emails'), ('UNANSWERED', 'All UNANSWERED emails'), ('DELETED', 'All DELETED emails'), ('UNDELETED', 'All UNDELETED emails'), ('KEYWORD {}', 'All emails with the given KEYWORD'), ('UNKEYWORD {}', 'All emails without the given KEYWORD'), ('LARGER {}', 'All emails LARGER than the given size'), ('SMALLER {}', 'All emails SMALLER than the given size'), ('SUBJECT {}', 'All emails with SUBJECT containing the given text'), ('BODY {}', 'All emails with BODY containing the given text'), ('FROM {}', 'All emails sent FROM the given address'), ('SENTSINCE {}', 'All emails SENT SINCE the given date')], default=EmailFetchingCriterionChoices.ALL, help_text='The selection criterion for emails to archive.') fetching_criterion_arg = CharField(allow_blank=True, help_text='Additional value for the selection criterion.', label='Filter value', max_length=255, required=False) mailbox = PrimaryKeyRelatedField(queryset=Mailbox.objects.all(), required=True)}¶
- daemons¶
The emails are serialized by
api.v1.serializers.BaseDaemonSerializer.
- class api.v1.serializers.UploadEmailSerializer(*args, **kwargs)[source]¶
Bases:
SerializerSerializer for email file upload.
- _declared_fields = {'file': FileField(required=True), 'file_format': ChoiceField(choices=<enum 'SupportedEmailUploadFormats'>, required=True)}¶
- class api.v1.serializers.UserProfileSerializer(*args, **kwargs)[source]¶
Bases:
ModelSerializerThe serializer for
eonvelope.models.UserProfile.- user¶
The
eonvelope.models.UserProfile.userfield is included but hidden.
- class Meta[source]¶
Bases:
objectMetadata class for the serializer.
- model¶
alias of
UserProfile
- exclude = ['id']¶
Include the id field.
- extra_kwargs = {'immich_api_key': {'write_only': True}, 'nextcloud_password': {'write_only': True}, 'paperless_api_key': {'write_only': True}}¶
- _declared_fields = {'user': HiddenField(default=CurrentUserDefault())}¶
Subpackages¶
- api.v1.serializers.account_serializers package
- api.v1.serializers.attachment_serializers package
- api.v1.serializers.correspondent_serializers package
- api.v1.serializers.daemon_serializers package
- api.v1.serializers.email_serializers package
- api.v1.serializers.emailcorrespondent_serializers package
- api.v1.serializers.mailbox_serializers package