from __future__ import annotations

from dataclasses import dataclass

from packages.domain import IngestJob
from packages.ports.ingest_job_repository import IngestJobRepository


@dataclass(slots=True)
class SubmitIngestJobCommand:
    project_id: str
    library_id: str
    storage_key: str
    file_hash: str = ""


class SubmitIngestJobUseCase:
    def __init__(self, ingest_job_repository: IngestJobRepository):
        self.ingest_job_repository = ingest_job_repository

    def execute(self, command: SubmitIngestJobCommand) -> IngestJob:
        job = IngestJob.create(
            project_id=command.project_id,
            library_id=command.library_id,
            storage_key=command.storage_key,
            file_hash=command.file_hash,
        )
        return self.ingest_job_repository.create(job)
