/*
 * 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";
import {
  AiConfigsAccessAllowedReason,
  AiConfigsAccessAllowedReason$inboundSchema,
  AiConfigsAccessAllowedReason$Outbound,
  AiConfigsAccessAllowedReason$outboundSchema,
} from "./aiconfigsaccessallowedreason.js";

export type AiConfigsAccessAllowedRep = {
  action: string;
  reason: AiConfigsAccessAllowedReason;
};

/** @internal */
export const AiConfigsAccessAllowedRep$inboundSchema: z.ZodType<
  AiConfigsAccessAllowedRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  action: z.string(),
  reason: AiConfigsAccessAllowedReason$inboundSchema,
});
/** @internal */
export type AiConfigsAccessAllowedRep$Outbound = {
  action: string;
  reason: AiConfigsAccessAllowedReason$Outbound;
};

/** @internal */
export const AiConfigsAccessAllowedRep$outboundSchema: z.ZodType<
  AiConfigsAccessAllowedRep$Outbound,
  z.ZodTypeDef,
  AiConfigsAccessAllowedRep
> = z.object({
  action: z.string(),
  reason: AiConfigsAccessAllowedReason$outboundSchema,
});

export function aiConfigsAccessAllowedRepToJSON(
  aiConfigsAccessAllowedRep: AiConfigsAccessAllowedRep,
): string {
  return JSON.stringify(
    AiConfigsAccessAllowedRep$outboundSchema.parse(aiConfigsAccessAllowedRep),
  );
}
export function aiConfigsAccessAllowedRepFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsAccessAllowedRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsAccessAllowedRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsAccessAllowedRep' from JSON`,
  );
}
