# -*- coding: utf-8 -*-
"""
Nom du fichier : groups.py
Chemin : /var/www/html/gitlab-bridge/app/schemas/groups.py
Description : Schémas Pydantic liés à la recherche de groupes GitLab pour le bridge OpenWebUI.
Options éventuelles :
    - Aucun
Exemples d'utilisation :
    - Import dans app/api/v1/groups.py
Prérequis :
    - Python 3.11+
    - Pydantic v2
Auteur : Sylvain SCATTOLINI
Date de création / modification : 2026-03-26
Version : 1.1
"""

from __future__ import annotations

from pydantic import BaseModel, ConfigDict, Field


class GroupMatch(BaseModel):
    """
    Groupe GitLab candidat renvoyé par la recherche.
    """

    model_config = ConfigDict(extra="forbid")

    id: int
    name: str
    full_path: str
    score: int


class GroupSearchRequest(BaseModel):
    """
    Requête de recherche de groupes.
    """

    model_config = ConfigDict(extra="forbid")

    query: str = Field(..., min_length=1, max_length=255)
    root_hint: str = Field(default="", max_length=255)
    limit: int = Field(default=10, ge=1, le=50)


class GroupSearchResponse(BaseModel):
    """
    Réponse de recherche de groupes.
    """

    model_config = ConfigDict(extra="forbid")

    success: bool = True
    query: str
    matches: list[GroupMatch]