# coding: utf-8

"""
    Instana REST API documentation

    Documentation for INSTANA REST API

    The version of the OpenAPI document: 1.309.1268
    Contact: support@instana.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class CursorPagination(BaseModel):
    """
    Details for controlling the pagination of the API response. This object allows you to define the starting point for retrieving records, how many records to skip, and the size of the result set. 
    """ # noqa: E501
    ingestion_time: Optional[StrictInt] = Field(default=None, description="The timestamp indicating the starting point from which data was ingested. The format of the timestamp is in Unix epoch Time. For example, `Thursday, 5 September 2024 07:03:13 GMT` can be represented as `1725519793`. ", alias="ingestionTime")
    offset: Optional[StrictInt] = Field(default=None, description="The number of records to be skipped from the `ingestionTime`. For example: when `offset` is 20 and `ingestionTime` is 1725519793, the API response should have records starting from the 21st record after the specified `ingestionTime`. Note that if `offset` value is not empty, `ingestionTime` can't be empty. ")
    retrieval_size: Optional[Annotated[int, Field(le=200, strict=True, ge=1)]] = Field(default=None, description="The number of records to retrieve in a single request. For example, when retrievalSize is set to 30, offset is 20, and ingestionTime is 1725519793, the API request will fetch 30 records starting from the 21st record after the specified `ingestionTime`. Minimum value is 1 and maximum value is 200. ", alias="retrievalSize")
    __properties: ClassVar[List[str]] = ["ingestionTime", "offset", "retrievalSize"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CursorPagination from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CursorPagination from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "ingestionTime": obj.get("ingestionTime"),
            "offset": obj.get("offset"),
            "retrievalSize": obj.get("retrievalSize")
        })
        return _obj


