from __future__ import annotations

from typing import Optional

from cachelib import BaseCache, SimpleCache

from cognite.pygen.dm_clients.cdf.get_client import get_client_config
from cognite.pygen.dm_clients.domain_modeling import DomainClient, DomainModelAPI

from .schema import {% for model in models %}{{ model.name }}, {% endfor %}{{ schema_name }}


class {{ client_name_camel }}(DomainClient):
    """
    Domain-specific client class for the entire domain.
    This class can contain any domain-specific logic, but is entirely optional. The attributes below (`actor` and
    `movie`) are created in the base class, and here we have only added type annotations so that IntelliSense can work.
    """
    {% for  model in models %}
    {{ model.name_snake }}: DomainModelAPI[{{ model.name }}]{% endfor %}


def get_{{ client_name_snake }}(
    cache: Optional[BaseCache] = None,
    space_id: Optional[str] = None,
    data_model: Optional[str] = None,
    schema_version: Optional[int] = None,
) -> {{ client_name_camel }}:
    """Quick way of instantiating a {{ client_name_camel }} with sensible defaults for development."""
    cache = SimpleCache() if cache is None else cache
    config = get_client_config()
    return {{ client_name_camel }}({{ schema_name }}, DomainModelAPI, cache, config, space_id, data_model, schema_version)
