from __future__ import annotations

{% if unobservable_properties or observable_properties or unobservable_commands or observable_commands %}
from typing import Any, Dict
from sila2.framework import FullyQualifiedIdentifier
{% endif %}

{% for definition in definition_imports %}
from ..generated.{{ feature._identifier|lower }} import {{ definition }}
{% endfor %}

{% for import_ in imports %}
from {{ import_.origin }} import {{ import_.target }}
{% endfor %}

{% if metadata %}
from typing import List, Union
from sila2.framework import Feature, Command, Property, FullyQualifiedIdentifier
{% endif %}

{% for cmd in unobservable_commands %}
from ..generated.{{ feature._identifier|lower }} import {{ cmd.name }}_Responses
{% endfor %}
{% for cmd in observable_commands %}
from ..generated.{{ feature._identifier|lower }} import {{ cmd.name }}_Responses
    {% if cmd.intermediate_responses %}
from ..generated.{{ feature._identifier|lower }} import {{ cmd.name }}_IntermediateResponses
from sila2.server import ObservableCommandInstanceWithIntermediateResponses
    {% else %}
from sila2.server import ObservableCommandInstance
    {% endif %}
{% endfor %}

from ..generated.{{ feature._identifier|lower }} import {{ feature._identifier }}Base

class {{ feature._identifier }}Impl({{ feature._identifier }}Base):
{% if not unobservable_properties and not observable_commands and not unobservable_commands %}
    pass
{% endif %}
{% for prop in unobservable_properties %}
    def get_{{ prop.name }}(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> {{ prop.type.representation }}:
        raise NotImplementedError  # TODO
{% endfor %}

{% for cmd in unobservable_commands %}
    def {{ cmd.name }}(
    self,
    {% for param in cmd.parameters %}{{ param.name }}: {{ param.type.representation }},{% endfor %}
    *,
    metadata: Dict[FullyQualifiedIdentifier, Any]
    ) -> {{ cmd.name }}_Responses:
        raise NotImplementedError  # TODO
{% endfor %}

{% for cmd in observable_commands %}
    def {{ cmd.name }}(
        self,
        {% for param in cmd.parameters %}{{ param.name }}: {{ param.type.representation }},{% endfor %}
        *,
        metadata: Dict[FullyQualifiedIdentifier, Any],
        {% if cmd.intermediate_responses %}
        instance: ObservableCommandInstanceWithIntermediateResponses[{{ cmd.name }}_IntermediateResponses],
        {% else %}
        instance: ObservableCommandInstance
        {% endif %}
    ) -> {{ cmd.name }}_Responses:
        raise NotImplementedError  # TODO
{% endfor %}

{% for meta in metadata %}
    def get_calls_affected_by_{{ meta.name }}(self) -> List[Union[Feature, Command, Property, FullyQualifiedIdentifier]]:
        raise NotImplementedError  # TODO
{% endfor %}
