/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 252d6c0d8fdf
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import * as discriminatedUnionTypes from "../../types/discriminatedUnion.js";
import { discriminatedUnion } from "../../types/discriminatedUnion.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type JobsApiRoutesFineTuningCancelFineTuningJobRequest = {
  /**
   * The ID of the job to cancel.
   */
  jobId: string;
};

/**
 * OK
 */
export type JobsApiRoutesFineTuningCancelFineTuningJobResponse =
  | components.ClassifierFineTuningJobDetails
  | components.CompletionFineTuningJobDetails
  | discriminatedUnionTypes.Unknown<"jobType">;

/** @internal */
export type JobsApiRoutesFineTuningCancelFineTuningJobRequest$Outbound = {
  job_id: string;
};

/** @internal */
export const JobsApiRoutesFineTuningCancelFineTuningJobRequest$outboundSchema:
  z.ZodType<
    JobsApiRoutesFineTuningCancelFineTuningJobRequest$Outbound,
    JobsApiRoutesFineTuningCancelFineTuningJobRequest
  > = z.object({
    jobId: z.string(),
  }).transform((v) => {
    return remap$(v, {
      jobId: "job_id",
    });
  });

export function jobsApiRoutesFineTuningCancelFineTuningJobRequestToJSON(
  jobsApiRoutesFineTuningCancelFineTuningJobRequest:
    JobsApiRoutesFineTuningCancelFineTuningJobRequest,
): string {
  return JSON.stringify(
    JobsApiRoutesFineTuningCancelFineTuningJobRequest$outboundSchema.parse(
      jobsApiRoutesFineTuningCancelFineTuningJobRequest,
    ),
  );
}

/** @internal */
export const JobsApiRoutesFineTuningCancelFineTuningJobResponse$inboundSchema:
  z.ZodType<JobsApiRoutesFineTuningCancelFineTuningJobResponse, unknown> =
    discriminatedUnion("job_type", {
      classifier: components.ClassifierFineTuningJobDetails$inboundSchema,
      completion: components.CompletionFineTuningJobDetails$inboundSchema,
    }, { outputPropertyName: "jobType" });

export function jobsApiRoutesFineTuningCancelFineTuningJobResponseFromJSON(
  jsonString: string,
): SafeParseResult<
  JobsApiRoutesFineTuningCancelFineTuningJobResponse,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      JobsApiRoutesFineTuningCancelFineTuningJobResponse$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'JobsApiRoutesFineTuningCancelFineTuningJobResponse' from JSON`,
  );
}
