# coding: utf-8

"""
    Neurograph Core

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from neurograph.v1.models.reports_data_source_config import ReportsDataSourceConfig
from neurograph.v1.models.reports_date_range import ReportsDateRange
from typing import Optional, Set
from typing_extensions import Self

class ReportsReportGenerateRequest(BaseModel):
    """
    ReportsReportGenerateRequest
    """ # noqa: E501
    analysis_type: Optional[StrictStr] = None
    brand_context: Optional[Dict[str, Any]] = None
    client_id: Optional[StrictStr] = None
    custom_prompt: Optional[StrictStr] = None
    data_sources: Optional[List[ReportsDataSourceConfig]] = None
    date_range: Optional[ReportsDateRange] = None
    dry_run: Optional[StrictBool] = None
    end_date: Optional[StrictStr] = None
    max_rows: Optional[StrictInt] = None
    name: Optional[StrictStr] = None
    output_format: Optional[StrictStr] = None
    personas: Optional[List[StrictStr]] = None
    report_type: Optional[StrictStr] = None
    start_date: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["analysis_type", "brand_context", "client_id", "custom_prompt", "data_sources", "date_range", "dry_run", "end_date", "max_rows", "name", "output_format", "personas", "report_type", "start_date"]

    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 ReportsReportGenerateRequest 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 each item in data_sources (list)
        _items = []
        if self.data_sources:
            for _item_data_sources in self.data_sources:
                if _item_data_sources:
                    _items.append(_item_data_sources.to_dict())
            _dict['data_sources'] = _items
        # override the default output from pydantic by calling `to_dict()` of date_range
        if self.date_range:
            _dict['date_range'] = self.date_range.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "analysis_type": obj.get("analysis_type"),
            "brand_context": obj.get("brand_context"),
            "client_id": obj.get("client_id"),
            "custom_prompt": obj.get("custom_prompt"),
            "data_sources": [ReportsDataSourceConfig.from_dict(_item) for _item in obj["data_sources"]] if obj.get("data_sources") is not None else None,
            "date_range": ReportsDateRange.from_dict(obj["date_range"]) if obj.get("date_range") is not None else None,
            "dry_run": obj.get("dry_run"),
            "end_date": obj.get("end_date"),
            "max_rows": obj.get("max_rows"),
            "name": obj.get("name"),
            "output_format": obj.get("output_format"),
            "personas": obj.get("personas"),
            "report_type": obj.get("report_type"),
            "start_date": obj.get("start_date")
        })
        return _obj


