/*
 * 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 PatchAIConfigRequest = {
  /**
   * The project key
   */
  projectKey: string;
  /**
   * The AI Config key
   */
  configKey: string;
  /**
   * AI Config object to update
   */
  aiConfigPatch?: components.AIConfigPatch | undefined;
};

/** @internal */
export const PatchAIConfigRequest$inboundSchema: z.ZodType<
  PatchAIConfigRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectKey: z.string(),
  configKey: z.string(),
  AIConfigPatch: components.AIConfigPatch$inboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    "AIConfigPatch": "aiConfigPatch",
  });
});
/** @internal */
export type PatchAIConfigRequest$Outbound = {
  projectKey: string;
  configKey: string;
  AIConfigPatch?: components.AIConfigPatch$Outbound | undefined;
};

/** @internal */
export const PatchAIConfigRequest$outboundSchema: z.ZodType<
  PatchAIConfigRequest$Outbound,
  z.ZodTypeDef,
  PatchAIConfigRequest
> = z.object({
  projectKey: z.string(),
  configKey: z.string(),
  aiConfigPatch: components.AIConfigPatch$outboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    aiConfigPatch: "AIConfigPatch",
  });
});

export function patchAIConfigRequestToJSON(
  patchAIConfigRequest: PatchAIConfigRequest,
): string {
  return JSON.stringify(
    PatchAIConfigRequest$outboundSchema.parse(patchAIConfigRequest),
  );
}
export function patchAIConfigRequestFromJSON(
  jsonString: string,
): SafeParseResult<PatchAIConfigRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => PatchAIConfigRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'PatchAIConfigRequest' from JSON`,
  );
}
