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

export type AiConfigsAccessDenied = {
  action: string;
  reason: AiConfigsAccessDeniedReason;
};

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

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

export function aiConfigsAccessDeniedToJSON(
  aiConfigsAccessDenied: AiConfigsAccessDenied,
): string {
  return JSON.stringify(
    AiConfigsAccessDenied$outboundSchema.parse(aiConfigsAccessDenied),
  );
}
export function aiConfigsAccessDeniedFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsAccessDenied, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsAccessDenied$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsAccessDenied' from JSON`,
  );
}
