# generated by datamodel-codegen:
#   filename:  run-results_v6.json

from __future__ import annotations

from enum import Enum
from typing import Any
from typing import Optional
from typing import Union

from pydantic import ConfigDict
from pydantic import Field

from vendor.dbt_artifacts_parser.parsers.base import BaseParserModel


class Metadata(BaseParserModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    dbt_schema_version: str
    dbt_version: Optional[str] = "1.9.0b2"
    generated_at: Optional[str] = None
    invocation_id: Optional[str] = None
    env: Optional[dict[str, str]] = None


class Status(Enum):
    success = "success"
    error = "error"
    skipped = "skipped"
    partial_success = "partial success"


class Status1(Enum):
    pass_ = "pass"
    error = "error"
    fail = "fail"
    warn = "warn"
    skipped = "skipped"


class Status2(Enum):
    pass_ = "pass"
    warn = "warn"
    error = "error"
    runtime_error = "runtime error"


class TimingItem(BaseParserModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    name: str
    started_at: Optional[str] = None
    completed_at: Optional[str] = None


class BatchResults(BaseParserModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    successful: Optional[list[list]] = None
    failed: Optional[list[list]] = None


class Result(BaseParserModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    status: Union[Status, Status1, Status2]
    timing: list[TimingItem]
    thread_id: str
    execution_time: float
    adapter_response: dict[str, Any]
    message: Optional[str] = None
    failures: Optional[int] = None
    unique_id: str
    compiled: Optional[bool] = None
    compiled_code: Optional[str] = None
    relation_name: Optional[str] = None
    batch_results: Optional[BatchResults] = None


class RunResultsV6(BaseParserModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    metadata: Metadata = Field(..., title="BaseArtifactMetadata")
    results: list[Result]
    elapsed_time: float
    args: Optional[dict[str, Any]] = None
