from psycopg import Connection
from src.__types.index import TenantAuthInfo
from src.infrastructure.repositories.tenant_repository import TenantRepository


class TenantAuthInfoUseCase:
    def __init__(self, tenant_repository: TenantRepository) -> None:
        self.tenant_repository = tenant_repository

    @classmethod
    def create(cls, connection: Connection) -> "TenantAuthInfoUseCase":
        return cls(tenant_repository=TenantRepository(connection=connection))

    def get(self, name: str) -> TenantAuthInfo:
        """指定されたテナント名のユーザー認証情報を取得する。"""
        return self.tenant_repository.get_auth_info_by_name(name=name)
