# ----------------------------------------------------------------------------
#
#  Welcome to Baml! To use this generated code, please run the following:
#
#  $ pip install baml
#
# ----------------------------------------------------------------------------

# This file was generated by BAML: please do not edit it. Instead, edit the
# BAML files and re-generate this code using: baml-cli generate
# baml-cli is available with the baml package.

import typing
from baml_py import type_builder
from baml_py import baml_py

# These are exports, not used here, hence the linter is disabled
from baml_py.baml_py import FieldType, EnumValueBuilder, EnumBuilder, ClassBuilder  # noqa: F401 # pylint: disable=unused-import
from .globals import DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME


class TypeBuilder(type_builder.TypeBuilder):
    def __init__(self):
        super().__init__(
            classes=set(
                [
                    "ResponseModel",
                ]
            ),
            enums=set([]),
            runtime=DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME,
        )

    # #########################################################################
    # Generated enums 0
    # #########################################################################

    # #########################################################################
    # Generated classes 1
    # #########################################################################

    @property
    def ResponseModel(self) -> "ResponseModelBuilder":
        return ResponseModelBuilder(self)


# #########################################################################
# Generated enums 0
# #########################################################################


# #########################################################################
# Generated classes 1
# #########################################################################


class ResponseModelAst:
    def __init__(self, tb: type_builder.TypeBuilder):
        _tb = tb._tb  # type: ignore (we know how to use this private attribute)
        self._bldr = _tb.class_("ResponseModel")
        self._properties: typing.Set[str] = set([])
        self._props = ResponseModelProperties(self._bldr, self._properties)

    def type(self) -> baml_py.FieldType:
        return self._bldr.field()

    @property
    def props(self) -> "ResponseModelProperties":
        return self._props


class ResponseModelBuilder(ResponseModelAst):
    def __init__(self, tb: type_builder.TypeBuilder):
        super().__init__(tb)

    def add_property(self, name: str, type: baml_py.FieldType) -> baml_py.ClassPropertyBuilder:
        if name in self._properties:
            raise ValueError(f"Property {name} already exists.")
        return self._bldr.property(name).type(type)

    def list_properties(self) -> typing.List[typing.Tuple[str, baml_py.ClassPropertyBuilder]]:
        return self._bldr.list_properties()

    def remove_property(self, name: str) -> None:
        self._bldr.remove_property(name)

    def reset(self) -> None:
        self._bldr.reset()


class ResponseModelProperties:
    def __init__(self, bldr: baml_py.ClassBuilder, properties: typing.Set[str]):
        self.__bldr = bldr
        self.__properties = properties  # type: ignore (we know how to use this private attribute) # noqa: F821

    def __getattr__(self, name: str) -> baml_py.ClassPropertyBuilder:
        if name not in self.__properties:
            raise AttributeError(f"Property {name} not found.")
        return self.__bldr.property(name)
