from __future__ import annotations

from typing import Set
from sila2.client import SilaClient
from sila2.framework import FullyQualifiedIdentifier

{% for feature in features %}
    {% if feature.defined_execution_errors %}
from .{{ feature._identifier.lower() }} import {{ feature._identifier }}Feature
        {% for error in feature.defined_execution_errors.keys() %}
from .{{ feature._identifier.lower() }} import {{ error }}
        {% endfor %}
    {% endif %}
{% endfor %}

{% for feature in features %}
from .{{ feature._identifier.lower() }} import {{ feature._identifier }}Client
{% endfor %}


class Client(SilaClient):
    {% for feature in features %}
    {{ feature._identifier }}: {{ feature._identifier }}Client
    {% endfor %}
    _expected_features: Set[FullyQualifiedIdentifier] = {
        FullyQualifiedIdentifier("org.silastandard/core/SiLAService/v1"),
    {% for feature in features %}
        {{ feature.fully_qualified_identifier|repr }},
    {% endfor %}
    }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        {% for feature in features %}
            {% for error in feature.defined_execution_errors.keys() %}
        self._register_defined_execution_error_class(
            {{ feature._identifier }}Feature.defined_execution_errors["{{ error }}"], {{ error }}
        )
            {% endfor %}
        {% endfor %}
