# coding: utf-8

"""
    FlowHunt

    FlowHunt API

    The version of the OpenAPI document: 2.0.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from flowhunt.models.pagination import Pagination
from typing import Optional, Set
from typing_extensions import Self

class ScheduleUrlSearchRequest(BaseModel):
    """
    ScheduleUrlSearchRequest
    """ # noqa: E501
    schedule_id: Optional[StrictStr] = None
    domain_id: Optional[StrictStr] = None
    url_id: Optional[StrictStr] = None
    url: Optional[StrictStr] = None
    text_timestamp_from: Optional[datetime] = None
    text_timestamp_to: Optional[datetime] = None
    url_title: Optional[StrictStr] = None
    is_original_url: Optional[StrictBool] = None
    created_at_from: Optional[datetime] = None
    created_at_to: Optional[datetime] = None
    limit: Optional[StrictInt] = None
    pagination: Optional[Pagination] = None
    __properties: ClassVar[List[str]] = ["schedule_id", "domain_id", "url_id", "url", "text_timestamp_from", "text_timestamp_to", "url_title", "is_original_url", "created_at_from", "created_at_to", "limit", "pagination"]

    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 ScheduleUrlSearchRequest 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,
        )
        # override the default output from pydantic by calling `to_dict()` of pagination
        if self.pagination:
            _dict['pagination'] = self.pagination.to_dict()
        # set to None if schedule_id (nullable) is None
        # and model_fields_set contains the field
        if self.schedule_id is None and "schedule_id" in self.model_fields_set:
            _dict['schedule_id'] = None

        # set to None if domain_id (nullable) is None
        # and model_fields_set contains the field
        if self.domain_id is None and "domain_id" in self.model_fields_set:
            _dict['domain_id'] = None

        # set to None if url_id (nullable) is None
        # and model_fields_set contains the field
        if self.url_id is None and "url_id" in self.model_fields_set:
            _dict['url_id'] = None

        # set to None if url (nullable) is None
        # and model_fields_set contains the field
        if self.url is None and "url" in self.model_fields_set:
            _dict['url'] = None

        # set to None if text_timestamp_from (nullable) is None
        # and model_fields_set contains the field
        if self.text_timestamp_from is None and "text_timestamp_from" in self.model_fields_set:
            _dict['text_timestamp_from'] = None

        # set to None if text_timestamp_to (nullable) is None
        # and model_fields_set contains the field
        if self.text_timestamp_to is None and "text_timestamp_to" in self.model_fields_set:
            _dict['text_timestamp_to'] = None

        # set to None if url_title (nullable) is None
        # and model_fields_set contains the field
        if self.url_title is None and "url_title" in self.model_fields_set:
            _dict['url_title'] = None

        # set to None if is_original_url (nullable) is None
        # and model_fields_set contains the field
        if self.is_original_url is None and "is_original_url" in self.model_fields_set:
            _dict['is_original_url'] = None

        # set to None if created_at_from (nullable) is None
        # and model_fields_set contains the field
        if self.created_at_from is None and "created_at_from" in self.model_fields_set:
            _dict['created_at_from'] = None

        # set to None if created_at_to (nullable) is None
        # and model_fields_set contains the field
        if self.created_at_to is None and "created_at_to" in self.model_fields_set:
            _dict['created_at_to'] = None

        # set to None if limit (nullable) is None
        # and model_fields_set contains the field
        if self.limit is None and "limit" in self.model_fields_set:
            _dict['limit'] = None

        # set to None if pagination (nullable) is None
        # and model_fields_set contains the field
        if self.pagination is None and "pagination" in self.model_fields_set:
            _dict['pagination'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "schedule_id": obj.get("schedule_id"),
            "domain_id": obj.get("domain_id"),
            "url_id": obj.get("url_id"),
            "url": obj.get("url"),
            "text_timestamp_from": obj.get("text_timestamp_from"),
            "text_timestamp_to": obj.get("text_timestamp_to"),
            "url_title": obj.get("url_title"),
            "is_original_url": obj.get("is_original_url"),
            "created_at_from": obj.get("created_at_from"),
            "created_at_to": obj.get("created_at_to"),
            "limit": obj.get("limit"),
            "pagination": Pagination.from_dict(obj["pagination"]) if obj.get("pagination") is not None else None
        })
        return _obj


