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

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 RetrieveModelV1ModelsModelIdGetRequest = {
  /**
   * The ID of the model to retrieve.
   */
  modelId: string;
};

/**
 * Successful Response
 */
export type ResponseRetrieveModelV1ModelsModelIdGet =
  | components.BaseModelCard
  | components.FTModelCard
  | discriminatedUnionTypes.Unknown<"type">;

/** @internal */
export type RetrieveModelV1ModelsModelIdGetRequest$Outbound = {
  model_id: string;
};

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

export function retrieveModelV1ModelsModelIdGetRequestToJSON(
  retrieveModelV1ModelsModelIdGetRequest:
    RetrieveModelV1ModelsModelIdGetRequest,
): string {
  return JSON.stringify(
    RetrieveModelV1ModelsModelIdGetRequest$outboundSchema.parse(
      retrieveModelV1ModelsModelIdGetRequest,
    ),
  );
}

/** @internal */
export const ResponseRetrieveModelV1ModelsModelIdGet$inboundSchema: z.ZodType<
  ResponseRetrieveModelV1ModelsModelIdGet,
  unknown
> = discriminatedUnion("type", {
  base: components.BaseModelCard$inboundSchema,
  ["fine-tuned"]: components.FTModelCard$inboundSchema,
});

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