api.v1.serializers.daemon_serializers.BaseDaemonSerializer module

Module with the BaseDaemonSerializer serializer class.

class api.v1.serializers.daemon_serializers.BaseDaemonSerializer.BaseDaemonSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

The 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.Daemon should 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: object

Metadata class for the base serializer.

Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this. read_only_fields and exclude must not be shortened in subclasses.

model

The model to serialize.

alias of Daemon

fields: ClassVar[str] = '__all__'

Include all fields.

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.created and core.models.Daemon.Daemon.updated fields 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.

Parameters:

attrs (dict[str, Any]) – The attributes on the serializer.

Return type:

dict[str, Any]

Returns:

The same attributes.

Raises:

serializers.ValidationError – If the validation fails.

validate_mailbox(value)[source]

Validate that the given mailbox belongs to the requesting user.

Return type:

Mailbox

Parameters:

value (Mailbox)

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

Return type:

Daemon

Parameters:
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

Return type:

Daemon

Parameters:

validated_data (dict)