# coding: utf-8

"""
    Hindsight HTTP API

    HTTP API for Hindsight

    The version of the OpenAPI document: 0.6.1
    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class BankTemplateConfig(BaseModel):
    """
    Bank configuration fields within a template manifest.  Only includes configurable (per-bank) fields. Credential fields (API keys, base URLs) are intentionally excluded for security.
    """ # noqa: E501
    reflect_mission: Optional[StrictStr] = None
    retain_mission: Optional[StrictStr] = None
    retain_extraction_mode: Optional[StrictStr] = None
    retain_custom_instructions: Optional[StrictStr] = None
    retain_chunk_size: Optional[StrictInt] = None
    enable_observations: Optional[StrictBool] = None
    observations_mission: Optional[StrictStr] = None
    disposition_skepticism: Optional[Annotated[int, Field(le=5, strict=True, ge=1)]] = None
    disposition_literalism: Optional[Annotated[int, Field(le=5, strict=True, ge=1)]] = None
    disposition_empathy: Optional[Annotated[int, Field(le=5, strict=True, ge=1)]] = None
    entity_labels: Optional[List[Dict[str, Any]]] = None
    entities_allow_free_form: Optional[StrictBool] = None
    retain_default_strategy: Optional[StrictStr] = None
    retain_strategies: Optional[Dict[str, Any]] = None
    retain_chunk_batch_size: Optional[StrictInt] = None
    mcp_enabled_tools: Optional[List[StrictStr]] = None
    consolidation_llm_batch_size: Optional[StrictInt] = None
    consolidation_source_facts_max_tokens: Optional[StrictInt] = None
    consolidation_source_facts_max_tokens_per_observation: Optional[StrictInt] = None
    max_observations_per_scope: Optional[StrictInt] = None
    reflect_source_facts_max_tokens: Optional[StrictInt] = None
    llm_gemini_safety_settings: Optional[List[Any]] = None
    recall_budget_function: Optional[StrictStr] = None
    recall_budget_fixed_low: Optional[StrictInt] = None
    recall_budget_fixed_mid: Optional[StrictInt] = None
    recall_budget_fixed_high: Optional[StrictInt] = None
    recall_budget_adaptive_low: Optional[Union[StrictFloat, StrictInt]] = None
    recall_budget_adaptive_mid: Optional[Union[StrictFloat, StrictInt]] = None
    recall_budget_adaptive_high: Optional[Union[StrictFloat, StrictInt]] = None
    recall_budget_min: Optional[StrictInt] = None
    recall_budget_max: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["reflect_mission", "retain_mission", "retain_extraction_mode", "retain_custom_instructions", "retain_chunk_size", "enable_observations", "observations_mission", "disposition_skepticism", "disposition_literalism", "disposition_empathy", "entity_labels", "entities_allow_free_form", "retain_default_strategy", "retain_strategies", "retain_chunk_batch_size", "mcp_enabled_tools", "consolidation_llm_batch_size", "consolidation_source_facts_max_tokens", "consolidation_source_facts_max_tokens_per_observation", "max_observations_per_scope", "reflect_source_facts_max_tokens", "llm_gemini_safety_settings", "recall_budget_function", "recall_budget_fixed_low", "recall_budget_fixed_mid", "recall_budget_fixed_high", "recall_budget_adaptive_low", "recall_budget_adaptive_mid", "recall_budget_adaptive_high", "recall_budget_min", "recall_budget_max"]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "reflect_mission": obj.get("reflect_mission"),
            "retain_mission": obj.get("retain_mission"),
            "retain_extraction_mode": obj.get("retain_extraction_mode"),
            "retain_custom_instructions": obj.get("retain_custom_instructions"),
            "retain_chunk_size": obj.get("retain_chunk_size"),
            "enable_observations": obj.get("enable_observations"),
            "observations_mission": obj.get("observations_mission"),
            "disposition_skepticism": obj.get("disposition_skepticism"),
            "disposition_literalism": obj.get("disposition_literalism"),
            "disposition_empathy": obj.get("disposition_empathy"),
            "entity_labels": obj.get("entity_labels"),
            "entities_allow_free_form": obj.get("entities_allow_free_form"),
            "retain_default_strategy": obj.get("retain_default_strategy"),
            "retain_strategies": obj.get("retain_strategies"),
            "retain_chunk_batch_size": obj.get("retain_chunk_batch_size"),
            "mcp_enabled_tools": obj.get("mcp_enabled_tools"),
            "consolidation_llm_batch_size": obj.get("consolidation_llm_batch_size"),
            "consolidation_source_facts_max_tokens": obj.get("consolidation_source_facts_max_tokens"),
            "consolidation_source_facts_max_tokens_per_observation": obj.get("consolidation_source_facts_max_tokens_per_observation"),
            "max_observations_per_scope": obj.get("max_observations_per_scope"),
            "reflect_source_facts_max_tokens": obj.get("reflect_source_facts_max_tokens"),
            "llm_gemini_safety_settings": obj.get("llm_gemini_safety_settings"),
            "recall_budget_function": obj.get("recall_budget_function"),
            "recall_budget_fixed_low": obj.get("recall_budget_fixed_low"),
            "recall_budget_fixed_mid": obj.get("recall_budget_fixed_mid"),
            "recall_budget_fixed_high": obj.get("recall_budget_fixed_high"),
            "recall_budget_adaptive_low": obj.get("recall_budget_adaptive_low"),
            "recall_budget_adaptive_mid": obj.get("recall_budget_adaptive_mid"),
            "recall_budget_adaptive_high": obj.get("recall_budget_adaptive_high"),
            "recall_budget_min": obj.get("recall_budget_min"),
            "recall_budget_max": obj.get("recall_budget_max")
        })
        return _obj


