from __future__ import annotations

from infrahub_sync.plugin_loader import PluginLoader

from .sync_models import (
{% for nodekind, node in schema.items()|sort() %}
{%-   if node | get_identifiers(config) %}    {{ nodekind }},
{%   endif -%}
{% endfor -%}
)

# Load adapter class dynamically at runtime
{% if adapter.adapter %}
_loader = PluginLoader()
_AdapterBaseClass = _loader.resolve("{{ adapter.adapter }}")
{% else %}
_AdapterBaseClass = PluginLoader().resolve("{{ adapter.name }}")
{% endif %}

# -------------------------------------------------------
# AUTO-GENERATED FILE, DO NOT MODIFY
#  This file has been generated with the command `infrahub-sync generate`
#  All modifications will be lost the next time you reexecute this command
# -------------------------------------------------------
class {{ adapter.name.title() }}Sync(_AdapterBaseClass):
{% for nodekind, node in schema.items() -%}
{%-   if node | get_identifiers(config) %}    {{ node.kind }} = {{ nodekind }}
{%   endif -%}
{% endfor %}
