/*
 * 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 AIConfigPatch = {
  /**
   * Key of the variation this config serves by default
   */
  defaultVariationKey?: string | undefined;
  /**
   * A description of the AI Config
   */
  description?: string | undefined;
  /**
   * The ID of the member who maintains this resource
   */
  maintainerId?: string | undefined;
  /**
   * The key of the team that maintains this resource
   */
  maintainerTeamKey?: string | undefined;
  /**
   * A human-readable name for the AI Config
   */
  name?: string | undefined;
  /**
   * Tags for this resource
   */
  tags?: Array<string> | undefined;
  /**
   * Evaluation metric key for this config
   */
  evaluationMetricKey?: string | undefined;
  /**
   * Whether the evaluation metric is inverted, meaning a lower value is better if set as true
   */
  isInverted?: boolean | undefined;
};

/** @internal */
export const AIConfigPatch$inboundSchema: z.ZodType<
  AIConfigPatch,
  z.ZodTypeDef,
  unknown
> = z.object({
  defaultVariationKey: z.string().optional(),
  description: z.string().optional(),
  maintainerId: z.string().optional(),
  maintainerTeamKey: z.string().optional(),
  name: z.string().optional(),
  tags: z.array(z.string()).optional(),
  evaluationMetricKey: z.string().optional(),
  isInverted: z.boolean().optional(),
});
/** @internal */
export type AIConfigPatch$Outbound = {
  defaultVariationKey?: string | undefined;
  description?: string | undefined;
  maintainerId?: string | undefined;
  maintainerTeamKey?: string | undefined;
  name?: string | undefined;
  tags?: Array<string> | undefined;
  evaluationMetricKey?: string | undefined;
  isInverted?: boolean | undefined;
};

/** @internal */
export const AIConfigPatch$outboundSchema: z.ZodType<
  AIConfigPatch$Outbound,
  z.ZodTypeDef,
  AIConfigPatch
> = z.object({
  defaultVariationKey: z.string().optional(),
  description: z.string().optional(),
  maintainerId: z.string().optional(),
  maintainerTeamKey: z.string().optional(),
  name: z.string().optional(),
  tags: z.array(z.string()).optional(),
  evaluationMetricKey: z.string().optional(),
  isInverted: z.boolean().optional(),
});

export function aiConfigPatchToJSON(aiConfigPatch: AIConfigPatch): string {
  return JSON.stringify(AIConfigPatch$outboundSchema.parse(aiConfigPatch));
}
export function aiConfigPatchFromJSON(
  jsonString: string,
): SafeParseResult<AIConfigPatch, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AIConfigPatch$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AIConfigPatch' from JSON`,
  );
}
