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

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 JobsApiRoutesFineTuningUpdateFineTunedModelRequest = {
  /**
   * The ID of the model to update.
   */
  modelId: string;
  updateModelRequest: components.UpdateModelRequest;
};

/**
 * OK
 */
export type JobsApiRoutesFineTuningUpdateFineTunedModelResponse =
  | components.ClassifierFineTunedModel
  | components.CompletionFineTunedModel
  | discriminatedUnionTypes.Unknown<"modelType">;

/** @internal */
export type JobsApiRoutesFineTuningUpdateFineTunedModelRequest$Outbound = {
  model_id: string;
  UpdateModelRequest: components.UpdateModelRequest$Outbound;
};

/** @internal */
export const JobsApiRoutesFineTuningUpdateFineTunedModelRequest$outboundSchema:
  z.ZodType<
    JobsApiRoutesFineTuningUpdateFineTunedModelRequest$Outbound,
    JobsApiRoutesFineTuningUpdateFineTunedModelRequest
  > = z.object({
    modelId: z.string(),
    updateModelRequest: components.UpdateModelRequest$outboundSchema,
  }).transform((v) => {
    return remap$(v, {
      modelId: "model_id",
      updateModelRequest: "UpdateModelRequest",
    });
  });

export function jobsApiRoutesFineTuningUpdateFineTunedModelRequestToJSON(
  jobsApiRoutesFineTuningUpdateFineTunedModelRequest:
    JobsApiRoutesFineTuningUpdateFineTunedModelRequest,
): string {
  return JSON.stringify(
    JobsApiRoutesFineTuningUpdateFineTunedModelRequest$outboundSchema.parse(
      jobsApiRoutesFineTuningUpdateFineTunedModelRequest,
    ),
  );
}

/** @internal */
export const JobsApiRoutesFineTuningUpdateFineTunedModelResponse$inboundSchema:
  z.ZodType<JobsApiRoutesFineTuningUpdateFineTunedModelResponse, unknown> =
    discriminatedUnion("model_type", {
      classifier: components.ClassifierFineTunedModel$inboundSchema,
      completion: components.CompletionFineTunedModel$inboundSchema,
    }, { outputPropertyName: "modelType" });

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