# coding: utf-8

"""
    Kestra EE

    All API operations, except for Superadmin-only endpoints, require a tenant identifier in the HTTP path.<br/> Endpoints designated as Superadmin-only are not tenant-scoped.

    The version of the OpenAPI document: v1
    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, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from kestrapy.models.banner import Banner
from kestrapy.models.edition_provider_edition import EditionProviderEdition
from kestrapy.models.left_sidebar_configuration import LeftSidebarConfiguration
from kestrapy.models.misc_controller_environment import MiscControllerEnvironment
from kestrapy.models.misc_controller_plugin_id_and_version import MiscControllerPluginIdAndVersion
from kestrapy.models.misc_controller_preview import MiscControllerPreview
from kestrapy.models.misc_controller_tenant_configuration_info import MiscControllerTenantConfigurationInfo
from kestrapy.models.query_filter_resource_field import QueryFilterResourceField
from kestrapy.models.right_sidebar_configuration import RightSidebarConfiguration
from typing import Optional, Set
from typing_extensions import Self

class MiscControllerEEConfiguration(BaseModel):
    """
    MiscControllerEEConfiguration
    """ # noqa: E501
    uuid: Optional[StrictStr] = None
    version: Optional[StrictStr] = None
    edition: Optional[EditionProviderEdition] = None
    commit_id: Optional[StrictStr] = Field(default=None, alias="commitId")
    commit_date: Optional[datetime] = Field(default=None, alias="commitDate")
    is_custom_dashboards_enabled: Optional[StrictBool] = Field(default=None, alias="isCustomDashboardsEnabled")
    is_task_run_enabled: Optional[StrictBool] = Field(default=None, alias="isTaskRunEnabled")
    is_anonymous_usage_enabled: Optional[StrictBool] = Field(default=None, alias="isAnonymousUsageEnabled")
    is_ui_anonymous_usage_enabled: Optional[StrictBool] = Field(default=None, alias="isUiAnonymousUsageEnabled")
    is_template_enabled: Optional[StrictBool] = Field(default=None, alias="isTemplateEnabled")
    environment: Optional[MiscControllerEnvironment] = None
    url: Optional[StrictStr] = None
    preview: Optional[MiscControllerPreview] = None
    system_namespace: Optional[StrictStr] = Field(default=None, alias="systemNamespace")
    hidden_labels_prefixes: Optional[List[StrictStr]] = Field(default=None, alias="hiddenLabelsPrefixes")
    resource_to_filters: Optional[List[QueryFilterResourceField]] = Field(default=None, alias="resourceToFilters")
    is_ai_enabled: Optional[StrictBool] = Field(default=None, alias="isAiEnabled")
    is_basic_auth_initialized: Optional[StrictBool] = Field(default=None, alias="isBasicAuthInitialized")
    plugins_hash: Optional[StrictInt] = Field(default=None, alias="pluginsHash")
    tenants: Optional[MiscControllerTenantConfigurationInfo] = None
    secrets_enabled: Optional[StrictBool] = Field(default=None, alias="secretsEnabled")
    supported_storages: Optional[List[MiscControllerPluginIdAndVersion]] = Field(default=None, alias="supportedStorages")
    supported_secrets: Optional[List[MiscControllerPluginIdAndVersion]] = Field(default=None, alias="supportedSecrets")
    plugin_management_enabled: Optional[StrictBool] = Field(default=None, alias="pluginManagementEnabled")
    plugin_custom_enabled: Optional[StrictBool] = Field(default=None, alias="pluginCustomEnabled")
    banner: Optional[Banner] = None
    mail_service_enabled: Optional[StrictBool] = Field(default=None, alias="mailServiceEnabled")
    outputs_in_internal_storage_enabled: Optional[StrictBool] = Field(default=None, alias="outputsInInternalStorageEnabled")
    left_sidebar: Optional[LeftSidebarConfiguration] = Field(default=None, alias="leftSidebar")
    right_sidebar: Optional[RightSidebarConfiguration] = Field(default=None, alias="rightSidebar")
    in_maintenance: Optional[StrictBool] = Field(default=None, alias="inMaintenance")
    password_regexp: Optional[StrictStr] = Field(default=None, alias="passwordRegexp")
    passwordless_enabled: Optional[StrictBool] = Field(default=None, alias="passwordlessEnabled")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["uuid", "version", "edition", "commitId", "commitDate", "isCustomDashboardsEnabled", "isTaskRunEnabled", "isAnonymousUsageEnabled", "isUiAnonymousUsageEnabled", "isTemplateEnabled", "environment", "url", "preview", "systemNamespace", "hiddenLabelsPrefixes", "resourceToFilters", "isAiEnabled", "isBasicAuthInitialized", "pluginsHash", "tenants", "secretsEnabled", "supportedStorages", "supportedSecrets", "pluginManagementEnabled", "pluginCustomEnabled", "banner", "mailServiceEnabled", "outputsInInternalStorageEnabled", "leftSidebar", "rightSidebar", "inMaintenance", "passwordRegexp", "passwordlessEnabled"]

    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 MiscControllerEEConfiguration 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.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set([
            "additional_properties",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of environment
        if self.environment:
            _dict['environment'] = self.environment.to_dict()
        # override the default output from pydantic by calling `to_dict()` of preview
        if self.preview:
            _dict['preview'] = self.preview.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in resource_to_filters (list)
        _items = []
        if self.resource_to_filters:
            for _item_resource_to_filters in self.resource_to_filters:
                if _item_resource_to_filters:
                    _items.append(_item_resource_to_filters.to_dict())
            _dict['resourceToFilters'] = _items
        # override the default output from pydantic by calling `to_dict()` of tenants
        if self.tenants:
            _dict['tenants'] = self.tenants.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in supported_storages (list)
        _items = []
        if self.supported_storages:
            for _item_supported_storages in self.supported_storages:
                if _item_supported_storages:
                    _items.append(_item_supported_storages.to_dict())
            _dict['supportedStorages'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in supported_secrets (list)
        _items = []
        if self.supported_secrets:
            for _item_supported_secrets in self.supported_secrets:
                if _item_supported_secrets:
                    _items.append(_item_supported_secrets.to_dict())
            _dict['supportedSecrets'] = _items
        # override the default output from pydantic by calling `to_dict()` of banner
        if self.banner:
            _dict['banner'] = self.banner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of left_sidebar
        if self.left_sidebar:
            _dict['leftSidebar'] = self.left_sidebar.to_dict()
        # override the default output from pydantic by calling `to_dict()` of right_sidebar
        if self.right_sidebar:
            _dict['rightSidebar'] = self.right_sidebar.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

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

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

        _obj = cls.model_validate({
            "uuid": obj.get("uuid"),
            "version": obj.get("version"),
            "edition": obj.get("edition"),
            "commitId": obj.get("commitId"),
            "commitDate": obj.get("commitDate"),
            "isCustomDashboardsEnabled": obj.get("isCustomDashboardsEnabled"),
            "isTaskRunEnabled": obj.get("isTaskRunEnabled"),
            "isAnonymousUsageEnabled": obj.get("isAnonymousUsageEnabled"),
            "isUiAnonymousUsageEnabled": obj.get("isUiAnonymousUsageEnabled"),
            "isTemplateEnabled": obj.get("isTemplateEnabled"),
            "environment": MiscControllerEnvironment.from_dict(obj["environment"]) if obj.get("environment") is not None else None,
            "url": obj.get("url"),
            "preview": MiscControllerPreview.from_dict(obj["preview"]) if obj.get("preview") is not None else None,
            "systemNamespace": obj.get("systemNamespace"),
            "hiddenLabelsPrefixes": obj.get("hiddenLabelsPrefixes"),
            "resourceToFilters": [QueryFilterResourceField.from_dict(_item) for _item in obj["resourceToFilters"]] if obj.get("resourceToFilters") is not None else None,
            "isAiEnabled": obj.get("isAiEnabled"),
            "isBasicAuthInitialized": obj.get("isBasicAuthInitialized"),
            "pluginsHash": obj.get("pluginsHash"),
            "tenants": MiscControllerTenantConfigurationInfo.from_dict(obj["tenants"]) if obj.get("tenants") is not None else None,
            "secretsEnabled": obj.get("secretsEnabled"),
            "supportedStorages": [MiscControllerPluginIdAndVersion.from_dict(_item) for _item in obj["supportedStorages"]] if obj.get("supportedStorages") is not None else None,
            "supportedSecrets": [MiscControllerPluginIdAndVersion.from_dict(_item) for _item in obj["supportedSecrets"]] if obj.get("supportedSecrets") is not None else None,
            "pluginManagementEnabled": obj.get("pluginManagementEnabled"),
            "pluginCustomEnabled": obj.get("pluginCustomEnabled"),
            "banner": Banner.from_dict(obj["banner"]) if obj.get("banner") is not None else None,
            "mailServiceEnabled": obj.get("mailServiceEnabled"),
            "outputsInInternalStorageEnabled": obj.get("outputsInInternalStorageEnabled"),
            "leftSidebar": LeftSidebarConfiguration.from_dict(obj["leftSidebar"]) if obj.get("leftSidebar") is not None else None,
            "rightSidebar": RightSidebarConfiguration.from_dict(obj["rightSidebar"]) if obj.get("rightSidebar") is not None else None,
            "inMaintenance": obj.get("inMaintenance"),
            "passwordRegexp": obj.get("passwordRegexp"),
            "passwordlessEnabled": obj.get("passwordlessEnabled")
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


