from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

@dataclass
class PackagesGetResponse_pagination(Parsable):
    """
    Describes pagination details for the response, including information about the current page and navigation to other pages.
    """
    # The maximum number of results to be displayed on each page.
    limit: Optional[int] = None
    # The URL to retrieve the subsequent page of results, if available. If not included, this is the last page of data.
    next_url: Optional[str] = None
    # The number of results skipped before starting the current page.
    offset: Optional[int] = None
    # The URL to retrieve the preceding page of results, if applicable. Not returned on the first page of results.
    previous_url: Optional[str] = None
    # The overall count of results available across all pages.
    total_results: Optional[int] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> PackagesGetResponse_pagination:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: PackagesGetResponse_pagination
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return PackagesGetResponse_pagination()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "limit": lambda n : setattr(self, 'limit', n.get_int_value()),
            "nextUrl": lambda n : setattr(self, 'next_url', n.get_str_value()),
            "offset": lambda n : setattr(self, 'offset', n.get_int_value()),
            "previousUrl": lambda n : setattr(self, 'previous_url', n.get_str_value()),
            "totalResults": lambda n : setattr(self, 'total_results', n.get_int_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_int_value("limit", self.limit)
        writer.write_str_value("nextUrl", self.next_url)
        writer.write_int_value("offset", self.offset)
        writer.write_str_value("previousUrl", self.previous_url)
        writer.write_int_value("totalResults", self.total_results)
    

