# AUTO-GENERATED by ninja-codegen — DO NOT EDIT
# Re-run `ninjastack sync` to regenerate.
# Data Agent for entity: {{ entity.name }}

from __future__ import annotations

from ninja_agents.base import DataAgent
from ninja_agents.tools import generate_crud_tools
from ninja_core.schema.agent import AgentConfig, ReasoningLevel
from ninja_core.schema.entity import EntitySchema, FieldSchema, FieldType, StorageEngine


# Entity definition for {{ entity.name }}
{{ entity.name | upper }}_ENTITY = EntitySchema(
    name={{ entity.name | repr }},
    storage_engine={{ entity.storage_engine.value | repr }},
    fields=[
{% for field in entity.fields %}
        FieldSchema(
            name={{ field.name | repr }},
            field_type=FieldType.{{ field.field_type.value }},
{% if field.primary_key %}
            primary_key=True,
{% endif %}
{% if field.nullable %}
            nullable=True,
{% endif %}
{% if field.unique %}
            unique=True,
{% endif %}
{% if field.indexed %}
            indexed=True,
{% endif %}
        ),
{% endfor %}
    ],
{% if entity.description %}
    description={{ entity.description | repr }},
{% endif %}
{% if entity.collection_name %}
    collection_name={{ entity.collection_name | repr }},
{% endif %}
)

# CRUD tools for {{ entity.name }}
{{ entity.name | upper }}_TOOLS = generate_crud_tools({{ entity.name | upper }}_ENTITY)

# Instantiate the DataAgent (ADK BaseAgent subclass)
{{ entity.name | lower }}_data_agent = DataAgent(
    entity={{ entity.name | upper }}_ENTITY,
    config=AgentConfig(reasoning_level=ReasoningLevel.NONE),
    tools={{ entity.name | upper }}_TOOLS,
)
