# Path: ecs_scheduler/models.py
# class Pagination:
#     """
#     Job pagination parameters.
# 
#     :param skip: The number of jobs to skip
#     :param count: The number of jobs to return
#     :param total: The total number of jobs across all pages;
#                   used to calculate next and prev page links
#     """
#     skip: int
#     count: int
#     total: int = 0


import random
import re
import apscheduler.triggers.cron
import marshmallow
from pytz.exceptions import UnknownTimeZoneError
from .models import Pagination
    representation.

    Used for serialization only.
    """
    # override id to include in dump output
    id = marshmallow.fields.String(dump_only=True)
    link = marshmallow.fields.Method('link_generator', dump_only=True)
    lastRun = marshmallow.fields.LocalDateTime(dump_only=True)
    lastRunTasks = marshmallow.fields.List(
        marshmallow.fields.Nested(TaskInfoSchema), dump_only=True
    )
    estimatedNextRun = marshmallow.fields.LocalDateTime(dump_only=True)

    def __init__(self, link_func, *args, **kwargs):
        self._link_func = link_func
        super().__init__(*args, **kwargs)

    def link_generator(self, obj):
        return self._link_func(obj['id'])


class PaginationSchema(marshmallow.Schema):
    """Schema for pagination arguments."""
    skip = marshmallow.fields.Integer(missing=0)
    count = marshmallow.fields.Integer(missing=10)

    @marshmallow.post_load
    def make_pagination(self, data):
        for field in self.fields.keys():
            data[field] = max(0, data[field])

# Path: ecs_scheduler/models.py
# class Pagination:
#     """
#     Job pagination parameters.
# 
#     :param skip: The number of jobs to skip
#     :param count: The number of jobs to return
#     :param total: The total number of jobs across all pages;
#                   used to calculate next and prev page links
#     """
#     skip: int
#     count: int
#     total: int = 0


# Path: ecs_scheduler/serialization.py
import random
import re
import apscheduler.triggers.cron
import marshmallow
from pytz.exceptions import UnknownTimeZoneError
from .models import Pagination

    representation.

    Used for serialization only.
    """
    # override id to include in dump output
    id = marshmallow.fields.String(dump_only=True)
    link = marshmallow.fields.Method('link_generator', dump_only=True)
    lastRun = marshmallow.fields.LocalDateTime(dump_only=True)
    lastRunTasks = marshmallow.fields.List(
        marshmallow.fields.Nested(TaskInfoSchema), dump_only=True
    )
    estimatedNextRun = marshmallow.fields.LocalDateTime(dump_only=True)

    def __init__(self, link_func, *args, **kwargs):
        self._link_func = link_func
        super().__init__(*args, **kwargs)

    def link_generator(self, obj):
        return self._link_func(obj['id'])


class PaginationSchema(marshmallow.Schema):
    """Schema for pagination arguments."""
    skip = marshmallow.fields.Integer(missing=0)
    count = marshmallow.fields.Integer(missing=10)

    @marshmallow.post_load
    def make_pagination(self, data):
        for field in self.fields.keys():
            data[field] = max(0, data[field])

        return Pagination(**data)