# coding: utf-8

"""
    Train Journey

    Demonstrate feature of Aladdin Graph services using train journeys, stations and trains.  # noqa: E501

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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


from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr
from aladdinsdk.api.codegen.reference_architecture.demo.train_journey.v1.TrainJourneyAPI.models.v1_train_journey_query import V1TrainJourneyQuery

class V1FilterTrainJourneysRequest(BaseModel):
    """
    The Request body of the `FilterTrainJourneys` call.
    """
    query: Optional[V1TrainJourneyQuery] = None
    page_token: Optional[StrictStr] = Field(None, alias="pageToken", description="The starting point of a query result.")
    page_size: Optional[StrictInt] = Field(None, alias="pageSize", description="The maximum number of train journeys to be returned per page of results. The page size is 1000. Otherwise, the maximum allowed page size is 100.  Default is 100 if empty or a number < 1 is specified.")
    __properties = ["query", "pageToken", "pageSize"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of query
        if self.query:
            _dict['query'] = self.query.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1FilterTrainJourneysRequest:
        """Create an instance of V1FilterTrainJourneysRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1FilterTrainJourneysRequest.parse_obj(obj)

        _obj = V1FilterTrainJourneysRequest.parse_obj({
            "query": V1TrainJourneyQuery.from_dict(obj.get("query")) if obj.get("query") is not None else None,
            "page_token": obj.get("pageToken"),
            "page_size": obj.get("pageSize")
        })
        return _obj

