from typing import Dict
from typing import Any

{% if config.field_params %}
@configure("""
{{ config.json(indent=4, include=set(["field_params"])) }}
""")
{% endif -%}
class {{ config.name }}:
    """
    {% filter indent(4) -%}
    {{ config.doc }}
    {%- endfilter %}
    """

    def __init__{{ config.signature }}:
        """
        {% filter indent(8) -%}
        {{ config.init_doc }}
        {%- endfilter %}
        """
        self._request_base: Dict[str, Any] = {
            "class_name": "{{ config.name }}",
            {%- for param in config.signature.parameters %}
            {%- if param != "self" %}
            "{{ param }}": {{ param }},
            {%- endif %}
            {%- endfor %}
        }

    {%- for method_config in config.method_configs %}

    {% if method_config.field_params %}
    @configure("""
    {% filter indent(4) -%}
    {{ method_config.json(indent=4, include=set(["field_params"])) }}
    {%- endfilter %}
    """)
    {% endif -%}
    def {{ method_config.name }}{{ method_config.signature }}:
        """
        {% filter indent(8) -%}
        {{ method_config.doc }}
        {%- endfilter %}
        """
        request = self._request_base.copy()
        request["function"] = {
            "func_name": "{{ method_config.name }}",
            {%- for param in method_config.signature.parameters %}
            {%- if param != "self" %}
            "{{ param }}": {{ param }}{% if not loop.last %},{% endif %}
            {%- endif %}
            {%- endfor %}
        }

        model = BackendModule.parse_obj(request)
        response = model.compute()

        return response.__root__  # type: ignore
    {%- endfor %}
