# 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 pydantic import BaseModel, ConfigDict, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from flowhunt.models.app_url_input import AppUrlInput
from flowhunt.models.bool_char import BoolChar
from flowhunt.models.schedule_frequency import ScheduleFrequency
from flowhunt.models.schedule_type import ScheduleType
from typing import Optional, Set
from typing_extensions import Self

class ScheduleCreateRequest(BaseModel):
    """
    ScheduleCreateRequest
    """ # noqa: E501
    url: AppUrlInput
    frequency: ScheduleFrequency
    schedule_type: ScheduleType
    with_screenshot: Optional[BoolChar] = None
    with_browser: Optional[BoolChar] = None
    follow_links: Optional[BoolChar] = None
    with_proxy_rotation: Optional[BoolChar] = None
    disallow_urls: Optional[StrictStr] = None
    filter_urls: Optional[StrictStr] = None
    custom_headers: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["url", "frequency", "schedule_type", "with_screenshot", "with_browser", "follow_links", "with_proxy_rotation", "disallow_urls", "filter_urls", "custom_headers"]

    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 ScheduleCreateRequest 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 url
        if self.url:
            _dict['url'] = self.url.to_dict()
        # set to None if with_screenshot (nullable) is None
        # and model_fields_set contains the field
        if self.with_screenshot is None and "with_screenshot" in self.model_fields_set:
            _dict['with_screenshot'] = None

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "url": AppUrlInput.from_dict(obj["url"]) if obj.get("url") is not None else None,
            "frequency": obj.get("frequency"),
            "schedule_type": obj.get("schedule_type"),
            "with_screenshot": obj.get("with_screenshot"),
            "with_browser": obj.get("with_browser"),
            "follow_links": obj.get("follow_links"),
            "with_proxy_rotation": obj.get("with_proxy_rotation"),
            "disallow_urls": obj.get("disallow_urls"),
            "filter_urls": obj.get("filter_urls"),
            "custom_headers": obj.get("custom_headers")
        })
        return _obj


