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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type JudgeAttachment = {
  /**
   * Judge config key
   */
  judgeConfigKey: string;
  /**
   * Sampling rate for this judge attachment (0.0 to 1.0)
   */
  samplingRate: number;
};

/** @internal */
export const JudgeAttachment$inboundSchema: z.ZodType<
  JudgeAttachment,
  z.ZodTypeDef,
  unknown
> = z.object({
  judgeConfigKey: z.string(),
  samplingRate: z.number(),
});
/** @internal */
export type JudgeAttachment$Outbound = {
  judgeConfigKey: string;
  samplingRate: number;
};

/** @internal */
export const JudgeAttachment$outboundSchema: z.ZodType<
  JudgeAttachment$Outbound,
  z.ZodTypeDef,
  JudgeAttachment
> = z.object({
  judgeConfigKey: z.string(),
  samplingRate: z.number(),
});

export function judgeAttachmentToJSON(
  judgeAttachment: JudgeAttachment,
): string {
  return JSON.stringify(JudgeAttachment$outboundSchema.parse(judgeAttachment));
}
export function judgeAttachmentFromJSON(
  jsonString: string,
): SafeParseResult<JudgeAttachment, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => JudgeAttachment$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'JudgeAttachment' from JSON`,
  );
}
