/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.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 RetrieveModelV1ModelsModelIdGetResponseRetrieveModelV1ModelsModelIdGet =
  | (components.BaseModelCard & { type: "base" })
  | (components.FTModelCard & { type: "fine-tuned" });

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

/** @internal */
export const RetrieveModelV1ModelsModelIdGetRequest$outboundSchema: z.ZodType<
  RetrieveModelV1ModelsModelIdGetRequest$Outbound,
  z.ZodTypeDef,
  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 RetrieveModelV1ModelsModelIdGetResponseRetrieveModelV1ModelsModelIdGet$inboundSchema:
  z.ZodType<
    RetrieveModelV1ModelsModelIdGetResponseRetrieveModelV1ModelsModelIdGet,
    z.ZodTypeDef,
    unknown
  > = z.union([
    components.BaseModelCard$inboundSchema.and(
      z.object({ type: z.literal("base") }),
    ),
    components.FTModelCard$inboundSchema.and(
      z.object({ type: z.literal("fine-tuned") }),
    ),
  ]);

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