"""
Nom du script : gitlab_project_service.py
Chemin : /gitlab-bridge/app/services/gitlab_project_service.py
Description : Service de résolution d'un projet GitLab par son chemin namespace/projet.
Options éventuelles : Aucune.
Exemples d'utilisation : `GitLabProjectService(client).resolve_project(path)`.
Prérequis : Python 3.11+.
Auteur : Sylvain SCATTOLINI
Date de création / modification : 2026-03-25
Version : 1.1
"""

from __future__ import annotations

from app.clients.gitlab_client import GitLabClient
from app.core.exceptions import GitLabApiError, ProjectNotFoundError


class GitLabProjectService:
    """Résout un projet GitLab et masque les détails techniques."""

    def __init__(self, client: GitLabClient) -> None:
        self.client = client

    def resolve_project(self, project_path: str) -> dict:
        try:
            return self.client.get_project_by_path(project_path)
        except GitLabApiError as exc:
            if 'HTTP 404' in str(exc):
                raise ProjectNotFoundError() from exc
            raise
