api.v1.views.MailboxViewSet module

Module with the MailboxViewSet viewset.

class api.v1.views.MailboxViewSet.MailboxViewSet(**kwargs)[source]

Bases: ReadOnlyModelViewSet, UpdateModelMixin, DestroyModelMixin, ToggleFavoriteMixin

Viewset for the core.models.Mailbox.Mailbox.

Provides all but the create action.

BASENAME = 'mailbox'
serializer_class

alias of MailboxWithDaemonSerializer

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]
filterset_class

alias of MailboxFilterSet

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
ordering_fields: Final[list[str]] = ['name', 'account__mail_address', 'account__mail_host', 'account__protocol', 'save_attachments', 'save_to_eml', 'is_favorite', 'is_healthy', 'created', 'updated']
ordering: Final[list[str]] = ['id']
get_queryset()[source]

Filters the data for entries connected to the request user.

Return type:

QuerySet

Returns:

The mailbox entries matching the request user.

URL_PATH_TEST = 'test'
URL_NAME_TEST = 'test'
test(request, pk=None)[source]

Action method testing the mailbox data.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the mailbox to test. Defaults to None.

Return type:

Response

Returns:

A response containing the updated mailbox data and the test result.

URL_PATH_FETCHING_OPTIONS = 'fetching-options'
URL_NAME_FETCHING_OPTIONS = 'fetching-options'
fetching_options(request, pk=None)[source]

Action method returning all fetching options for the mailbox.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – int: The private key of the mailbox. Defaults to None.

Return type:

Response

Returns:

A response detailing the request status.

URL_PATH_FETCH = 'fetch'
URL_NAME_FETCH = 'fetch'
fetch(request, pk=None)[source]

Action method fetching all mails from the mailbox.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the mailbox. Defaults to None.

Return type:

Response

Returns:

A response with the mailbox data.

URL_PATH_DOWNLOAD = 'download'
URL_NAME_DOWNLOAD = 'download'
download(request, pk=None)[source]

Action method downloading the eml files of all emails in the mailbox in a single file.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to download. Defaults to None.

Raises:
  • Http404 – If there are no emails in the mailbox.

  • ValidationError – If file_format is missing or unsupported.

Return type:

Response | FileResponse

Returns:

A fileresponse containing the emails in the requested format.

URL_PATH_DOWNLOAD_BATCH = 'download'
URL_NAME_DOWNLOAD_BATCH = 'download-batch'
download_batch(request)[source]

Action method downloading a batch of mailboxes.

Todo

Validation and parsing of queryparams can probably be done more concisely with a serializer.

Parameters:

request (Request) – The request triggering the action.

Raises:
  • Http404 – If there are no emails in the mailbox.

  • ValidationError – If id or file_format param is missing or in invalid format or file_format is unsupported.

Return type:

Response | FileResponse

Returns:

A fileresponse containing the mailboxes emails in the requested format.

URL_PATH_UPLOAD_MAILBOX = 'upload'
URL_NAME_UPLOAD_MAILBOX = 'upload'
upload_emails(request, pk=None)[source]

Action method allowing upload of a mailbox file and adding the contained mails to a mailbox.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – int: The private key of the mailbox to upload to. Defaults to None.

Return type:

Response

Returns:

A response detailing the request status.

basename = None
description = None
destroy(request, *args, **kwargs)
detail = None
list(request, *args, **kwargs)
name = None
retrieve(request, *args, **kwargs)
suffix = None
update(request, *args, **kwargs)