from dataclasses import dataclass
from enum import IntEnum
from typing import *


{% for import in imports -%}
from . import {{ import }}
{% endfor %}


{% for error in errors %}
class {{ error.name }}(Exception):
{%- if error.fields %}
    def __init__(
        self,
        {%- for field in error.fields %}
            {{ field.name }}: {{ field.type }}{% if field.value is not none %} = {{ field.value }}{% endif %},
        {%- endfor %}
    ):
        ...
{%- else %}
    pass
{%- endif %}
{% endfor %}


{% for enum in enums %}
class {{ enum.name }}(IntEnum):
{%- for field  in enum.fields %}
    {{ field.name }} = {{ field.value }}
{%- endfor %}
{% endfor %}


{% for struct in structs %}
@dataclass
class {{ struct.name }}:
{%- for field in struct.fields %}
    {{ field.name }}: {{ field.type }}{% if field.value is not none %} = {{ field.value }}{% endif %}
{%- else %}
    pass
{%- endfor %}
{% endfor %}


{% for service in services %}
class {{ service.name }}:
{%- for method in service.methods %}
    {% if is_async %}async {% endif %}def {{ method.name }}(
        self,
{%- for arg in method.args %}
        {{ arg.name }}: {{ arg.type }},
{%- endfor %}
    ) -> {{ method.return_type }}:
        ...
{%- else %}
    pass
{% endfor %}
{% endfor %}