"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: d175c6e32ecb

from __future__ import annotations
from .classifierfinetuningjobdetails import (
    ClassifierFineTuningJobDetails,
    ClassifierFineTuningJobDetailsTypedDict,
)
from .completionfinetuningjobdetails import (
    CompletionFineTuningJobDetails,
    CompletionFineTuningJobDetailsTypedDict,
)
from functools import partial
from mistralai.client.types import BaseModel
from mistralai.client.utils import FieldMetadata, PathParamMetadata
from mistralai.client.utils.unions import parse_open_union
from pydantic import ConfigDict
from pydantic.functional_validators import BeforeValidator
from typing import Any, Literal, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


class JobsAPIRoutesFineTuningCancelFineTuningJobRequestTypedDict(TypedDict):
    job_id: str
    r"""The ID of the job to cancel."""


class JobsAPIRoutesFineTuningCancelFineTuningJobRequest(BaseModel):
    job_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The ID of the job to cancel."""


JobsAPIRoutesFineTuningCancelFineTuningJobResponseTypedDict = TypeAliasType(
    "JobsAPIRoutesFineTuningCancelFineTuningJobResponseTypedDict",
    Union[
        CompletionFineTuningJobDetailsTypedDict, ClassifierFineTuningJobDetailsTypedDict
    ],
)
r"""OK"""


class UnknownJobsAPIRoutesFineTuningCancelFineTuningJobResponse(BaseModel):
    r"""A JobsAPIRoutesFineTuningCancelFineTuningJobResponse variant the SDK doesn't recognize. Preserves the raw payload."""

    job_type: Literal["UNKNOWN"] = "UNKNOWN"
    raw: Any
    is_unknown: Literal[True] = True

    model_config = ConfigDict(frozen=True)


_JOBS_API_ROUTES_FINE_TUNING_CANCEL_FINE_TUNING_JOB_RESPONSE_VARIANTS: dict[
    str, Any
] = {
    "classifier": ClassifierFineTuningJobDetails,
    "completion": CompletionFineTuningJobDetails,
}


JobsAPIRoutesFineTuningCancelFineTuningJobResponse = Annotated[
    Union[
        ClassifierFineTuningJobDetails,
        CompletionFineTuningJobDetails,
        UnknownJobsAPIRoutesFineTuningCancelFineTuningJobResponse,
    ],
    BeforeValidator(
        partial(
            parse_open_union,
            disc_key="job_type",
            variants=_JOBS_API_ROUTES_FINE_TUNING_CANCEL_FINE_TUNING_JOB_RESPONSE_VARIANTS,
            unknown_cls=UnknownJobsAPIRoutesFineTuningCancelFineTuningJobResponse,
            union_name="JobsAPIRoutesFineTuningCancelFineTuningJobResponse",
        )
    ),
]
r"""OK"""
